<ins> error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/leaking-unnameables.rs:8:18 | LL | pub fn f<T>() -> _ { |                  ^ |                  | |                  not allowed in type signatures |                  help: replace with the correct return type: `fn()` error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0121`. </ins>


submit_post_lto_module_to_llvm, submit_pre_lto_module_to_llvm, ComputedLtoType, OngoingCodegen, }; use crate::common::{self, IntPredicate, RealPredicate, TypeKind}; <ins> use crate::meth::load_vtable; </ins> use crate::mir::operand::OperandValue; use crate::mir::place::PlaceRef; use crate::traits::*;


if let Some(entry_idx) = vptr_entry_idx { let ptr_size = bx.data_layout().pointer_size; <del> let ptr_align = bx.data_layout().pointer_align.abi; </del> let vtable_byte_offset = u64::try_from(entry_idx).unwrap() * ptr_size.bytes(); <del> let gep = bx.inbounds_ptradd(old_info, bx.const_usize(vtable_byte_offset)); let new_vptr = bx.load(bx.type_ptr(), gep, ptr_align); bx.nonnull_metadata(new_vptr); // VTable loads are invariant. bx.set_invariant_load(new_vptr); new_vptr </del> <ins> load_vtable(bx, old_info, bx.type_ptr(), vtable_byte_offset, source, true) </ins> } else { old_info }


let llty = bx.fn_ptr_backend_type(fn_abi); let ptr_size = bx.data_layout().pointer_size; <del> let ptr_align = bx.data_layout().pointer_align.abi; </del> let vtable_byte_offset = self.0 * ptr_size.bytes(); <del> if bx.cx().sess().opts.unstable_opts.virtual_function_elimination && bx.cx().sess().lto() == Lto::Fat { let typeid = bx .typeid_metadata(typeid_for_trait_ref(bx.tcx(), expect_dyn_trait_in_self(ty))) .unwrap(); let func = bx.type_checked_load(llvtable, vtable_byte_offset, typeid); func } else { let gep = bx.inbounds_ptradd(llvtable, bx.const_usize(vtable_byte_offset)); let ptr = bx.load(llty, gep, ptr_align); // VTable loads are invariant. bx.set_invariant_load(ptr); if nonnull { bx.nonnull_metadata(ptr); } ptr } </del> <ins> load_vtable(bx, llvtable, llty, vtable_byte_offset, ty, nonnull) </ins> } pub(crate) fn get_optional_fn<Bx: BuilderMethods<'a, 'tcx>>(


self, bx: &mut Bx, llvtable: Bx::Value, <ins> ty: Ty<'tcx>, </ins> ) -> Bx::Value { // Load the data pointer from the object. debug!("get_int({:?}, {:?})", llvtable, self); let llty = bx.type_isize(); let ptr_size = bx.data_layout().pointer_size; <del> let ptr_align = bx.data_layout().pointer_align.abi; </del> let vtable_byte_offset = self.0 * ptr_size.bytes(); <del> let gep = bx.inbounds_ptradd(llvtable, bx.const_usize(vtable_byte_offset)); let ptr = bx.load(llty, gep, ptr_align); // VTable loads are invariant. bx.set_invariant_load(ptr); ptr </del> <ins> load_vtable(bx, llvtable, llty, vtable_byte_offset, ty, false) </ins> } } /// This takes a valid `self` receiver type and extracts the principal trait <del> /// ref of the type. fn expect_dyn_trait_in_self(ty: Ty<'_>) -> ty::PolyExistentialTraitRef<'_> { </del> <ins> /// ref of the type. Return `None` if there is no principal trait. fn dyn_trait_in_self(ty: Ty<'_>) -> Option<ty::PolyExistentialTraitRef<'_>> { </ins> for arg in ty.peel_refs().walk() { if let GenericArgKind::Type(ty) = arg.unpack() && let ty::Dynamic(data, _, _) = ty.kind() { <del> return data.principal().expect("expected principal trait object"); </del> <ins> return data.principal(); </ins> } }


cx.vtables().borrow_mut().insert((ty, trait_ref), vtable); vtable } <ins> /// Call this function whenever you need to load a vtable. pub(crate) fn load_vtable<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( bx: &mut Bx, llvtable: Bx::Value, llty: Bx::Type, vtable_byte_offset: u64, ty: Ty<'tcx>, nonnull: bool, ) -> Bx::Value { let ptr_align = bx.data_layout().pointer_align.abi; if bx.cx().sess().opts.unstable_opts.virtual_function_elimination && bx.cx().sess().lto() == Lto::Fat { if let Some(trait_ref) = dyn_trait_in_self(ty) { let typeid = bx.typeid_metadata(typeid_for_trait_ref(bx.tcx(), trait_ref)).unwrap(); let func = bx.type_checked_load(llvtable, vtable_byte_offset, typeid); return func; } else if nonnull { bug!("load nonnull value from a vtable without a principal trait") } } let gep = bx.inbounds_ptradd(llvtable, bx.const_usize(vtable_byte_offset)); let ptr = bx.load(llty, gep, ptr_align); // VTable loads are invariant. bx.set_invariant_load(ptr); if nonnull { bx.nonnull_metadata(ptr); } ptr } </ins>


sym::vtable_align => ty::COMMON_VTABLE_ENTRIES_ALIGN, _ => bug!(), }; <del> let value = meth::VirtualIndex::from_index(idx).get_usize(bx, vtable); </del> <ins> let value = meth::VirtualIndex::from_index(idx).get_usize(bx, vtable, callee_ty); </ins> match name { // Size is always <= isize::MAX. sym::vtable_size => {


// Load size/align from vtable. let vtable = info.unwrap(); let size = meth::VirtualIndex::from_index(ty::COMMON_VTABLE_ENTRIES_SIZE) <del> .get_usize(bx, vtable); </del> <ins> .get_usize(bx, vtable, t); </ins> let align = meth::VirtualIndex::from_index(ty::COMMON_VTABLE_ENTRIES_ALIGN) <del> .get_usize(bx, vtable); </del> <ins> .get_usize(bx, vtable, t); </ins> // Size is always <= isize::MAX. let size_bound = bx.data_layout().ptr_sized_integer().signed_max() as u128;


<del> //@ known-bug: #123955 //@ compile-flags: -Clto -Zvirtual-function-elimination //@ only-x86_64 pub fn main() { _ = Box::new(()) as Box<dyn Send>; } </del>


<del> //@ known-bug: #124092 //@ compile-flags: -Zvirtual-function-elimination=true -Clto=true //@ only-x86_64 const X: for<'b> fn(&'b ()) = |&()| (); fn main() { let dyn_debug = Box::new(X) as Box<fn(&'static ())> as Box<dyn Send>; } </del>


<ins> //@ build-pass //@ compile-flags: -Zvirtual-function-elimination=true -Clto=true //@ only-x86_64 //@ no-prefer-dynamic // issue #123955 pub fn test0() { _ = Box::new(()) as Box<dyn Send>; } // issue #124092 const X: for<'b> fn(&'b ()) = |&()| (); pub fn test1() { let _dyn_debug = Box::new(X) as Box<fn(&'static ())> as Box<dyn Send>; } fn main() {} </ins>


} #[inline(always)] <del> pub unsafe fn init(_argc: isize, _argv: *const *const u8) { // On Linux-GNU, we rely on `ARGV_INIT_ARRAY` below to initialize // `ARGC` and `ARGV`. But in Miri that does not actually happen so we // still initialize here. #[cfg(any(miri, not(all(target_os = "linux", target_env = "gnu"))))] really_init(_argc, _argv); </del> <ins> pub unsafe fn init(argc: isize, argv: *const *const u8) { // on GNU/Linux if we are main then we will init argv and argc twice, it "duplicates work" // BUT edge-cases are real: only using .init_array can break most emulators, dlopen, etc. really_init(argc, argv); </ins> } /// glibc passes argc, argv, and envp to functions in .init_array, as a non-standard extension.


self.space(); } MatchKind::Postfix => { <del> self.print_expr_as_cond(expr); </del> <ins> self.print_expr_maybe_paren(expr, parser::PREC_POSTFIX, fixup); </ins> self.word_nbsp(".match"); } }


<del> #![feature(postfix_match)] fn main() { let val = Some(42); val.match { Some(_) => 2, _ => 1 }; Some(2).match { Some(_) => true, None => false }.match { false => "ferris is cute", true => "I turn cats in to petted cats", }.match { _ => (), } } </del>


<ins> #![feature(prelude_import)] #![no_std] #![feature(postfix_match)] #[prelude_import] use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; use std::ops::Add; //@ pretty-mode:expanded //@ pp-exact:precedence.pp macro_rules! repro { ($e:expr) => { $e.match { _ => {} } }; } struct Struct {} impl Add<Struct> for usize { type Output = (); fn add(self, _: Struct) -> () { () } } pub fn main() { let a; ( { 1 } + 1).match { _ => {} }; (4 as usize).match { _ => {} }; (return).match { _ => {} }; (a = 42).match { _ => {} }; (|| {}).match { _ => {} }; (42..101).match { _ => {} }; (1 + Struct {}).match { _ => {} }; } </ins>


<ins> #![feature(postfix_match)] use std::ops::Add; //@ pretty-mode:expanded //@ pp-exact:precedence.pp macro_rules! repro { ($e:expr) => { $e.match { _ => {} } }; } struct Struct {} impl Add<Struct> for usize { type Output = (); fn add(self, _: Struct) -> () { () } } pub fn main() { let a; repro!({ 1 } + 1); repro!(4 as usize); repro!(return); repro!(a = 42); repro!(|| {}); repro!(42..101); repro!(1 + Struct {}); } </ins>


<ins> #![feature(postfix_match)] fn main() { let val = Some(42); val.match { Some(_) => 2, _ => 1 }; Some(2).match { Some(_) => true, None => false }.match { false => "ferris is cute", true => "I turn cats in to petted cats", }.match { _ => (), } } </ins>


use std::str; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, OnceLock}; <del> use std::time::{Instant, SystemTime}; </del> <ins> use std::time::{Duration, Instant, SystemTime}; </ins> use time::OffsetDateTime; use tracing::trace;


pub fn install_ctrlc_handler() { #[cfg(not(target_family = "wasm"))] ctrlc::set_handler(move || { <del> // Indicate that we have been signaled to stop. If we were already signaled, exit // immediately. In our interpreter loop we try to consult this value often, but if for // whatever reason we don't get to that check or the cleanup we do upon finding that // this bool has become true takes a long time, the exit here will promptly exit the // process on the second Ctrl-C. if CTRL_C_RECEIVED.swap(true, Ordering::Relaxed) { std::process::exit(1); } </del> <ins> // Indicate that we have been signaled to stop, then give the rest of the compiler a bit of // time to check CTRL_C_RECEIVED and run its own shutdown logic, but after a short amount // of time exit the process. This sleep+exit ensures that even if nobody is checking // CTRL_C_RECEIVED, the compiler exits reasonably promptly. CTRL_C_RECEIVED.store(true, Ordering::Relaxed); std::thread::sleep(Duration::from_millis(100)); std::process::exit(1); </ins> }) .expect("Unable to install ctrlc handler"); }


//! //! The corresponding [`Sync`] version of `OnceCell<T>` is [`OnceLock<T>`]. //! <ins> //! ## `LazyCell<T, F>` //! //! A common pattern with OnceCell is, for a given OnceCell, to use the same function on every //! call to [`OnceCell::get_or_init`] with that cell. This is what is offered by [`LazyCell`], //! which pairs cells of `T` with functions of `F`, and always calls `F` before it yields `&T`. //! This happens implicitly by simply attempting to dereference the LazyCell to get its contents, //! so its use is much more transparent with a place which has been initialized by a constant. //! //! More complicated patterns that don't fit this description can be built on `OnceCell<T>` instead. //! //! `LazyCell` works by providing an implementation of `impl Deref` that calls the function, //! so you can just use it by dereference (e.g. `*lazy_cell` or `lazy_cell.deref()`). //! //! The corresponding [`Sync`] version of `LazyCell<T, F>` is [`LazyLock<T, F>`]. </ins> //! //! # When to choose interior mutability //!


//! [`RwLock<T>`]: ../../std/sync/struct.RwLock.html //! [`Mutex<T>`]: ../../std/sync/struct.Mutex.html //! [`OnceLock<T>`]: ../../std/sync/struct.OnceLock.html <ins> //! [`LazyLock<T, F>`]: ../../std/sync/struct.LazyLock.html </ins> //! [`Sync`]: ../../std/marker/trait.Sync.html //! [`atomic`]: crate::sync::atomic


/// # Examples /// /// Initialize static variables with `LazyLock`. <del> /// </del> /// ``` <del> /// use std::collections::HashMap; /// </del> /// use std::sync::LazyLock; /// <del> /// static HASHMAP: LazyLock<HashMap<i32, String>> = LazyLock::new(|| { ///     println!("initializing"); ///     let mut m = HashMap::new(); ///     m.insert(13, "Spica".to_string()); ///     m.insert(74, "Hoyten".to_string()); ///     m </del> <ins> /// // n.b. static items do not call [`Drop`] on program termination, so this won't be deallocated. /// // this is fine, as the OS can deallocate the terminated program faster than we can free memory /// // but tools like valgrind might report "memory leaks" as it isn't obvious this is intentional. /// static DEEP_THOUGHT: LazyLock<String> = LazyLock::new(|| { /// # mod another_crate { /// #     pub fn great_question() -> String { "42".to_string() } /// # } ///     // M3 Ultra takes about 16 million years in --release config ///     another_crate::great_question() </ins> /// }); /// <del> /// fn main() { ///     println!("ready"); ///     std::thread::spawn(|| { ///         println!("{:?}", HASHMAP.get(&13)); ///     }).join().unwrap(); ///     println!("{:?}", HASHMAP.get(&74)); /// ///     // Prints: ///     //   ready ///     //   initializing ///     //   Some("Spica") ///     //   Some("Hoyten") /// } </del> <ins> /// // The `String` is built, stored in the `LazyLock`, and returned as `&String`. /// let _ = &*DEEP_THOUGHT; /// // The `String` is retrieved from the `LazyLock` and returned as `&String`. /// let _ = &*DEEP_THOUGHT; </ins> /// ``` <ins> /// </ins> /// Initialize fields with `LazyLock`. /// ``` /// use std::sync::LazyLock;


//! - [`Once`]: Used for a thread-safe, one-time global initialization routine //! //! - [`OnceLock`]: Used for thread-safe, one-time initialization of a <del> //!   global variable. </del> <ins> //!   variable, with potentially different initializers based on the caller. //! //! - [`LazyLock`]: Used for thread-safe, one-time initialization of a //!   variable, using one nullary initializer function provided at creation. </ins> //! //! - [`RwLock`]: Provides a mutual exclusion mechanism which allows //!   multiple readers at the same time, while allowing only one


/// A synchronization primitive which can be written to only once. /// /// This type is a thread-safe [`OnceCell`], and can be used in statics. <ins> /// In many simple cases, you can use [`LazyLock<T, F>`] instead to get the benefits of this type /// with less effort: `LazyLock<T, F>` "looks like" `&T` because it initializes with `F` on deref! /// Where OnceLock shines is when LazyLock is too simple to support a given case, as LazyLock /// doesn't allow additional inputs to its function after you call [`LazyLock::new(|| ...)`]. </ins> /// /// [`OnceCell`]: crate::cell::OnceCell <ins> /// [`LazyLock<T, F>`]: crate::sync::LazyLock /// [`LazyLock::new(|| ...)`]: crate::sync::LazyLock::new </ins> /// /// # Examples /// <del> /// Using `OnceLock` to store a function’s previously computed value (a.k.a. /// ‘lazy static’ or ‘memoizing’): /// /// ``` /// use std::sync::OnceLock; /// /// struct DeepThought { ///     answer: String, /// } /// /// impl DeepThought { /// #   fn great_question() -> String { /// #       "42".to_string() /// #   } /// # ///     fn new() -> Self { ///         Self { ///             // M3 Ultra takes about 16 million years in --release config ///             answer: Self::great_question(), ///         } ///     } /// } /// /// fn computation() -> &'static DeepThought { ///     // n.b. static items do not call [`Drop`] on program termination, so if ///     // [`DeepThought`] impls Drop, that will not be used for this instance. ///     static COMPUTATION: OnceLock<DeepThought> = OnceLock::new(); ///     COMPUTATION.get_or_init(|| DeepThought::new()) /// } /// /// // The `DeepThought` is built, stored in the `OnceLock`, and returned. /// let _ = computation().answer; /// // The `DeepThought` is retrieved from the `OnceLock` and returned. /// let _ = computation().answer; /// ``` /// </del> /// Writing to a `OnceLock` from a separate thread: /// /// ```


///     Some(&12345), /// ); /// ``` <ins> /// /// You can use `OnceLock` to implement a type that requires "append-only" logic: /// /// ``` /// use std::sync::{OnceLock, atomic::{AtomicU32, Ordering}}; /// use std::thread; /// /// struct OnceList<T> { ///     data: OnceLock<T>, ///     next: OnceLock<Box<OnceList<T>>>, /// } /// impl<T> OnceList<T> { ///     const fn new() -> OnceList<T> { ///         OnceList { data: OnceLock::new(), next: OnceLock::new() } ///     } ///     fn push(&self, value: T) { ///         // FIXME: this impl is concise, but is also slow for long lists or many threads. ///         // as an exercise, consider how you might improve on it while preserving the behavior ///         if let Err(value) = self.data.set(value) { ///             let next = self.next.get_or_init(|| Box::new(OnceList::new())); ///             next.push(value) ///         }; ///     } ///     fn contains(&self, example: &T) -> bool ///     where ///         T: PartialEq, ///     { ///         self.data.get().map(|item| item == example).filter(|v| *v).unwrap_or_else(|| { ///             self.next.get().map(|next| next.contains(example)).unwrap_or(false) ///         }) ///     } /// } /// /// // Let's exercise this new Sync append-only list by doing a little counting /// static LIST: OnceList<u32> = OnceList::new(); /// static COUNTER: AtomicU32 = AtomicU32::new(0); /// /// let vec = (0..thread::available_parallelism().unwrap().get()).map(|_| thread::spawn(|| { ///     while let i @ 0..=1000 = COUNTER.fetch_add(1, Ordering::Relaxed) { ///         LIST.push(i); ///     } /// })).collect::<Vec<thread::JoinHandle<_>>>(); /// vec.into_iter().for_each(|handle| handle.join().unwrap()); /// /// for i in 0..=1000 { ///     assert!(LIST.contains(&i)); /// } /// /// ``` </ins> #[stable(feature = "once_cell", since = "1.70.0")] pub struct OnceLock<T> { once: Once,


// Get the arguments for the found method, only specifying that `Self` is the receiver type. let Some(possible_rcvr_ty) = typeck_results.node_type_opt(rcvr.hir_id) else { return }; let args = GenericArgs::for_item(tcx, method_def_id, |param, _| { <del> if param.index == 0 { </del> <ins> if let ty::GenericParamDefKind::Lifetime = param.kind { tcx.lifetimes.re_erased.into() } else if param.index == 0 && param.name == kw::SelfUpper { </ins> possible_rcvr_ty.into() } else if param.index == closure_param.index { closure_ty.into()


Obligation::misc(tcx, span, self.mir_def_id(), self.param_env, pred) })); <del> if ocx.select_all_or_error().is_empty() { </del> <ins> if ocx.select_all_or_error().is_empty() && count > 0 { </ins> diag.span_suggestion_verbose( tcx.hir().body(*body).value.peel_blocks().span.shrink_to_lo(), "dereference the return value",


<del> //@ known-bug: rust-lang/rust#124563 use std::marker::PhantomData; pub trait Trait {} pub trait Foo { type Trait: Trait; type Bar: Bar; fn foo(&mut self); } pub struct FooImpl<'a, 'b, A: Trait>(PhantomData<&'a &'b A>); impl<'a, 'b, T> Foo for FooImpl<'a, 'b, T> where T: Trait, { type Trait = T; type Bar = BarImpl<'a, 'b, T>; fn foo(&mut self) { self.enter_scope(|ctx| { BarImpl(ctx); }); } } impl<'a, 'b, T> FooImpl<'a, 'b, T> where T: Trait, { fn enter_scope(&mut self, _scope: impl FnOnce(&mut Self)) {} } pub trait Bar { type Foo: Foo; } pub struct BarImpl<'a, 'b, T: Trait>(&'b mut FooImpl<'a, 'b, T>); impl<'a, 'b, T> Bar for BarImpl<'a, 'b, T> where T: Trait, { type Foo = FooImpl<'a, 'b, T>; } </del>


<ins> // #125634 struct Thing; // Invariant in 'a, Covariant in 'b struct TwoThings<'a, 'b>(*mut &'a (), &'b mut ()); impl Thing { fn enter_scope<'a>(self, _scope: impl for<'b> FnOnce(TwoThings<'a, 'b>)) {} } fn foo() { Thing.enter_scope(|ctx| { SameLifetime(ctx); //~ ERROR lifetime may not live long enough }); } struct SameLifetime<'a>(TwoThings<'a, 'a>); fn main() {} </ins>


<ins> error: lifetime may not live long enough --> $DIR/account-for-lifetimes-in-closure-suggestion.rs:13:22 | LL |     Thing.enter_scope(|ctx| { |                        --- |                        | |                        has type `TwoThings<'_, '1>` |                        has type `TwoThings<'2, '_>` LL |         SameLifetime(ctx); |                      ^^^ this usage requires that `'1` must outlive `'2` | = note: requirement occurs because of the type `TwoThings<'_, '_>`, which makes the generic argument `'_` invariant = note: the struct `TwoThings<'a, 'b>` is invariant over the parameter `'a` = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance error: aborting due to 1 previous error </ins>


<ins> // #124563 use std::marker::PhantomData; pub trait Trait {} pub trait Foo { type Trait: Trait; type Bar: Bar; fn foo(&mut self); } pub struct FooImpl<'a, 'b, A: Trait>(PhantomData<&'a &'b A>); impl<'a, 'b, T> Foo for FooImpl<'a, 'b, T> where T: Trait, { type Trait = T; type Bar = BarImpl<'a, 'b, T>; //~ ERROR lifetime bound not satisfied fn foo(&mut self) { self.enter_scope(|ctx| { //~ ERROR lifetime may not live long enough BarImpl(ctx); //~ ERROR lifetime may not live long enough }); } } impl<'a, 'b, T> FooImpl<'a, 'b, T> where T: Trait, { fn enter_scope(&mut self, _scope: impl FnOnce(&mut Self)) {} } pub trait Bar { type Foo: Foo; } pub struct BarImpl<'a, 'b, T: Trait>(&'b mut FooImpl<'a, 'b, T>); impl<'a, 'b, T> Bar for BarImpl<'a, 'b, T> where T: Trait, { type Foo = FooImpl<'a, 'b, T>; } fn main() {} </ins>


<ins> error[E0478]: lifetime bound not satisfied --> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:19:16 | LL |     type Bar = BarImpl<'a, 'b, T>; |                ^^^^^^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime `'a` as defined here --> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:14:6 | LL | impl<'a, 'b, T> Foo for FooImpl<'a, 'b, T> |      ^^ note: but lifetime parameter must outlive the lifetime `'b` as defined here --> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:14:10 | LL | impl<'a, 'b, T> Foo for FooImpl<'a, 'b, T> |          ^^ error: lifetime may not live long enough --> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:23:21 | LL |         self.enter_scope(|ctx| { |                           --- |                           | |                           has type `&'1 mut FooImpl<'_, '_, T>` |                           has type `&mut FooImpl<'2, '_, T>` LL |             BarImpl(ctx); |                     ^^^ this usage requires that `'1` must outlive `'2` error: lifetime may not live long enough --> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:22:9 | LL |   impl<'a, 'b, T> Foo for FooImpl<'a, 'b, T> |        --  -- lifetime `'b` defined here |        | |        lifetime `'a` defined here ... LL | /         self.enter_scope(|ctx| { LL | |             BarImpl(ctx); LL | |         }); | |__________^ argument requires that `'a` must outlive `'b` | = help: consider adding the following bound: `'a: 'b` = note: requirement occurs because of a mutable reference to `FooImpl<'_, '_, T>` = note: mutable references are invariant over their type parameter = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0478`. </ins>


<ins> // Test a method call where the parameter `B` would (illegally) be // inferred to a region bound in the method argument. If this program // were accepted, then the closure passed to `s.f` could escape its // argument. //@ run-rustfix struct S; impl S { fn f<B, F>(&self, _: F) where F: FnOnce(&i32) -> B { } } fn main() { let s = S; s.f(|p| *p) //~ ERROR lifetime may not live long enough } </ins>


// inferred to a region bound in the method argument. If this program // were accepted, then the closure passed to `s.f` could escape its // argument. <ins> //@ run-rustfix </ins> struct S;


error: lifetime may not live long enough <del> --> $DIR/regions-escape-method.rs:15:13 </del> <ins> --> $DIR/regions-escape-method.rs:16:13 </ins> | LL |     s.f(|p| p) |          -- ^ returning this value requires that `'1` must outlive `'2` |          || |          |return type of closure is &'2 i32 |          has type `&'1 i32` <ins> | help: dereference the return value | LL |     s.f(|p| *p) |             + </ins> error: aborting due to 1 previous error


.bounds = `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type .exception = items in an anonymous const item (`const _: () = {"{"} ... {"}"}`) are treated as in the same scope as the anonymous const's declaration .const_anon = use a const-anon item to suppress this lint <ins> .macro_to_change = the {$macro_kind} `{$macro_to_change}` defines the non-local `impl`, and may need to be changed </ins> lint_non_local_definitions_impl_move_help = move the `impl` block outside of this {$body_kind_descr} {$depth ->


has_trait: bool, self_ty_str: String, of_trait_str: Option<String>, <ins> macro_to_change: Option<(String, &'static str)>, </ins> }, MacroRules { depth: u32,


has_trait, self_ty_str, of_trait_str, <ins> macro_to_change, </ins> } => { diag.primary_message(fluent::lint_non_local_definitions_impl); diag.arg("depth", depth);


diag.arg("of_trait_str", of_trait_str); } <ins> if let Some((macro_to_change, macro_kind)) = macro_to_change { diag.arg("macro_to_change", macro_to_change); diag.arg("macro_kind", macro_kind); diag.note(fluent::lint_macro_to_change); } if let Some(cargo_update) = cargo_update { diag.subdiagnostic(&diag.dcx, cargo_update); } </ins> if has_trait { diag.note(fluent::lint_bounds); diag.note(fluent::lint_with_trait);


); } <del> if let Some(cargo_update) = cargo_update { diag.subdiagnostic(&diag.dcx, cargo_update); } </del> if let Some(const_anon) = const_anon { diag.note(fluent::lint_exception); if let Some(const_anon) = const_anon {


Some((cx.tcx.def_span(parent), may_move)) }; <ins> let macro_to_change = if let ExpnKind::Macro(kind, name) = item.span.ctxt().outer_expn_data().kind { Some((name.to_string(), kind.descr())) } else { None }; </ins> cx.emit_span_lint( NON_LOCAL_DEFINITIONS, ms,


move_to, may_remove, has_trait: impl_.of_trait.is_some(), <ins> macro_to_change, </ins> }, ) }


| `Debug` is not local | move the `impl` block outside of this constant `_IMPL_DEBUG` | <ins> = note: the macro `non_local_macro::non_local_impl` defines the non-local `impl`, and may need to be changed = note: the macro `non_local_macro::non_local_impl` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro` </ins> = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` <del> = note: the macro `non_local_macro::non_local_impl` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro` </del> = note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363> = note: `#[warn(non_local_definitions)]` on by default


LL | m!(); | ---- in this macro invocation | <ins> = note: the macro `m` defines the non-local `impl`, and may need to be changed </ins> = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl` = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>


variant_index: VariantIdx, ) -> InterpResult<'tcx, Option<(ScalarInt, usize)>> { match self.layout_of(ty)?.variants { <del> abi::Variants::Single { index } => { assert_eq!(index, variant_index); Ok(None) } </del> <ins> abi::Variants::Single { .. } => Ok(None), </ins> abi::Variants::Multiple { tag_encoding: TagEncoding::Direct,


assert!(def.is_enum()); let layout = ty_and_layout.layout; <del> if let Variants::Multiple { tag_field, .. } = layout.variants() { // For enums (but not coroutines), the tag field is // currently always the first field of the layout. assert_eq!(*tag_field, 0); } </del> <ins> // Computes the variant of a given index. let layout_of_variant = |index| { let tag = cx.tcx.tag_for_variant((ty_and_layout.ty, index)); let variant_def = Def::Variant(def.variant(index)); let variant_ty_and_layout = ty_and_layout.for_variant(&cx, index); Self::from_variant(variant_def, tag, variant_ty_and_layout, layout.size, cx) }; </ins> <del> let variants = def.discriminants(cx.tcx()).try_fold( Self::uninhabited(), |variants, (idx, ref discriminant)| { let tag = cx.tcx.tag_for_variant((ty_and_layout.ty, idx)); let variant_def = Def::Variant(def.variant(idx)); let variant_ty_and_layout = ty_and_layout.for_variant(&cx, idx); let variant = Self::from_variant( variant_def, tag, variant_ty_and_layout, layout.size, cx, </del> <ins> // We consider three kinds of enums, each demanding a different // treatment of their layout computation: // 1. enums that are uninhabited // 2. enums for which all but one variant is uninhabited // 3. enums with multiple inhabited variants match layout.variants() { _ if layout.abi.is_uninhabited() => { // Uninhabited enums are usually (always?) zero-sized. In // the (unlikely?) event that an uninhabited enum is // non-zero-sized, this assert will trigger an ICE, and this // code should be modified such that a `layout.size` amount // of uninhabited bytes is returned instead. // // Uninhabited enums are currently implemented such that // their layout is described with `Variants::Single`, even // though they don't necessarily have a 'single' variant to // defer to. That said, we don't bother specifically // matching on `Variants::Single` in this arm because the // behavioral principles here remain true even if, for // whatever reason, the compiler describes an uninhabited // enum with `Variants::Multiple`. assert_eq!(layout.size, Size::ZERO); Ok(Self::uninhabited()) } Variants::Single { index } => { // `Variants::Single` on non-uninhabited enums denotes that // the enum delegates its layout to the variant at `index`. layout_of_variant(*index) } Variants::Multiple { tag_field, .. } => { // `Variants::Multiple` denotes an enum with multiple // inhabited variants. The layout of such an enum is the // disjunction of the layouts of its tagged variants. // For enums (but not coroutines), the tag field is // currently always the first field of the layout. assert_eq!(*tag_field, 0); let variants = def.discriminants(cx.tcx()).try_fold( Self::uninhabited(), |variants, (idx, ref discriminant)| { let variant = layout_of_variant(idx)?; Result::<Self, Err>::Ok(variants.or(variant)) }, </ins> )?; <del> Result::<Self, Err>::Ok(variants.or(variant)) }, )?; return Ok(Self::def(Def::Adt(def)).then(variants)); </del> <ins> return Ok(Self::def(Def::Adt(def)).then(variants)); } } </ins> } /// Constructs a `Tree` from a 'variant-like' layout.


<del> //@ known-bug: rust-lang/rust#125811 mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; pub fn is_transmutable<Src, Dst>() where Dst: BikeshedIntrinsicFrom<Src>, { } } #[repr(C)] struct Zst; enum V0 { B(!), } enum V2 { V = 2, } enum Lopsided { Smol(Zst), Lorg(V0), } #[repr(C)] #[repr(C)] struct Dst(Lopsided, V2); fn should_pad_variants() { assert::is_transmutable::<Src, Dst>(); } </del>


<ins> //@ check-pass //! Tests that we do not regress rust-lang/rust#125811 #![feature(transmutability)] fn assert_transmutable<T>() where (): std::mem::BikeshedIntrinsicFrom<T> {} enum Uninhabited {} enum SingleInhabited { X, Y(Uninhabited) } enum SingleUninhabited { X(Uninhabited), Y(Uninhabited), } fn main() { assert_transmutable::<Uninhabited>(); assert_transmutable::<SingleInhabited>(); assert_transmutable::<SingleUninhabited>(); } </ins>


pub(super) fn parse_ty_for_where_clause(&mut self) -> PResult<'a, P<Ty>> { self.parse_ty_common( AllowPlus::Yes, <del> AllowCVariadic::Yes, </del> <ins> AllowCVariadic::No, </ins> RecoverQPath::Yes, RecoverReturnSign::OnlyFatArrow, None,


match allow_c_variadic { AllowCVariadic::Yes => TyKind::CVarArgs, AllowCVariadic::No => { <del> // FIXME(Centril): Should we just allow `...` syntactically </del> <ins> // FIXME(c_variadic): Should we just allow `...` syntactically </ins> // anywhere in a type and use semantic restrictions instead? <ins> // NOTE: This may regress certain MBE calls if done incorrectly. </ins> let guar = self .dcx() .emit_err(NestedCVariadicType { span: lo.to(self.prev_token.span) });


<ins> // A bare `...` represents `CVarArgs` (`VaListImpl<'_>`) in function argument type // position without being a proper type syntactically. // This test ensures that we do not regress certain MBE calls would we ever promote // `...` to a proper type syntactically. //@ check-pass macro_rules! ck { ($ty:ty) => { compile_error!(""); }; (...) => {}; } ck!(...); fn main() {} </ins>


fn f2<'a>(x: u8, y: Vec<&'a ...>) {} //~^ ERROR C-variadic type `...` may not be nested inside another type <ins> // Regression test for issue #125847. fn f3() where for<> ...: {} //~^ ERROR C-variadic type `...` may not be nested inside another type </ins> fn main() { let _recovery_witness: () = 0; //~^ ERROR: mismatched types


LL | fn f2<'a>(x: u8, y: Vec<&'a ...>) {} |                             ^^^ <ins> error[E0743]: C-variadic type `...` may not be nested inside another type --> $DIR/variadic-ffi-nested-syntactic-fail.rs:8:21 | LL | fn f3() where for<> ...: {} |                     ^^^ </ins> error[E0308]: mismatched types <del> --> $DIR/variadic-ffi-nested-syntactic-fail.rs:8:33 </del> <ins> --> $DIR/variadic-ffi-nested-syntactic-fail.rs:12:33 </ins> | LL |     let _recovery_witness: () = 0; |                            --   ^ expected `()`, found integer |                            | |                            expected due to this <del> error: aborting due to 3 previous errors </del> <ins> error: aborting due to 4 previous errors </ins> Some errors have detailed explanations: E0308, E0743. For more information about an error, try `rustc --explain E0308`.


{ write!(f, "n{}", Indent(n + 4))?; } <ins> let last_input_index = self.inputs.values.len().checked_sub(1); </ins> for (i, input) in self.inputs.values.iter().enumerate() { <del> if i > 0 { match line_wrapping_indent { None => write!(f, ", ")?, Some(n) => write!(f, ",n{}", Indent(n + 4))?, }; } </del> if let Some(selfty) = input.to_self() { match selfty { clean::SelfValue => {


write!(f, "{}: ", input.name)?; input.type_.print(cx).fmt(f)?; } <ins> match (line_wrapping_indent, last_input_index) { (_, None) => (), (None, Some(last_i)) if i != last_i => write!(f, ", ")?, (None, Some(_)) => (), (Some(n), Some(last_i)) if i != last_i => write!(f, ",n{}", Indent(n + 4))?, (Some(_), Some(_)) => write!(f, ",n")?, } </ins> } if self.c_variadic { match line_wrapping_indent { None => write!(f, ", ...")?, <del> Some(n) => write!(f, "n{}...", Indent(n + 4))?, </del> <ins> Some(n) => write!(f, "{}...n", Indent(n + 4))?, </ins> }; } match line_wrapping_indent { None => write!(f, ")")?, <del> Some(n) => write!(f, "n{})", Indent(n))?, </del> <ins> Some(n) => write!(f, "{})", Indent(n))?, </ins> }; self.print_output(cx).fmt(f)


impl Foo { // @has async_fn/struct.Foo.html <del> // @has - '//*[@class="method"]' 'pub async fn complicated_lifetimes( &self, context: &impl Bar ) -> impl Iterator<Item = &usize>' </del> <ins> // @has - '//*[@class="method"]' 'pub async fn complicated_lifetimes( &self, context: &impl Bar, ) -> impl Iterator<Item = &usize>' </ins> pub async fn complicated_lifetimes(&self, context: &impl Bar) -> impl Iterator<Item = &usize> { [0].iter() }


pub fn create( ) -> Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000
   No newline at end of file
pub fn create() -> Padding00000000000000000000000000000000000000000000000000000000000000000000000000000000
   No newline at end of file


fn poll_write( self, cx: &mut Option<String>,  buf: &mut [usize]   buf: &mut [usize],  ) -> Option<Result<usize, Error>>;     fn poll_flush(self, cx: &mut Option<String>) -> Option<Result<(), Error>>;     fn poll_close(self, cx: &mut Option<String>) -> Option<Result<(), Error>>;


fn poll_write_vectored( self, cx: &mut Option<String>,  bufs: &[usize]   bufs: &[usize],  ) -> Option<Result<usize, Error>> { ... } }  No newline at end of file


// @has impl_trait/fn.func2.html // @has - '//pre[@class="rust item-decl"]' "func2<T>(" // @has - '//pre[@class="rust item-decl"]' "_x: impl Deref<Target = Option<T>> + Iterator<Item = T>," <del> // @has - '//pre[@class="rust item-decl"]' "_y: impl Iterator<Item = u8> )" </del> <ins> // @has - '//pre[@class="rust item-decl"]' "_y: impl Iterator<Item = u8>, )" </ins> // @!has - '//pre[@class="rust item-decl"]' 'where' pub use impl_trait_aux::func2;


// @matches foo/fn.function_with_a_really_long_name.html '//*[@class="rust item-decl"]//code' " //     function_with_a_really_long_name(n //        parameter_one: i32,n <del> //        parameter_two: i32n </del> <ins> //        parameter_two: i32,n </ins> //    ) -> Option<i32>$" pub fn function_with_a_really_long_name(parameter_one: i32, parameter_two: i32) -> Option<i32> { Some(parameter_one + parameter_two)


pub use reexports::foo; // @has 'foo/outer/inner/fn.foo_crate.html' '//pre[@class="rust item-decl"]' 'pub(crate) fn foo_crate()' pub(crate) use reexports::foo_crate; <del> // @has 'foo/outer/inner/fn.foo_super.html' '//pre[@class="rust item-decl"]' 'pub(in outer) fn foo_super( )' </del> <ins> // @has 'foo/outer/inner/fn.foo_super.html' '//pre[@class="rust item-decl"]' 'pub(in outer) fn foo_super()' </ins> pub(super) use::reexports::foo_super; // @!has 'foo/outer/inner/fn.foo_self.html' pub(self) use reexports::foo_self;


use rustc_span::symbol::{kw, Symbol}; use rustc_span::Span; <ins> #[instrument(level = "debug", skip(tcx))] </ins> pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { use rustc_hir::*;


// FIXME(#43408) always enable this once `lazy_normalization` is // stable enough and does not need a feature gate anymore. Node::AnonConst(_) => { <del> let parent_def_id = tcx.hir().get_parent_item(hir_id); </del> <ins> let parent_did = tcx.parent(def_id.to_def_id()); // We don't do this unconditionally because the `DefId` parent of an anon const // might be an implicitly created closure during `async fn` desugaring. This would // have the wrong generics. // // i.e. `async fn foo<'a>() { let a = [(); { 1 + 2 }]; bar().await() }` // would implicitly have a closure in its body that would be the parent of // the `{ 1 + 2 }` anon const. This closure's generics is simply a witness // instead of `['a]`. let parent_did = if let DefKind::AnonConst = tcx.def_kind(parent_did) { parent_did } else { tcx.hir().get_parent_item(hir_id).to_def_id() }; debug!(?parent_did); </ins> let mut in_param_ty = false; for (_parent, node) in tcx.hir().parent_iter(hir_id) {


// // This has some implications for how we get the predicates available to the anon const // see `explicit_predicates_of` for more information on this <del> let generics = tcx.generics_of(parent_def_id.to_def_id()); </del> <ins> let generics = tcx.generics_of(parent_did); </ins> let param_def_idx = generics.param_def_id_to_index[&param_id.to_def_id()]; // In the above example this would be .params[..N#0] let own_params = generics.params_to(param_def_idx as usize, tcx).to_owned();


// // Note that we do not supply the parent generics when using // `min_const_generics`. <del> Some(parent_def_id.to_def_id()) </del> <ins> Some(parent_did) </ins> } } else { let parent_node = tcx.parent_hir_node(hir_id);


Node::Expr(Expr { kind: ExprKind::Repeat(_, constant), .. }) if constant.hir_id() == hir_id => { <del> Some(parent_def_id.to_def_id()) </del> <ins> Some(parent_did) </ins> } // Exclude `GlobalAsm` here which cannot have generics. Node::Expr(&Expr { kind: ExprKind::InlineAsm(asm), .. })


_ => false, }) => { <del> Some(parent_def_id.to_def_id()) </del> <ins> Some(parent_did) </ins> } _ => None, }


<ins> // Given an anon const `a`: `{ N }` and some anon const `b` which references the // first anon const: `{ [1; a] }`. `b` should not have any generics as it is not // a simple `N` argument nor is it a repeat expr count. // // On the other hand `b` *is* a repeat expr count and so it should inherit its // parents generics as part of the `const_evaluatable_unchecked` fcw (#76200). // // In this specific case however `b`'s parent should be `a` and so it should wind // up not having any generics after all. If `a` were to inherit its generics from // the enclosing item then the reference to `a` from `b` would contain generic // parameters not usable by `b` which would cause us to ICE. fn bar<const N: usize>() {} fn foo<const N: usize>() { bar::<{ [1; N] }>(); //~^ ERROR: generic parameters may not be used in const operations } fn main() {} </ins>


<ins> error: generic parameters may not be used in const operations --> $DIR/repeat_expr_hack_gives_right_generics.rs:16:17 | LL |     bar::<{ [1; N] }>(); |                 ^ cannot perform const operation using `N` | = help: const parameters may only be used as standalone arguments, i.e. `N` = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to 1 previous error </ins>


}; use rustc_session::config::{self, DebugInfo, Lto}; use rustc_span::symbol::Symbol; <del> use rustc_span::FileName; </del> <ins> use rustc_span::{hygiene, FileName, DUMMY_SP}; </ins> use rustc_span::{FileNameDisplayPreference, SourceFile}; use rustc_symbol_mangling::typeid_for_trait_ref; use rustc_target::abi::{Align, Size};


// We may want to remove the namespace scope if we're in an extern block (see // https://github.com/rust-lang/rust/pull/46457#issuecomment-351750952). let var_scope = get_namespace_for_item(cx, def_id); <del> let span = tcx.def_span(def_id); </del> <ins> let span = hygiene::walk_chain_collapsed(tcx.def_span(def_id), DUMMY_SP); </ins> let (file_metadata, line_number) = if !span.is_dummy() { let loc = cx.lookup_debug_loc(span.lo());


<ins> //@ ignore-lldb // Test that static debug info is not collapsed with #[collapse_debuginfo(external)] //@ compile-flags:-g // === GDB TESTS =================================================================================== // gdb-command:info line collapse_debuginfo_static_external::FOO // gdb-check:[...]Line 15[...] #[collapse_debuginfo(external)] macro_rules! decl_foo { () => { static FOO: u32 = 0; }; } decl_foo!(); fn main() { // prevent FOO from getting optimized out std::hint::black_box(&FOO); } </ins>


<ins> //@ ignore-lldb // Test that static debug info is collapsed with #[collapse_debuginfo(yes)] //@ compile-flags:-g // === GDB TESTS =================================================================================== // gdb-command:info line collapse_debuginfo_static::FOO // gdb-check:[...]Line 19[...] #[collapse_debuginfo(yes)] macro_rules! decl_foo { () => { static FOO: u32 = 0; }; } decl_foo!(); fn main() { // prevent FOO from getting optimized out std::hint::black_box(&FOO); } </ins>


} // Resolve any lifetime variables that may have been introduced during normalization. let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else { <del> // This code path is not reached in any tests, but may be reachable. If // this is triggered, it should be converted to `delayed_bug` and the // triggering case turned into a test. tcx.dcx().bug("encountered errors when checking RPITIT refinement (resolution)"); </del> <ins> // If resolution didn't fully complete, we cannot continue checking RPITIT refinement, and // delay a bug as the original code contains load-bearing errors. tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (resolution)"); return; </ins> }; // For quicker lookup, use an `IndexSet` (we don't use one earlier because


<ins> // This is a non-regression test for issue #126670 where RPITIT refinement checking encountered // errors during resolution and ICEd. //@ edition: 2018 pub trait Mirror { type Assoc; } impl<T: ?Sized> Mirror for () { //~^ ERROR the type parameter `T` is not constrained type Assoc = T; } pub trait First { async fn first() -> <() as Mirror>::Assoc; //~^ ERROR type annotations needed } impl First for () { async fn first() {} } fn main() {} </ins>


<ins> error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates --> $DIR/refine-resolution-errors.rs:9:6 | LL | impl<T: ?Sized> Mirror for () { |      ^ unconstrained type parameter error[E0282]: type annotations needed --> $DIR/refine-resolution-errors.rs:15:5 | LL |     async fn first() -> <() as Mirror>::Assoc; |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type error: aborting due to 2 previous errors Some errors have detailed explanations: E0207, E0282. For more information about an error, try `rustc --explain E0207`. </ins>


#[inline] pub(crate) fn extend_from_slice(&mut self, other: &[u8]) { self.bytes.extend_from_slice(other); <del> self.is_known_utf8 = self.is_known_utf8 || self.next_surrogate(0).is_none(); </del> <ins> self.is_known_utf8 = false; </ins> } }


string.push(CodePoint::from_u32(0xD800).unwrap()); check_utf8_boundary(&string, 3); } <ins> #[test] fn wobbled_wtf8_plus_bytes_isnt_utf8() { let mut string: Wtf8Buf = unsafe { Wtf8::from_bytes_unchecked(b"xEDxA0x80").to_owned() }; assert!(!string.is_known_utf8); string.extend_from_slice(b"some utf-8"); assert!(!string.is_known_utf8); } #[test] fn wobbled_wtf8_plus_str_isnt_utf8() { let mut string: Wtf8Buf = unsafe { Wtf8::from_bytes_unchecked(b"xEDxA0x80").to_owned() }; assert!(!string.is_known_utf8); string.push_str("some utf-8"); assert!(!string.is_known_utf8); } #[test] fn unwobbly_wtf8_plus_utf8_is_utf8() { let mut string: Wtf8Buf = Wtf8Buf::from_str("hello world"); assert!(string.is_known_utf8); string.push_str("some utf-8"); assert!(string.is_known_utf8); } </ins>


for print in &sess.opts.prints { if print.kind == PrintKind::LinkArgs { <del> let content = format!("{cmd:?}"); </del> <ins> let content = format!("{cmd:?}n"); </ins> print.out.overwrite(&content, sess); } }


.run_unchecked(); out.assert_stdout_contains("lfoo"); out.assert_stdout_contains("lbar"); <ins> assert!(out.stdout_utf8().ends_with('n')); </ins> }


false } } <ins> } else if tcx.trait_is_auto(trait_ref.def_id) { tcx.dcx().span_delayed_bug( tcx.def_span(obligation.predicate.def_id), "associated types not allowed on auto traits", ); false </ins> } else { bug!("unexpected builtin trait with associated type: {trait_ref:?}") }


<del> //@ known-bug: #117829 #![feature(auto_traits)] trait B {} auto trait Z<T> where T: Z<u16>, <T as Z<u16>>::W: B, { type W; } fn main() {} </del>


<del> //@ known-bug: #117829 auto trait Z<'a, T: ?Sized> where T: Z<'a, u16>, for<'b> <T as Z<'b, u16>>::W: Clone, { type W: ?Sized; } </del>


<ins> error[E0380]: auto traits cannot have associated items --> $DIR/assoc-ty.rs:10:10 | LL | auto trait Trait { |            ----- auto traits cannot have associated items LL | LL |     type Output; |     -----^^^^^^- help: remove these associated items error[E0658]: auto traits are experimental and possibly buggy --> $DIR/assoc-ty.rs:8:1 | LL | / auto trait Trait { LL | | LL | |     type Output; LL | | LL | | } | |_^ | = note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information = help: add `#![feature(auto_traits)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0308]: mismatched types --> $DIR/assoc-ty.rs:15:36 | LL |     let _: <() as Trait>::Output = (); |            ---------------------   ^^ expected associated type, found `()` |            | |            expected due to this | = note: expected associated type `<() as Trait>::Output` found unit type `()` = help: consider constraining the associated type `<() as Trait>::Output` to `()` or calling a method that returns `<() as Trait>::Output` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to 3 previous errors Some errors have detailed explanations: E0308, E0380, E0658. For more information about an error, try `rustc --explain E0308`. </ins>


<ins> error[E0380]: auto traits cannot have associated items --> $DIR/assoc-ty.rs:10:10 | LL | auto trait Trait { |            ----- auto traits cannot have associated items LL | LL |     type Output; |     -----^^^^^^- help: remove these associated items error[E0658]: auto traits are experimental and possibly buggy --> $DIR/assoc-ty.rs:8:1 | LL | / auto trait Trait { LL | | LL | |     type Output; LL | | LL | | } | |_^ | = note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information = help: add `#![feature(auto_traits)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0308]: mismatched types --> $DIR/assoc-ty.rs:15:36 | LL |     let _: <() as Trait>::Output = (); |            ---------------------   ^^ types differ |            | |            expected due to this | = note: expected associated type `<() as Trait>::Output` found unit type `()` = help: consider constraining the associated type `<() as Trait>::Output` to `()` or calling a method that returns `<() as Trait>::Output` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html error: aborting due to 3 previous errors Some errors have detailed explanations: E0308, E0380, E0658. For more information about an error, try `rustc --explain E0308`. </ins>


<ins> //@ revisions: current next //@[next] compile-flags: -Znext-solver //@ ignore-compare-mode-next-solver (explicit revisions) // Tests that projection doesn't explode if we accidentally // put an associated type on an auto trait. auto trait Trait { //~^ ERROR auto traits are experimental and possibly buggy type Output; //~^ ERROR auto traits cannot have associated items } fn main() { let _: <() as Trait>::Output = (); //~^ ERROR mismatched types } </ins>


} #[inline(always)] <del> pub fn local_def_path_hash_to_def_id( &self, hash: DefPathHash, err_msg: &dyn std::fmt::Debug, ) -> LocalDefId { </del> <ins> /// Returns `None` if the `DefPathHash` does not correspond to a `LocalDefId` /// in the current compilation session. This can legitimately happen if the /// `DefPathHash` is from a `DefId` in an upstream crate or, during incr. comp., /// if the `DefPathHash` is from a previous compilation session and /// the def-path does not exist anymore. pub fn local_def_path_hash_to_def_id(&self, hash: DefPathHash) -> Option<LocalDefId> { </ins> debug_assert!(hash.stable_crate_id() == self.table.stable_crate_id); <del> #[cold] #[inline(never)] fn err(err_msg: &dyn std::fmt::Debug) -> ! { panic!("{err_msg:?}") } </del> self.table .def_path_hash_to_index .get(&hash.local_hash()) .map(|local_def_index| LocalDefId { local_def_index }) <del> .unwrap_or_else(|| err(err_msg)) </del> } pub fn def_path_hash_to_def_index_map(&self) -> &DefPathHashMap {


/// has been removed. fn extract_def_id(&self, tcx: TyCtxt<'_>) -> Option<DefId> { if tcx.fingerprint_style(self.kind) == FingerprintStyle::DefPathHash { <del> Some(tcx.def_path_hash_to_def_id( DefPathHash(self.hash.into()), &("Failed to extract DefId", self.kind, self.hash), )) </del> <ins> tcx.def_path_hash_to_def_id(DefPathHash(self.hash.into())) </ins> } else { None }


if tcx.fingerprint_style(dep_node.kind) == FingerprintStyle::HirId { let (local_hash, local_id) = Fingerprint::from(dep_node.hash).split(); let def_path_hash = DefPathHash::new(tcx.stable_crate_id(LOCAL_CRATE), local_hash); <del> let def_id = tcx .def_path_hash_to_def_id( def_path_hash, &("Failed to extract HirId", dep_node.kind, dep_node.hash), ) .expect_local(); </del> <ins> let def_id = tcx.def_path_hash_to_def_id(def_path_hash)?.expect_local(); </ins> let local_id = local_id .as_u64() .try_into()


// If we get to this point, then all of the query inputs were green, // which means that the definition with this hash is guaranteed to // still exist in the current compilation session. <del> self.tcx.def_path_hash_to_def_id( def_path_hash, &("Failed to convert DefPathHash", def_path_hash), ) </del> <ins> match self.tcx.def_path_hash_to_def_id(def_path_hash) { Some(r) => r, None => panic!("Failed to convert DefPathHash {def_path_hash:?}"), } </ins> } fn decode_attr_id(&mut self) -> rustc_span::AttrId {


/// Converts a `DefPathHash` to its corresponding `DefId` in the current compilation /// session, if it still exists. This is used during incremental compilation to /// turn a deserialized `DefPathHash` into its current `DefId`. <del> pub fn def_path_hash_to_def_id( self, hash: DefPathHash, err_msg: &dyn std::fmt::Debug, ) -> DefId { </del> <ins> pub fn def_path_hash_to_def_id(self, hash: DefPathHash) -> Option<DefId> { </ins> debug!("def_path_hash_to_def_id({:?})", hash); let stable_crate_id = hash.stable_crate_id();


// If this is a DefPathHash from the local crate, we can look up the // DefId in the tcx's `Definitions`. if stable_crate_id == self.stable_crate_id(LOCAL_CRATE) { <del> self.untracked .definitions .read() .local_def_path_hash_to_def_id(hash, err_msg) .to_def_id() </del> <ins> Some(self.untracked.definitions.read().local_def_path_hash_to_def_id(hash)?.to_def_id()) </ins> } else { <del> self.def_path_hash_to_def_id_extern(hash, stable_crate_id) </del> <ins> Some(self.def_path_hash_to_def_id_extern(hash, stable_crate_id)) </ins> } }


} /// Try to force a dep node to execute and see if it's green. <ins> /// /// Returns true if the query has actually been forced. It is valid that a query /// fails to be forced, e.g. when the query key cannot be reconstructed from the /// dep-node or when the query kind outright does not support it. </ins> #[inline] #[instrument(skip(self, frame), level = "debug")] fn try_force_from_dep_node(self, dep_node: DepNode, frame: Option<&MarkFrame<'_>>) -> bool { let cb = self.dep_kind_info(dep_node.kind); if let Some(f) = cb.force_from_dep_node { <del> if let Err(value) = panic::catch_unwind(panic::AssertUnwindSafe(|| { f(self, dep_node); })) { if !value.is::<rustc_errors::FatalErrorMarker>() { print_markframe_trace(self.dep_graph(), frame); </del> <ins> match panic::catch_unwind(panic::AssertUnwindSafe(|| f(self, dep_node))) { Err(value) => { if !value.is::<rustc_errors::FatalErrorMarker>() { print_markframe_trace(self.dep_graph(), frame); } panic::resume_unwind(value) </ins> } <del> panic::resume_unwind(value) </del> <ins> Ok(query_has_been_forced) => query_has_been_forced, </ins> } <del> true </del> } else { false }


<ins> // If it is impossible to find query arguments just from the hash // compiler should treat the node as red // In this test prior to fixing compiler was having problems figuring out // drop impl for T inside of m //@ revisions:cfail1 cfail2 //@ compile-flags: --crate-type=lib //@ build-pass pub trait P { type A; } struct S; impl P for S { type A = C; } struct T<D: P>(D::A, Z<D>); struct Z<D: P>(D::A, String); impl<D: P> T<D> { pub fn i() -> Self { loop {} } } enum C { #[cfg(cfail1)] Up(()), #[cfg(cfail2)] Lorry(()), } pub fn m() { T::<S>::i(); } </ins>


#[diag(parse_use_eq_instead)] pub(crate) struct UseEqInstead { #[primary_span] <ins> #[suggestion(style = "verbose", applicability = "machine-applicable", code = "=")] </ins> pub span: Span, <del> #[suggestion(style = "verbose", applicability = "machine-applicable", code = "")] pub suggestion: Span, </del> } #[derive(Diagnostic)]


&& expected.iter().any(|tok| matches!(tok, TokenType::Token(TokenKind::Eq))) { // Likely typo: `=` → `==` in let expr or enum item <del> return Err(self.dcx().create_err(UseEqInstead { span: self.token.span, suggestion: self.token.span.with_lo(self.token.span.lo() + BytePos(1)), })); </del> <ins> return Err(self.dcx().create_err(UseEqInstead { span: self.token.span })); </ins> } if self.token.is_keyword(kw::Move) && self.prev_token.is_keyword(kw::Async) {


= help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` help: try using `=` instead | <del> LL -     B == 2 LL +     B = 2 | </del> <ins> LL |     B = 2 |       ~ </ins> error: expected item, found `==` --> $DIR/issue-101477-enum.rs:6:7


| help: try using `=` instead | <del> LL -     let x == 2; LL +     let x = 2; | </del> <ins> LL |     let x = 2; |           ~ </ins> error: aborting due to 1 previous error


<ins> const A: usize ⩵ 2; //~^ ERROR unknown start of token: u{2a75} //~| ERROR unexpected `==` </ins>


<ins> error: unknown start of token: u{2a75} --> $DIR/unicode-double-equals-recovery.rs:1:16 | LL | const A: usize ⩵ 2; |                ^ | help: Unicode character '⩵' (Two Consecutive Equals Signs) looks like '==' (Double Equals Sign), but it is not | LL | const A: usize == 2; |                ~~ error: unexpected `==` --> $DIR/unicode-double-equals-recovery.rs:1:16 | LL | const A: usize ⩵ 2; |                ^ | help: try using `=` instead | LL | const A: usize = 2; |                ~ error: aborting due to 2 previous errors </ins>


.label = declared `#[non_exhaustive]` here .help = consider a manual implementation of `Default` <ins> builtin_macros_non_generic_pointee = the `#[pointee]` attribute may only be used on generic parameters </ins> builtin_macros_non_unit_default = the `#[default]` attribute may only be used on unit enum variants .help = consider a manual implementation of `Default`


use rustc_span::{Span, Symbol}; use thin_vec::{ThinVec, thin_vec}; <ins> use crate::errors; </ins> macro_rules! path { ($span:expr, $($part:ident)::*) => { vec![$(Ident::new(sym::$part, $span),)*] } }


push: &mut dyn FnMut(Annotatable), _is_const: bool, ) { <ins> item.visit_with(&mut DetectNonGenericPointeeAttr { cx }); </ins> let (name_ident, generics) = if let Annotatable::Item(aitem) = item && let ItemKind::Struct(struct_data, g) = &aitem.kind {


} } } <ins> struct DetectNonGenericPointeeAttr<'a, 'b> { cx: &'a ExtCtxt<'b>, } impl<'a, 'b> rustc_ast::visit::Visitor<'a> for DetectNonGenericPointeeAttr<'a, 'b> { fn visit_attribute(&mut self, attr: &'a rustc_ast::Attribute) -> Self::Result { if attr.has_name(sym::pointee) { self.cx.dcx().emit_err(errors::NonGenericPointee { span: attr.span }); } } fn visit_generic_param(&mut self, param: &'a rustc_ast::GenericParam) -> Self::Result { let mut error_on_pointee = AlwaysErrorOnGenericParam { cx: self.cx }; match &param.kind { GenericParamKind::Type { default } => { // The `default` may end up containing a block expression. // The problem is block expressions  may define structs with generics. // A user may attach a #[pointee] attribute to one of these generics // We want to catch that. The simple solution is to just // always raise a `NonGenericPointee` error when this happens. // // This solution does reject valid rust programs but, // such a code would have to, in order: // - Define a smart pointer struct. // - Somewhere in this struct definition use a type with a const generic argument. // - Calculate this const generic in a expression block. // - Define a new smart pointer type in this block. // - Have this smart pointer type have more than 1 generic type. // In this case, the inner smart pointer derive would be complaining that it // needs a pointer attribute. Meanwhile, the outer macro would be complaining // that we attached a #[pointee] to a generic type argument while helpfully // informing the user that #[pointee] can only be attached to generic pointer arguments rustc_ast::visit::visit_opt!(error_on_pointee, visit_ty, default); } GenericParamKind::Const { .. } | GenericParamKind::Lifetime => { rustc_ast::visit::walk_generic_param(&mut error_on_pointee, param); } } } fn visit_ty(&mut self, t: &'a rustc_ast::Ty) -> Self::Result { let mut error_on_pointee = AlwaysErrorOnGenericParam { cx: self.cx }; error_on_pointee.visit_ty(t) } } struct AlwaysErrorOnGenericParam<'a, 'b> { cx: &'a ExtCtxt<'b>, } impl<'a, 'b> rustc_ast::visit::Visitor<'a> for AlwaysErrorOnGenericParam<'a, 'b> { fn visit_attribute(&mut self, attr: &'a rustc_ast::Attribute) -> Self::Result { if attr.has_name(sym::pointee) { self.cx.dcx().emit_err(errors::NonGenericPointee { span: attr.span }); } } } </ins>


#[label] pub testing_span: Span, } <ins> #[derive(Diagnostic)] #[diag(builtin_macros_non_generic_pointee)] pub(crate) struct NonGenericPointee { #[primary_span] pub span: Span, } </ins>


ptr: &'a T, } <ins> #[derive(SmartPointer)] #[repr(transparent)] struct PointeeOnField<'a, #[pointee] T: ?Sized> { #[pointee] //~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters ptr: &'a T } #[derive(SmartPointer)] #[repr(transparent)] struct PointeeInTypeConstBlock<'a, T: ?Sized = [u32; const { struct UhOh<#[pointee] T>(T); 10 }]> { //~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters ptr: &'a T, } #[derive(SmartPointer)] #[repr(transparent)] struct PointeeInConstConstBlock< 'a, T: ?Sized, const V: u32 = { struct UhOh<#[pointee] T>(T); 10 }> //~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters { ptr: &'a T, } #[derive(SmartPointer)] #[repr(transparent)] struct PointeeInAnotherTypeConstBlock<'a, #[pointee] T: ?Sized> { ptr: PointeeInConstConstBlock<'a, T, { struct UhOh<#[pointee] T>(T); 0 }> //~^ ERROR: the `#[pointee]` attribute may only be used on generic parameters } </ins> // However, reordering attributes should work nevertheless. #[repr(transparent)] #[derive(SmartPointer)]


LL | struct NoMaybeSized<'a, #[pointee] T> { |                                    ^ <ins> error: the `#[pointee]` attribute may only be used on generic parameters --> $DIR/deriving-smart-pointer-neg.rs:59:5 | LL |     #[pointee] |     ^^^^^^^^^^ error: the `#[pointee]` attribute may only be used on generic parameters --> $DIR/deriving-smart-pointer-neg.rs:66:74 | LL | struct PointeeInTypeConstBlock<'a, T: ?Sized = [u32; const { struct UhOh<#[pointee] T>(T); 10 }]> { |                                                                          ^^^^^^^^^^ error: the `#[pointee]` attribute may only be used on generic parameters --> $DIR/deriving-smart-pointer-neg.rs:76:34 | LL |     const V: u32 = { struct UhOh<#[pointee] T>(T); 10 }> |                                  ^^^^^^^^^^ error: the `#[pointee]` attribute may only be used on generic parameters --> $DIR/deriving-smart-pointer-neg.rs:85:56 | LL |     ptr: PointeeInConstConstBlock<'a, T, { struct UhOh<#[pointee] T>(T); 0 }> |                                                        ^^^^^^^^^^ </ins> error[E0392]: lifetime parameter `'a` is never used --> $DIR/deriving-smart-pointer-neg.rs:15:16 |


| = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` <del> error: aborting due to 12 previous errors </del> <ins> error: aborting due to 16 previous errors </ins> For more information about this error, try `rustc --explain E0392`.


for debug_info in body.var_debug_info.iter_mut() { if let VarDebugInfoContents::Place(place) = &mut debug_info.value { let mut new_projections: Option<Vec<_>> = None; <del> let mut last_deref = 0; for (i, (base, elem)) in place.iter_projections().enumerate() { </del> <ins> for (base, elem) in place.iter_projections() { </ins> let base_ty = base.ty(&body.local_decls, tcx).ty; if elem == PlaceElem::Deref && base_ty.is_box() { <del> let new_projections = new_projections.get_or_insert_default(); </del> <ins> // Clone the projections before us, since now we need to mutate them. let new_projections = new_projections.get_or_insert_with(|| base.projection.to_vec()); </ins> let (unique_ty, nonnull_ty, ptr_ty) = build_ptr_tys(tcx, base_ty.boxed_ty(), unique_did, nonnull_did); <del> new_projections.extend_from_slice(&base.projection[last_deref..]); </del> new_projections.extend_from_slice(&build_projection( unique_ty, nonnull_ty, ptr_ty, )); new_projections.push(PlaceElem::Deref); <del> last_deref = i; </del> <ins> } else if let Some(new_projections) = new_projections.as_mut() { // Keep building up our projections list once we've started it. new_projections.push(elem); </ins> } } <del> if let Some(mut new_projections) = new_projections { new_projections.extend_from_slice(&place.projection[last_deref..]); </del> <ins> // Store the mutated projections if we actually changed something. if let Some(new_projections) = new_projections { </ins> place.projection = tcx.mk_place_elems(&new_projections); } }


<ins> - // MIR for `pointee` before ElaborateBoxDerefs + // MIR for `pointee` after ElaborateBoxDerefs fn pointee(_1: Box<i32>) -> () { -     debug foo => (*_1); +     debug foo => (*(((_1.0: std::ptr::Unique<i32>).0: std::ptr::NonNull<i32>).0: *const i32)); let mut _0: (); bb0: { return; } } </ins>


<ins> // skip-filecheck //@ test-mir-pass: ElaborateBoxDerefs #![feature(custom_mir, core_intrinsics)] extern crate core; use core::intrinsics::mir::*; // EMIT_MIR elaborate_box_deref_in_debuginfo.pointee.ElaborateBoxDerefs.diff #[custom_mir(dialect = "built")] fn pointee(opt: Box<i32>) { mir!( debug foo => *opt; { Return() } ) } fn main() {} </ins>


<ins> //@ aux-build:block-on.rs //@ edition:2021 //@ run-pass #![feature(async_closure)] extern crate block_on; pub trait Trait { fn callback(&mut self); } impl Trait for (i32,) { fn callback(&mut self) { println!("hi {}", self.0); self.0 += 1; } } async fn call_once(f: impl async FnOnce()) { f().await; } async fn run(mut loader: Box<dyn Trait>) { let f = async move || { loader.callback(); loader.callback(); }; call_once(f).await; } fn main() { block_on::block_on(async { run(Box::new((42,))).await; }); } </ins>


<del> Subproject commit 57ae1a3474057fead2c438928ed368b3740bf0ec </del> <ins> Subproject commit ccf4c38bdd73f1a37ec266c73bdaef80e39f8cf6 </ins>


/// /// # Panics /// <del> /// This function will panic if `rhs` is 0 or if `self` is -1 and `rhs` is /// `Self::MIN`. This behavior is not affected by the `overflow-checks` flag. </del> <ins> /// This function will panic if `rhs` is 0 or if `self` is `Self::MIN` and /// `rhs` is -1. This behavior is not affected by the `overflow-checks` flag. </ins> /// /// # Examples ///


/// assert_eq!(a.rem_euclid(-b), 3); /// assert_eq!((-a).rem_euclid(-b), 1); /// ``` <ins> /// /// This will panic: /// ```should_panic #[doc = concat!("let _ = ", stringify!($SelfT), "::MIN.rem_euclid(-1);")] /// ``` </ins> #[doc(alias = "modulo", alias = "mod")] #[stable(feature = "euclidean_division", since = "1.38.0")] #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.52.0")]


/// /// # Panics /// <del> /// This function will panic if `rhs` is 0 or if `self` is -1 and `rhs` is /// `Self::MIN`. This behavior is not affected by the `overflow-checks` flag. </del> <ins> /// This function will panic if `rhs` is 0 or if `self` is `Self::MIN` /// and `rhs` is -1. This behavior is not affected by the `overflow-checks` flag. </ins> /// /// # Examples ///


use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt, TypeVisitableExt}; use rustc_target::abi::{FieldIdx, VariantIdx}; <ins> use crate::pass_manager::validate_body; </ins> pub struct ByMoveBody; impl<'tcx> MirPass<'tcx> for ByMoveBody {


|(parent_field_idx, parent_capture), (child_field_idx, child_capture)| { // Store this set of additional projections (fields and derefs). // We need to re-apply them later. <del> let child_precise_captures = &child_capture.place.projections[parent_capture.place.projections.len()..]; </del> <ins> let mut child_precise_captures = child_capture.place.projections [parent_capture.place.projections.len()..] .to_vec(); </ins> <del> // If the parent captures by-move, and the child captures by-ref, then we // need to peel an additional `deref` off of the body of the child. let needs_deref = child_capture.is_by_ref() && !parent_capture.is_by_ref(); if needs_deref { assert_ne!( coroutine_kind, ty::ClosureKind::FnOnce, </del> <ins> // If the parent capture is by-ref, then we need to apply an additional // deref before applying any further projections to this place. if parent_capture.is_by_ref() { child_precise_captures.insert( 0, Projection { ty: parent_capture.place.ty(), kind: ProjectionKind::Deref }, ); } // If the child capture is by-ref, then we need to apply a "ref" // projection (i.e. `&`) at the end. But wait! We don't have that // as a projection kind. So instead, we can apply its dual and // *peel* a deref off of the place when it shows up in the MIR body. // Luckily, by construction this is always possible. let peel_deref = if child_capture.is_by_ref() { assert!( parent_capture.is_by_ref() || coroutine_kind != ty::ClosureKind::FnOnce, </ins> "`FnOnce` coroutine-closures return coroutines that capture from  their body; it will always result in a borrowck error!" ); <del> } </del> <ins> true } else { false }; // Regarding the behavior above, you may think that it's redundant to both // insert a deref and then peel a deref if the parent and child are both // captured by-ref. This would be correct, except for the case where we have // precise capturing projections, since the inserted deref is to the *beginning* // and the peeled deref is at the *end*. I cannot seem to actually find a // case where this happens, though, but let's keep this code flexible. </ins> // Finally, store the type of the parent's captured place. We need // this when building the field projection in the MIR body later on.


( FieldIdx::from_usize(parent_field_idx + num_args), parent_capture_ty, <del> needs_deref, </del> <ins> peel_deref, </ins> child_precise_captures, ), )


let mut by_move_body = body.clone(); MakeByMoveBody { tcx, field_remapping, by_move_coroutine_ty }.visit_body(&mut by_move_body); dump_mir(tcx, false, "coroutine_by_move", &0, &by_move_body, |_, _| Ok(())); <ins> // Let's just always validate this body. validate_body(tcx, &mut by_move_body, "Initial coroutine_by_move body".to_string()); </ins> // FIXME: use query feeding to generate the body right here and then only store the `DefId` of the new body. by_move_body.source = mir::MirSource::from_instance(InstanceKind::CoroutineKindShim { coroutine_def_id: coroutine_def_id.to_def_id(),


struct MakeByMoveBody<'tcx> { tcx: TyCtxt<'tcx>, <del> field_remapping: UnordMap<FieldIdx, (FieldIdx, Ty<'tcx>, bool, &'tcx [Projection<'tcx>])>, </del> <ins> field_remapping: UnordMap<FieldIdx, (FieldIdx, Ty<'tcx>, bool, Vec<Projection<'tcx>>)>, </ins> by_move_coroutine_ty: Ty<'tcx>, }


if place.local == ty::CAPTURE_STRUCT_LOCAL && let Some((&mir::ProjectionElem::Field(idx, _), projection)) = place.projection.split_first() <del> && let Some(&(remapped_idx, remapped_ty, needs_deref, bridging_projections)) = </del> <ins> && let Some(&(remapped_idx, remapped_ty, peel_deref, ref bridging_projections)) = </ins> self.field_remapping.get(&idx) { // As noted before, if the parent closure captures a field by value, and // the child captures a field by ref, then for the by-move body we're // generating, we also are taking that field by value. Peel off a deref, // since a layer of ref'ing has now become redundant. <del> let final_projections = if needs_deref { </del> <ins> let final_projections = if peel_deref { </ins> let Some((mir::ProjectionElem::Deref, projection)) = projection.split_first() else { bug!(


<ins> //@ compile-flags: -Zvalidate-mir //@ edition: 2021 #![feature(async_closure)] // NOT copy. struct Ty; fn hello(x: &Ty) { let c = async || { *x; //~^ ERROR cannot move out of `*x` which is behind a shared reference }; } fn main() {} </ins>


<ins> error[E0507]: cannot move out of `*x` which is behind a shared reference --> $DIR/move-out-of-ref.rs:11:9 | LL |         *x; |         ^^ move occurs because `*x` has type `Ty`, which does not implement the `Copy` trait | note: if `Ty` implemented `Clone`, you could clone the value --> $DIR/move-out-of-ref.rs:7:1 | LL | struct Ty; | ^^^^^^^^^ consider implementing `Clone` for this type ... LL |         *x; |         -- you could clone this value error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0507`. </ins>


// the string "false". Now it is disabled by absence of the attribute. to_add.push(llvm::CreateAttrStringValue(cx.llcx, "branch-target-enforcement", "false")); } <del> } else if llvm_util::get_version() >= (19, 0, 0) { // For non-naked functions, set branch protection attributes on aarch64. if let Some(BranchProtection { bti, pac_ret }) = cx.sess().opts.unstable_opts.branch_protection { assert!(cx.sess().target.arch == "aarch64"); if bti { to_add.push(llvm::CreateAttrString(cx.llcx, "branch-target-enforcement")); } if let Some(PacRet { leaf, key }) = pac_ret { to_add.push(llvm::CreateAttrStringValue( cx.llcx, "sign-return-address", if leaf { "all" } else { "non-leaf" }, )); to_add.push(llvm::CreateAttrStringValue( cx.llcx, "sign-return-address-key", if key == PAuthKey::A { "a_key" } else { "b_key" }, )); </del> <ins> } else { // Do not set sanitizer attributes for naked functions. to_add.extend(sanitize_attrs(cx, codegen_fn_attrs.no_sanitize)); if llvm_util::get_version() >= (19, 0, 0) { // For non-naked functions, set branch protection attributes on aarch64. if let Some(BranchProtection { bti, pac_ret }) = cx.sess().opts.unstable_opts.branch_protection { assert!(cx.sess().target.arch == "aarch64"); if bti { to_add.push(llvm::CreateAttrString(cx.llcx, "branch-target-enforcement")); } if let Some(PacRet { leaf, key }) = pac_ret { to_add.push(llvm::CreateAttrStringValue( cx.llcx, "sign-return-address", if leaf { "all" } else { "non-leaf" }, )); to_add.push(llvm::CreateAttrStringValue( cx.llcx, "sign-return-address-key", if key == PAuthKey::A { "a_key" } else { "b_key" }, )); } </ins> } } }


if let Some(backchain) = backchain_attr(cx) { to_add.push(backchain); } <del> to_add.extend(sanitize_attrs(cx, codegen_fn_attrs.no_sanitize)); </del> to_add.extend(patchable_function_entry_attrs(cx, codegen_fn_attrs.patchable_function_entry)); // Always annotate functions with the target-cpu they are compiled for.


<ins> // Make sure we do not request sanitizers for naked functions. //@ only-x86_64 //@ needs-sanitizer-address //@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static #![crate_type = "lib"] #![no_std] #![feature(abi_x86_interrupt, naked_functions)] // CHECK: define x86_intrcc void @page_fault_handler(ptr {{.*}}%0, i64 {{.*}}%1){{.*}}#[[ATTRS:[0-9]+]] { // CHECK-NOT: memcpy #[naked] #[no_mangle] pub extern "x86-interrupt" fn page_fault_handler(_: u64, _: u64) { unsafe { core::arch::asm!("ud2", options(noreturn)); } } // CHECK: #[[ATTRS]] = // CHECK-NOT: sanitize_address </ins>


let ty_fn_ptr_from = tcx.safe_to_unsafe_fn_ty(fn_sig); <del> if let Err(terr) = self.eq_types( *ty, </del> <ins> if let Err(terr) = self.sub_types( </ins> ty_fn_ptr_from, <ins> *ty, </ins> location.to_locations(), ConstraintCategory::Cast { unsize_to: None }, ) {


<ins> //@ check-pass fn higher_ranked_fndef(ctx: &mut ()) {} fn test(higher_ranked_fnptr: fn(&mut ())) { fn as_unsafe<T>(_: unsafe fn(T)) {} // Make sure that we can cast higher-ranked fn items and pointers to // a non-higher-ranked target. as_unsafe(higher_ranked_fndef); as_unsafe(higher_ranked_fnptr); } fn main() {} </ins>


) -> DefId { let body = tcx.mir_built(coroutine_def_id).borrow(); <ins> // If the typeck results are tainted, no need to make a by-ref body. if body.tainted_by_errors.is_some() { return coroutine_def_id.to_def_id(); } </ins> let Some(hir::CoroutineKind::Desugared(_, hir::CoroutineSource::Closure)) = tcx.coroutine_kind(coroutine_def_id) else {


// the MIR body will be constructed well. let coroutine_ty = body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty; <del> let ty::Coroutine(_, args) = *coroutine_ty.kind() else { bug!("{body:#?}") }; </del> <ins> let ty::Coroutine(_, args) = *coroutine_ty.kind() else { bug!("tried to create by-move body of non-coroutine receiver"); }; </ins> let args = args.as_coroutine(); let coroutine_kind = args.kind_ty().to_opt_closure_kind().unwrap();


let ty::CoroutineClosure(_, parent_args) = *tcx.type_of(parent_def_id).instantiate_identity().kind() else { <del> bug!(); </del> <ins> bug!("coroutine's parent was not a coroutine-closure"); </ins> }; if parent_args.references_error() { return coroutine_def_id.to_def_id();


<ins> //@ edition: 2021 #![feature(async_closure)] // Ensure that building a by-ref async closure body doesn't ICE when the parent // body is tainted. fn main() { missing; //~^ ERROR cannot find value `missing` in this scope // We don't do numerical inference fallback when the body is tainted. // This leads to writeback folding the type of the coroutine-closure // into an error type, since its signature contains that numerical // infer var. let c = async |_| {}; c(1); } </ins>


<ins> error[E0425]: cannot find value `missing` in this scope --> $DIR/tainted-body-2.rs:9:5 | LL |     missing; |     ^^^^^^^ not found in this scope error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0425`. </ins>


let mut span = None; let mut accum = 0u64; <del> for (index, arg_def) in fn_sig.inputs().iter().enumerate() { let layout = tcx.layout_of(ParamEnv::reveal_all().and(*arg_def.skip_binder()))?; </del> <ins> // this type is only used for layout computation, which does not rely on regions let fn_sig = tcx.instantiate_bound_regions_with_erased(fn_sig); for (index, ty) in fn_sig.inputs().iter().enumerate() { let layout = tcx.layout_of(ParamEnv::reveal_all().and(*ty))?; </ins> let align = layout.layout.align().abi.bytes(); let size = layout.layout.size().bytes();


tcx: TyCtxt<'tcx>, fn_sig: ty::PolyFnSig<'tcx>, ) -> Result<bool, &'tcx LayoutError<'tcx>> { <del> let mut ret_ty = fn_sig.output().skip_binder(); </del> <ins> // this type is only used for layout computation, which does not rely on regions let fn_sig = tcx.instantiate_bound_regions_with_erased(fn_sig); let mut ret_ty = fn_sig.output(); </ins> let layout = tcx.layout_of(ParamEnv::reveal_all().and(ret_ty))?; let size = layout.layout.size().bytes();


struct Wrapper<T>(T); struct Test<T: Copy> { <del> f1: extern "C-cmse-nonsecure-call" fn<U: Copy>(U, u32, u32, u32) -> u64, //~ ERROR cannot find type `U` in this scope //~^ ERROR function pointer types may not have generic parameters </del> <ins> f1: extern "C-cmse-nonsecure-call" fn<U: Copy>(U, u32, u32, u32) -> u64, //~^ ERROR cannot find type `U` in this scope //~| ERROR function pointer types may not have generic parameters </ins> f2: extern "C-cmse-nonsecure-call" fn(impl Copy, u32, u32, u32) -> u64, //~^ ERROR `impl Trait` is not allowed in `fn` pointer parameters f3: extern "C-cmse-nonsecure-call" fn(T, u32, u32, u32) -> u64, //~ ERROR [E0798] f4: extern "C-cmse-nonsecure-call" fn(Wrapper<T>, u32, u32, u32) -> u64, //~ ERROR [E0798] } <ins> type WithReference = extern "C-cmse-nonsecure-call" fn(&usize); trait Trait {} type WithTraitObject = extern "C-cmse-nonsecure-call" fn(&dyn Trait) -> &dyn Trait; //~^ ERROR return value of `"C-cmse-nonsecure-call"` function too large to pass via registers [E0798] type WithStaticTraitObject = extern "C-cmse-nonsecure-call" fn(&'static dyn Trait) -> &'static dyn Trait; //~^ ERROR return value of `"C-cmse-nonsecure-call"` function too large to pass via registers [E0798] #[repr(transparent)] struct WrapperTransparent<'a>(&'a dyn Trait); type WithTransparentTraitObject = extern "C-cmse-nonsecure-call" fn(WrapperTransparent) -> WrapperTransparent; //~^ ERROR return value of `"C-cmse-nonsecure-call"` function too large to pass via registers [E0798] type WithVarArgs = extern "C-cmse-nonsecure-call" fn(u32, ...); //~^ ERROR C-variadic function must have a compatible calling convention, like `C` or `cdecl` [E0045] </ins>


|                    +++ error[E0562]: `impl Trait` is not allowed in `fn` pointer parameters <del> --> $DIR/generics.rs:17:43 </del> <ins> --> $DIR/generics.rs:18:43 </ins> | LL |     f2: extern "C-cmse-nonsecure-call" fn(impl Copy, u32, u32, u32) -> u64, |                                           ^^^^^^^^^


= note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0798]: function pointers with the `"C-cmse-nonsecure-call"` ABI cannot contain generics in their type <del> --> $DIR/generics.rs:19:9 </del> <ins> --> $DIR/generics.rs:20:9 </ins> | LL |     f3: extern "C-cmse-nonsecure-call" fn(T, u32, u32, u32) -> u64, |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0798]: function pointers with the `"C-cmse-nonsecure-call"` ABI cannot contain generics in their type <del> --> $DIR/generics.rs:20:9 </del> <ins> --> $DIR/generics.rs:21:9 </ins> | LL |     f4: extern "C-cmse-nonsecure-call" fn(Wrapper<T>, u32, u32, u32) -> u64, |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <del> error: aborting due to 5 previous errors </del> <ins> error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers --> $DIR/generics.rs:27:73 | LL | type WithTraitObject = extern "C-cmse-nonsecure-call" fn(&dyn Trait) -> &dyn Trait; |                                                                         ^^^^^^^^^^ this type doesn't fit in the available registers | = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers --> $DIR/generics.rs:31:62 | LL |     extern "C-cmse-nonsecure-call" fn(&'static dyn Trait) -> &'static dyn Trait; |                                                              ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers | = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers --> $DIR/generics.rs:38:62 | LL |     extern "C-cmse-nonsecure-call" fn(WrapperTransparent) -> WrapperTransparent; |                                                              ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers | = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl` --> $DIR/generics.rs:41:20 | LL | type WithVarArgs = extern "C-cmse-nonsecure-call" fn(u32, ...); |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention error: aborting due to 9 previous errors </ins> <del> Some errors have detailed explanations: E0412, E0562, E0798. For more information about an error, try `rustc --explain E0412`. </del> <ins> Some errors have detailed explanations: E0045, E0412, E0562, E0798. For more information about an error, try `rustc --explain E0045`. </ins>


cmd_finder.must_have(s); } <del> // this warning is useless in CI, // and CI probably won't have the right branches anyway. if !build_helper::ci::CiEnv::is_ci() { if let Err(e) = warn_old_master_branch(&build.config.git_config(), &build.config.src) .map_err(|e| e.to_string()) { eprintln!("unable to check if upstream branch is old: {e}"); } } </del> <ins> warn_old_master_branch(&build.config.git_config(), &build.config.src); </ins> }


/// /// This can result in formatting thousands of files instead of a dozen, /// so we should warn the user something is wrong. <del> pub fn warn_old_master_branch( config: &GitConfig<'_>, git_dir: &Path, ) -> Result<(), Box<dyn std::error::Error>> { use std::time::Duration; const WARN_AFTER: Duration = Duration::from_secs(60 * 60 * 24 * 10); let updated_master = updated_master_branch(config, Some(git_dir))?; let branch_path = git_dir.join(".git/refs/remotes").join(&updated_master); match std::fs::metadata(branch_path) { Ok(meta) => { if meta.modified()?.elapsed()? > WARN_AFTER { eprintln!("warning: {updated_master} has not been updated in 10 days"); } else { return Ok(()); </del> <ins> pub fn warn_old_master_branch(config: &GitConfig<'_>, git_dir: &Path) { if crate::ci::CiEnv::is_ci() { // this warning is useless in CI, // and CI probably won't have the right branches anyway. return; } // this will be overwritten by the actual name, if possible let mut updated_master = "the upstream master branch".to_string(); match warn_old_master_branch_(config, git_dir, &mut updated_master) { Ok(branch_is_old) => { if !branch_is_old { return; </ins> } <ins> // otherwise fall through and print the rest of the warning </ins> } Err(err) => { eprintln!("warning: unable to check if {updated_master} is old due to error: {err}")


} eprintln!( "warning: {updated_master} is used to determine if files have been modifiedn <del> warning: if it is not updated, this may cause files to be needlessly reformatted" </del> <ins> warning: if it is not updated, this may cause files to be needlessly reformatted" </ins> ); <del> Ok(()) </del> <ins> } pub fn warn_old_master_branch_( config: &GitConfig<'_>, git_dir: &Path, updated_master: &mut String, ) -> Result<bool, Box<dyn std::error::Error>> { use std::time::Duration; *updated_master = updated_master_branch(config, Some(git_dir))?; let branch_path = git_dir.join(".git/refs/remotes").join(&updated_master); const WARN_AFTER: Duration = Duration::from_secs(60 * 60 * 24 * 10); let meta = match std::fs::metadata(&branch_path) { Ok(meta) => meta, Err(err) => { let gcd = git_common_dir(&git_dir)?; if branch_path.starts_with(&gcd) { return Err(Box::new(err)); } std::fs::metadata(Path::new(&gcd).join("refs/remotes").join(&updated_master))? } }; if meta.modified()?.elapsed()? > WARN_AFTER { eprintln!("warning: {updated_master} has not been updated in 10 days"); Ok(true) } else { Ok(false) } } fn git_common_dir(dir: &Path) -> Result<String, String> { output_result(Command::new("git").arg("-C").arg(dir).arg("rev-parse").arg("--git-common-dir")) .map(|x| x.trim().to_string()) </ins> }


} #[derive(PartialEq, Eq, Clone, Copy, Debug)] <del> pub struct ExitCode(bool); </del> <ins> pub struct ExitCode(u8); </ins> impl ExitCode { <del> pub const SUCCESS: ExitCode = ExitCode(false); pub const FAILURE: ExitCode = ExitCode(true); </del> <ins> pub const SUCCESS: ExitCode = ExitCode(0); pub const FAILURE: ExitCode = ExitCode(1); </ins> pub fn as_i32(&self) -> i32 { self.0 as i32


impl From<u8> for ExitCode { fn from(code: u8) -> Self { <del> match code { 0 => Self::SUCCESS, 1..=255 => Self::FAILURE, } </del> <ins> Self(code) </ins> } }


// if a test does not crash, consider it an error if proc_res.status.success() || matches!(proc_res.status.code(), Some(1 | 0)) { self.fatal(&format!( <del> "crashtest no longer crashes/triggers ICE, horray! Please give it a meaningful name,  add a doc-comment to the start of the test explaining why it exists and  move it to tests/ui or wherever you see fit. Adding 'Fixes #<issueNr>' to your PR description  ensures that the corresponding ticket is auto-closed upon merge." </del> <ins> "crashtest no longer crashes/triggers ICE, horray! Please give it a meaningful  name, add a doc-comment to the start of the test explaining why it exists and  move it to tests/ui or wherever you see fit. Adding 'Fixes #<issueNr>' to your PR  description ensures that the corresponding ticket is auto-closed upon merge.  If you want to see verbose output, set `COMPILETEST_VERBOSE_CRASHES=1`." </ins> )); } }


} .docblock li { <del> margin-bottom: .8em; </del> <ins> margin-bottom: .4em; </ins> } <del> .docblock li p { margin-bottom: .1em; </del> <ins> .docblock li p:not(:last-child) { /* This margin is voluntarily smaller than `.docblock li` to keep the visual list element items separated while also having a visual separation (although smaller) for paragraphs. */ margin-bottom: .3em; </ins> } /* "where ..." clauses with block display are also smaller */


<ins> // This test ensures that the documentation list markers are correctly placed. // It also serves as a regression test for <https://github.com/rust-lang/rust/issues/130622>. go-to: "file://" + |DOC_PATH| + "/test_docs/long_list/index.html" show-text: true // 0.3em assert-css: (".docblock li p:not(last-child)", {"margin-bottom": "4.8px"}) assert-css: (".docblock li p + p:last-child", {"margin-bottom": "0px"}) // 0.4em assert-css: (".docblock li", {"margin-bottom": "6.4px"}) </ins>


/// subt_vec_num(x: &[f64], y: f64) pub fn subt_vec_num() {} } <ins> pub mod long_list { //! bla //! //! * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque et libero ut leo //!   interdum laoreet vitae a mi. Aliquam erat volutpat. Suspendisse volutpat non quam non //!   commodo. //! //!   Praesent enim neque, imperdiet sed nisl at, lobortis egestas augue. Sed vitae tristique //!   augue. Phasellus vel pretium lectus. //! * Praesent enim neque, imperdiet sed nisl at, lobortis egestas augue. Sed vitae tristique //!   augue. Phasellus vel pretium lectus. //! * Praesent enim neque, imperdiet sed nisl at, lobortis egestas augue. Sed vitae tristique //!   augue. Phasellus vel pretium lectus. //! //! Another list: //! //! * [`TryFromBytes`](#a) indicates that a type may safely be converted from certain byte //!   sequence (conditional on runtime checks) //! * [`FromZeros`](#a) indicates that a sequence of zero bytes represents a valid instance of //!   a type //! * [`FromBytes`](#a) indicates that a type may safely be converted from an arbitrary byte //!   sequence } </ins>


} macro_rules! tool_check_step { <del> ($name:ident, $path:literal, $($alias:literal, )* $source_type:path $(, $default:literal )?) => { </del> <ins> ( $name:ident, $display_name:literal, $path:literal, $($alias:literal, )* $source_type:path $(, $default:literal )? ) => { </ins> #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct $name { pub target: TargetSelection,


cargo.arg("--all-targets"); } <del> let _guard = builder.msg_check(&concat!(stringify!($name), " artifacts").to_lowercase(), target); </del> <ins> let _guard = builder.msg_check(&format!("{} artifacts", $display_name), target); </ins> run_cargo( builder, cargo,


}; } <del> tool_check_step!(Rustdoc, "src/tools/rustdoc", "src/librustdoc", SourceType::InTree); </del> <ins> tool_check_step!(Rustdoc, "rustdoc", "src/tools/rustdoc", "src/librustdoc", SourceType::InTree); </ins> // Clippy, miri and Rustfmt are hybrids. They are external tools, but use a git subtree instead // of a submodule. Since the SourceType only drives the deny-warnings // behavior, treat it as in-tree so that any new warnings in clippy will be // rejected. <del> tool_check_step!(Clippy, "src/tools/clippy", SourceType::InTree); tool_check_step!(Miri, "src/tools/miri", SourceType::InTree); tool_check_step!(CargoMiri, "src/tools/miri/cargo-miri", SourceType::InTree); tool_check_step!(Rls, "src/tools/rls", SourceType::InTree); tool_check_step!(Rustfmt, "src/tools/rustfmt", SourceType::InTree); tool_check_step!(MiroptTestTools, "src/tools/miropt-test-tools", SourceType::InTree); tool_check_step!(TestFloatParse, "src/etc/test-float-parse", SourceType::InTree); tool_check_step!(Bootstrap, "src/bootstrap", SourceType::InTree, false); </del> <ins> tool_check_step!(Clippy, "clippy", "src/tools/clippy", SourceType::InTree); tool_check_step!(Miri, "miri", "src/tools/miri", SourceType::InTree); tool_check_step!(CargoMiri, "cargo-miri", "src/tools/miri/cargo-miri", SourceType::InTree); tool_check_step!(Rls, "rls", "src/tools/rls", SourceType::InTree); tool_check_step!(Rustfmt, "rustfmt", "src/tools/rustfmt", SourceType::InTree); tool_check_step!( MiroptTestTools, "miropt-test-tools", "src/tools/miropt-test-tools", SourceType::InTree ); tool_check_step!( TestFloatParse, "test-float-parse", "src/etc/test-float-parse", SourceType::InTree ); tool_check_step!(Bootstrap, "bootstrap", "src/bootstrap", SourceType::InTree, false); </ins> /// Cargo's output path for the standard library in a given stage, compiled /// by a particular compiler for the specified target.


}); }  function escape(content) { return $('
').text(content).html(); }  function showResults(results) { var output, shown, query = getQuery(); currentResults = query.id;  output = '
Results for ' + query.query + (query.type ? ' (type: ' + query.type + ')' : '') + '
';   output = '
Results for ' + escape(query.query) + (query.type ? ' (type: ' + escape(query.type) + ')' : '') + '
';  output += '
'; if (results.length > 0) {


TcpWatcher { home: home, handle: handle, <del> stream: StreamWatcher::new(handle), </del> <ins> stream: StreamWatcher::new(handle, true), </ins> refcount: Refcount::new(), read_access: AccessTimeout::new(), write_access: AccessTimeout::new(),


fn clone(&self) -> Box<rtio::RtioTcpStream + Send> { box TcpWatcher { handle: self.handle, <del> stream: StreamWatcher::new(self.handle), </del> <ins> stream: StreamWatcher::new(self.handle, false), </ins> home: self.home.clone(), refcount: self.refcount.clone(), read_access: self.read_access.clone(),


handle }; PipeWatcher { <del> stream: StreamWatcher::new(handle), </del> <ins> stream: StreamWatcher::new(handle, true), </ins> home: home, defused: false, refcount: Refcount::new(),


fn clone(&self) -> Box<rtio::RtioPipe + Send> { box PipeWatcher { <del> stream: StreamWatcher::new(self.stream.handle), </del> <ins> stream: StreamWatcher::new(self.stream.handle, false), </ins> defused: false, home: self.home.clone(), refcount: self.refcount.clone(),


// will be manipulated on each of the methods called on this watcher. // Wrappers should ensure to always reset the field to an appropriate value // if they rely on the field to perform an action. <del> pub fn new(stream: *mut uvll::uv_stream_t) -> StreamWatcher { unsafe { uvll::set_data_for_uv_handle(stream, 0 as *mut int) } </del> <ins> pub fn new(stream: *mut uvll::uv_stream_t, init: bool) -> StreamWatcher { if init { unsafe { uvll::set_data_for_uv_handle(stream, 0 as *mut int) } } </ins> StreamWatcher { handle: stream, last_write_req: None,


let handle = UvHandle::alloc(None::<TtyWatcher>, uvll::UV_TTY); let mut watcher = TtyWatcher { tty: handle, <del> stream: StreamWatcher::new(handle), </del> <ins> stream: StreamWatcher::new(handle, true), </ins> home: io.make_handle(), fd: fd, };


rx2.recv(); }) <ins> iotest!(fn clone_while_reading() { let addr = next_test_ip6(); let listen = TcpListener::bind(addr.ip.to_str().as_slice(), addr.port); let mut accept = listen.listen().unwrap(); // Enqueue a task to write to a socket let (tx, rx) = channel(); let (txdone, rxdone) = channel(); let txdone2 = txdone.clone(); spawn(proc() { let mut tcp = TcpStream::connect(addr.ip.to_str().as_slice(), addr.port).unwrap(); rx.recv(); tcp.write_u8(0).unwrap(); txdone2.send(()); }); // Spawn off a reading clone let tcp = accept.accept().unwrap(); let tcp2 = tcp.clone(); let txdone3 = txdone.clone(); spawn(proc() { let mut tcp2 = tcp2; tcp2.read_u8().unwrap(); txdone3.send(()); }); // Try to ensure that the reading clone is indeed reading for _ in range(0i, 50) { ::task::deschedule(); } // clone the handle again while it's reading, then let it finish the // read. let _ = tcp.clone(); tx.send(()); rxdone.recv(); rxdone.recv(); }) </ins> }


use std::io::timer; use mem; <del> let mut tb = TaskBuilder::new(); </del> <ins> let tb = TaskBuilder::new(); </ins> let rx = tb.try_future(proc() {}); mem::drop(rx); timer::sleep(1000);


gimli.debug = 0 miniz_oxide.debug = 0 object.debug = 0 <ins> rustc-demangle.debug = 0 </ins> # These are very thin wrappers around executing lld with the right binary name. # Basically nothing within them can go wrong without having been explicitly logged anyway.


<del> use crate::ffi::OsStr; </del> <ins> use crate::ffi::{OsStr, OsString}; </ins> use crate::fmt; use crate::io; <del> use crate::marker::PhantomData; </del> use crate::num::NonZero; use crate::path::Path; use crate::sys::fs::File;


//////////////////////////////////////////////////////////////////////////////// pub struct Command { <ins> program: OsString, args: Vec<OsString>, </ins> env: CommandEnv, <ins> cwd: Option<OsString>, stdin: Option<Stdio>, stdout: Option<Stdio>, stderr: Option<Stdio>, </ins> } // passed back to std::process with the pipes connected to the child, if any


pub stderr: Option<AnonPipe>, } <del> // FIXME: This should be a unit struct, so we can always construct it // The value here should be never used, since we cannot spawn processes. </del> <ins> #[derive(Debug)] </ins> pub enum Stdio { Inherit, Null, MakePipe, <ins> ParentStdout, ParentStderr, #[allow(dead_code)] // This variant exists only for the Debug impl InheritFile(File), </ins> } impl Command { <del> pub fn new(_program: &OsStr) -> Command { Command { env: Default::default() } </del> <ins> pub fn new(program: &OsStr) -> Command { Command { program: program.to_owned(), args: vec![program.to_owned()], env: Default::default(), cwd: None, stdin: None, stdout: None, stderr: None, } </ins> } <del> pub fn arg(&mut self, _arg: &OsStr) {} </del> <ins> pub fn arg(&mut self, arg: &OsStr) { self.args.push(arg.to_owned()); } </ins> pub fn env_mut(&mut self) -> &mut CommandEnv { &mut self.env } <del> pub fn cwd(&mut self, _dir: &OsStr) {} </del> <ins> pub fn cwd(&mut self, dir: &OsStr) { self.cwd = Some(dir.to_owned()); } </ins> <del> pub fn stdin(&mut self, _stdin: Stdio) {} </del> <ins> pub fn stdin(&mut self, stdin: Stdio) { self.stdin = Some(stdin); } </ins> <del> pub fn stdout(&mut self, _stdout: Stdio) {} </del> <ins> pub fn stdout(&mut self, stdout: Stdio) { self.stdout = Some(stdout); } </ins> <del> pub fn stderr(&mut self, _stderr: Stdio) {} </del> <ins> pub fn stderr(&mut self, stderr: Stdio) { self.stderr = Some(stderr); } </ins> pub fn get_program(&self) -> &OsStr { <del> panic!("unsupported") </del> <ins> &self.program </ins> } pub fn get_args(&self) -> CommandArgs<'_> { <del> CommandArgs { _p: PhantomData } </del> <ins> let mut iter = self.args.iter(); iter.next(); CommandArgs { iter } </ins> } pub fn get_envs(&self) -> CommandEnvs<'_> {


} pub fn get_current_dir(&self) -> Option<&Path> { <del> None </del> <ins> self.cwd.as_ref().map(|cs| Path::new(cs)) </ins> } pub fn spawn(