fn process() { let handles: Vec<_> = (0..10).map(|_| { thread::spawn(|| { <del> let mut _x = 0; </del> <ins> let mut x = 0; </ins> for _ in (0..5_000_000) { <del> _x += 1 </del> <ins> x += 1 </ins> } <ins> x </ins> }) }).collect(); for h in handles { <del> h.join().ok().expect("Could not join a thread!"); </del> <ins> println!("Thread finished with count={}", h.join().map_err(|_| "Could not join a thread!").unwrap()); </ins> } <ins> println!("done!"); </ins> } ``` Some of this should look familiar from previous examples. We spin up ten threads, collecting them into a `handles` vector. Inside of each thread, we <del> loop five million times, and add one to `_x` each time. Why the underscore? Well, if we remove it and compile: ```bash $ cargo build Compiling embed v0.1.0 (file:///home/steve/src/embed) src/lib.rs:3:1: 16:2 warning: function is never used: `process`, #[warn(dead_code)] on by default src/lib.rs:3 fn process() { src/lib.rs:4     let handles: Vec<_> = (0..10).map(|_| { src/lib.rs:5         thread::spawn(|| { src/lib.rs:6             let mut x = 0; src/lib.rs:7             for _ in (0..5_000_000) { src/lib.rs:8                 x += 1 ... src/lib.rs:6:17: 6:22 warning: variable `x` is assigned to, but never used, #[warn(unused_variables)] on by default src/lib.rs:6             let mut x = 0; ^~~~~ ``` That first warning is because we are building a library. If we had a test for this function, the warning would go away. But for now, it’s never called. The second is related to `x` versus `_x`. Because we never actually _do_ anything with `x`, we get a warning about it. In our case, that’s perfectly okay, as we’re just trying to waste CPU cycles. Prefixing `x` with the underscore removes the warning. Finally, we join on each thread. </del> <ins> loop five million times, and add one to `x` each time. Finally, we join on each thread. </ins> Right now, however, this is a Rust library, and it doesn’t expose anything that’s callable from C. If we tried to hook this up to another language right


} #[test] <del> #[cfg_attr(any(target_os = "vxworks", target_os = "android"), ignore)] </del> <ins> #[cfg_attr(any(target_os = "vxworks"), ignore)] </ins> fn test_process_output_error() { let Output { status, stdout, stderr } = if cfg!(target_os = "windows") { Command::new("cmd").args(&["/C", "mkdir ."]).output().unwrap()


// Check magic number let magic = t!(read_le_u16(file)); <del> if magic != 0x011A { return Err(format!("invalid magic number: expected {:x}, found {:x}", 0x011A, magic)); } </del> <ins> let extended = match magic { 0o0432 => false, 0o01036 => true, _ => return Err(format!("invalid magic number, found {:o}", magic)), }; </ins> // According to the spec, these fields must be >= -1 where -1 means that the feature is not // supported. Using 0 instead of -1 works because we skip sections with length 0.


<ins> error[E0214]: parenthesized type parameters may only be used with a `Fn` trait --> $DIR/issue-66286.rs:8:22 | LL | pub extern fn foo(_: Vec(u32)) -> u32 { |                      ^^^^^^^^ |                      | |                      only `Fn` traits may use parentheses |                      help: use angle brackets instead: `Vec<u32>` error: aborting due to previous error For more information about this error, try `rustc --explain E0214`. </ins>


} #[cfg(all( <del> any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"), </del> <ins> any( target_arch = "aarch64", target_arch = "powerpc", target_arch = "s390x", target_arch = "x86_64" ), </ins> any(not(target_arch = "aarch64"), not(any(target_os = "macos", target_os = "ios"))), not(target_family = "wasm"), not(target_arch = "asmjs"),


<ins> error: `extern` fn uses type `NotSafe`, which is not FFI-safe --> $DIR/lint-ctypes-113436-1.rs:22:22 | LL | extern "C" fn bar(x: Bar) -> Bar { |                      ^^^ not FFI-safe | = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct = note: this struct has unspecified layout note: the type is defined here --> $DIR/lint-ctypes-113436-1.rs:13:1 | LL | struct NotSafe(u32); | ^^^^^^^^^^^^^^ note: the lint level is defined here --> $DIR/lint-ctypes-113436-1.rs:1:9 | LL | #![deny(improper_ctypes_definitions)] |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` fn uses type `NotSafe`, which is not FFI-safe --> $DIR/lint-ctypes-113436-1.rs:22:30 | LL | extern "C" fn bar(x: Bar) -> Bar { |                              ^^^ not FFI-safe | = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct = note: this struct has unspecified layout note: the type is defined here --> $DIR/lint-ctypes-113436-1.rs:13:1 | LL | struct NotSafe(u32); | ^^^^^^^^^^^^^^ error: aborting due to 2 previous errors </ins>


pub fn foo(arg: Option<&Vec<i32>>) -> Option<&[i32]> { arg //~ ERROR 5:5: 5:8: mismatched types [E0308] } <ins> pub fn bar(arg: Option<&Vec<i32>>) -> &[i32] { arg.unwrap_or(&[]) //~ ERROR 9:19: 9:22: mismatched types [E0308] } pub fn barzz<'a>(arg: Option<&'a Vec<i32>>, v: &'a [i32]) -> &'a [i32] { arg.unwrap_or(v) //~ ERROR 13:19: 13:20: mismatched types [E0308] } pub fn convert_result(arg: Result<&Vec<i32>, ()>) -> &[i32] { arg.unwrap_or(&[]) //~ ERROR 17:19: 17:22: mismatched types [E0308] } </ins>


<ins> error[E0706]: trait fns cannot be declared `async` --> $DIR/async-trait-fn.rs:3:5 | LL |     async fn foo() {} |     ^^^^^^^^^^^^^^^^^ | = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait error[E0706]: trait fns cannot be declared `async` --> $DIR/async-trait-fn.rs:4:5 | LL |     async fn bar(&self) {} |     ^^^^^^^^^^^^^^^^^^^^^^ | = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0706`. </ins>


#[rustc_doc_primitive = "f128"] #[doc(alias = "quad")] <del> /// A 128-bit floating point type (specifically, the "binary128" type defined in IEEE 754-2008). </del> <ins> /// A 128-bit floating-point type (specifically, the "binary128" type defined in IEEE 754-2008). </ins> /// /// This type is very similar to [`prim@f32`] and [`prim@f64`], but has increased precision by using twice /// as many bits as `f64`. Please see [the documentation for `f32`](prim@f32) or [Wikipedia on


<ins> #[doc(hidden)] pub enum HiddenType {} #[doc(hidden)] pub trait HiddenTrait {} </ins>


<ins> error[E0261]: use of undeclared lifetime name `'short` --> $DIR/issue-107090.rs:4:9 | LL |     Foo<'short, 'out, T>: Convert<'a, 'b>; |         ^^^^^^ undeclared lifetime | = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html help: consider making the bound lifetime-generic with a new `'short` lifetime | LL |     for<'short> Foo<'short, 'out, T>: Convert<'a, 'b>; |     +++++++++++ help: consider introducing lifetime `'short` here | LL | struct Foo<'short, 'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>) |            +++++++ error[E0261]: use of undeclared lifetime name `'out` --> $DIR/issue-107090.rs:4:17 | LL |     Foo<'short, 'out, T>: Convert<'a, 'b>; |                 ^^^^ undeclared lifetime | help: consider making the bound lifetime-generic with a new `'out` lifetime | LL |     for<'out> Foo<'short, 'out, T>: Convert<'a, 'b>; |     +++++++++ help: consider introducing lifetime `'out` here | LL | struct Foo<'out, 'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>) |            +++++ error[E0261]: use of undeclared lifetime name `'b` --> $DIR/issue-107090.rs:13:47 | LL | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> { |      -                                        ^^ undeclared lifetime |      | |      help: consider introducing lifetime `'b` here: `'b,` error[E0261]: use of undeclared lifetime name `'out` --> $DIR/issue-107090.rs:13:67 | LL | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> { |      - help: consider introducing lifetime `'out` here: `'out,`   ^^^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'out` --> $DIR/issue-107090.rs:17:49 | LL |     fn cast(&'long self) -> &'short Foo<'short, 'out, T> { |                                                 ^^^^ undeclared lifetime | help: consider introducing lifetime `'out` here | LL |     fn cast<'out>(&'long self) -> &'short Foo<'short, 'out, T> { |            ++++++ help: consider introducing lifetime `'out` here | LL | impl<'out, 'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> { |      +++++ error[E0261]: use of undeclared lifetime name `'short` --> $DIR/issue-107090.rs:24:68 | LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T { |           -                                                        ^^^^^^ undeclared lifetime |           | |           help: consider introducing lifetime `'short` here: `'short,` error[E0308]: mismatched types --> $DIR/issue-107090.rs:4:27 | LL |     Foo<'short, 'out, T>: Convert<'a, 'b>; |                           ^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected trait `Convert<'static, 'static>` found trait `Convert<'a, 'b>` note: the lifetime `'a` as defined here... --> $DIR/issue-107090.rs:2:12 | LL | struct Foo<'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>) |            ^^ = note: ...does not necessarily outlive the static lifetime error[E0308]: mismatched types --> $DIR/issue-107090.rs:4:27 | LL |     Foo<'short, 'out, T>: Convert<'a, 'b>; |                           ^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected trait `Convert<'static, 'static>` found trait `Convert<'a, 'b>` note: the lifetime `'b` as defined here... --> $DIR/issue-107090.rs:2:16 | LL | struct Foo<'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>) |                ^^ = note: ...does not necessarily outlive the static lifetime error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'long` due to conflicting requirements --> $DIR/issue-107090.rs:13:55 | LL | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> { |                                                       ^^^^^^^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'short` as defined here... --> $DIR/issue-107090.rs:13:21 | LL | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> { |                     ^^^^^^ = note: ...but the lifetime must also be valid for the static lifetime... note: ...so that the types are compatible --> $DIR/issue-107090.rs:13:55 | LL | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> { |                                                       ^^^^^^^^^^^^^^^^^^^^ = note: expected `Convert<'short, 'static>` found `Convert<'_, 'static>` error: incompatible lifetime on type --> $DIR/issue-107090.rs:24:29 | LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T { |                             ^^^^^^^^^^^^^^^^^^ | note: because this has an unmet lifetime requirement --> $DIR/issue-107090.rs:4:27 | LL |     Foo<'short, 'out, T>: Convert<'a, 'b>; |                           ^^^^^^^^^^^^^^^ introduces a `'static` lifetime requirement note: the lifetime `'out` as defined here... --> $DIR/issue-107090.rs:24:17 | LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T { |                 ^^^^ note: ...does not necessarily outlive the static lifetime introduced by the compatible `impl` --> $DIR/issue-107090.rs:13:1 | LL | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0759]: `x` has lifetime `'in_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/issue-107090.rs:24:29 | LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T { |                             ^^^^^^^^^^^^^^^^^^ |                             | |                             this data with lifetime `'in_`... |                             ...is used and required to live as long as `'static` here error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'long` due to conflicting requirements --> $DIR/issue-107090.rs:17:13 | LL |     fn cast(&'long self) -> &'short Foo<'short, 'out, T> { |             ^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'short` as defined here... --> $DIR/issue-107090.rs:13:21 | LL | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> { |                     ^^^^^^ = note: ...but the lifetime must also be valid for the static lifetime... note: ...so that the types are compatible --> $DIR/issue-107090.rs:17:13 | LL |     fn cast(&'long self) -> &'short Foo<'short, 'out, T> { |             ^^^^^^^^^^^ = note: expected `Convert<'short, 'static>` found `Convert<'_, 'static>` error: aborting due to 12 previous errors Some errors have detailed explanations: E0261, E0308, E0495, E0759. For more information about an error, try `rustc --explain E0261`. </ins>


} } <ins> impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> { type Result = (); fn visit_ty(&mut self, t: <TyCtxt<'tcx> as ty::Interner>::Ty) -> Self::Result { debug!("wf bounds for t={:?} t.kind={:#?}", t, t.kind()); match *t.kind() { ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) | ty::Float(..) | ty::Error(_) | ty::Str | ty::CoroutineWitness(..) | ty::Never | ty::Param(_) | ty::Bound(..) | ty::Placeholder(..) | ty::Foreign(..) => { // WfScalar, WfParameter, etc } // Can only infer to `ty::Int(_) | ty::Uint(_)`. ty::Infer(ty::IntVar(_)) => {} // Can only infer to `ty::Float(_)`. ty::Infer(ty::FloatVar(_)) => {} ty::Slice(subty) => { self.require_sized(subty, traits::SliceOrArrayElem); } ty::Array(subty, _) => { self.require_sized(subty, traits::SliceOrArrayElem); // Note that we handle the len is implicitly checked while walking `arg`. } ty::Tuple(tys) => { if let Some((_last, rest)) = tys.split_last() { for &elem in rest { self.require_sized(elem, traits::TupleElem); } } } ty::RawPtr(_) => { // Simple cases that are WF if their type args are WF. } ty::Alias(ty::Projection, data) => { self.compute_projection(data); return; // Subtree handled by compute_projection. } ty::Alias(ty::Inherent, data) => { self.compute_inherent_projection(data); return; // Subtree handled by compute_inherent_projection. } ty::Adt(def, args) => { // WfNominalType let obligations = self.nominal_obligations(def.did(), args); self.out.extend(obligations); } ty::FnDef(did, args) => { let obligations = self.nominal_obligations(did, args); self.out.extend(obligations); } ty::Ref(r, rty, _) => { // WfReference if !r.has_escaping_bound_vars() && !rty.has_escaping_bound_vars() { let cause = self.cause(traits::ReferenceOutlivesReferent(t)); self.out.push(traits::Obligation::with_depth( self.tcx(), cause, self.recursion_depth, self.param_env, ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives( ty::OutlivesPredicate(rty, r), ))), )); } } ty::Coroutine(did, args, ..) => { // Walk ALL the types in the coroutine: this will // include the upvar types as well as the yield // type. Note that this is mildly distinct from // the closure case, where we have to be careful // about the signature of the closure. We don't // have the problem of implied bounds here since // coroutines don't take arguments. let obligations = self.nominal_obligations(did, args); self.out.extend(obligations); } ty::Closure(did, args) => { // Note that we cannot skip the generic types // types. Normally, within the fn // body where they are created, the generics will // always be WF, and outside of that fn body we // are not directly inspecting closure types // anyway, except via auto trait matching (which // only inspects the upvar types). // But when a closure is part of a type-alias-impl-trait // then the function that created the defining site may // have had more bounds available than the type alias // specifies. This may cause us to have a closure in the // hidden type that is not actually well formed and // can cause compiler crashes when the user abuses unsafe // code to procure such a closure. // See tests/ui/type-alias-impl-trait/wf_check_closures.rs let obligations = self.nominal_obligations(did, args); self.out.extend(obligations); // Only check the upvar types for WF, not the rest // of the types within. This is needed because we // capture the signature and it may not be WF // without the implied bounds. Consider a closure // like `|x: &'a T|` -- it may be that `T: 'a` is // not known to hold in the creator's context (and // indeed the closure may not be invoked by its // creator, but rather turned to someone who *can* // verify that). // // The special treatment of closures here really // ought not to be necessary either; the problem // is related to #25860 -- there is no way for us // to express a fn type complete with the implied // bounds that it is assuming. I think in reality // the WF rules around fn are a bit messed up, and // that is the rot problem: `fn(&'a T)` should // probably always be WF, because it should be // shorthand for something like `where(T: 'a) { // fn(&'a T) }`, as discussed in #25860. let upvars = args.as_closure().tupled_upvars_ty(); return upvars.visit_with(self); } ty::CoroutineClosure(did, args) => { // See the above comments. The same apply to coroutine-closures. let obligations = self.nominal_obligations(did, args); self.out.extend(obligations); let upvars = args.as_coroutine_closure().tupled_upvars_ty(); return upvars.visit_with(self); } ty::FnPtr(_) => { // Let the visitor iterate into the argument/return // types appearing in the fn signature. } ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => { // All of the requirements on type parameters // have already been checked for `impl Trait` in // return position. We do need to check type-alias-impl-trait though. if self.tcx().is_type_alias_impl_trait(def_id) { let obligations = self.nominal_obligations(def_id, args); self.out.extend(obligations); } } ty::Alias(ty::Weak, ty::AliasTy { def_id, args, .. }) => { let obligations = self.nominal_obligations(def_id, args); self.out.extend(obligations); } ty::Dynamic(data, r, _) => { // WfObject // // Here, we defer WF checking due to higher-ranked // regions. This is perhaps not ideal. self.from_object_ty(t, data, r); // FIXME(#27579) RFC also considers adding trait // obligations that don't refer to Self and // checking those let defer_to_coercion = self.tcx().features().object_safe_for_dispatch; if !defer_to_coercion { if let Some(principal) = data.principal_def_id() { self.out.push(traits::Obligation::with_depth( self.tcx(), self.cause(traits::WellFormed(None)), self.recursion_depth, self.param_env, ty::Binder::dummy(ty::PredicateKind::ObjectSafe(principal)), )); } } } // Inference variables are the complicated case, since we don't // know what type they are. We do two things: // // 1. Check if they have been resolved, and if so proceed with //    THAT type. // 2. If not, we've at least simplified things (e.g., we went //    from `Vec<$0>: WF` to `$0: WF`), so we can //    register a pending obligation and keep //    moving. (Goal is that an "inductive hypothesis" //    is satisfied to ensure termination.) // See also the comment on `fn obligations`, describing "livelock" // prevention, which happens before this can be reached. ty::Infer(_) => { let cause = self.cause(traits::WellFormed(None)); self.out.push(traits::Obligation::with_depth( self.tcx(), cause, self.recursion_depth, self.param_env, ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed( t.into(), ))), )); } } t.super_visit_with(self) } fn visit_const(&mut self, c: <TyCtxt<'tcx> as ty::Interner>::Const) -> Self::Result { match c.kind() { ty::ConstKind::Unevaluated(uv) => { if !c.has_escaping_bound_vars() { let obligations = self.nominal_obligations(uv.def, uv.args); self.out.extend(obligations); let predicate = ty::Binder::dummy(ty::PredicateKind::Clause( ty::ClauseKind::ConstEvaluatable(c), )); let cause = self.cause(traits::WellFormed(None)); self.out.push(traits::Obligation::with_depth( self.tcx(), cause, self.recursion_depth, self.param_env, predicate, )); } } ty::ConstKind::Infer(_) => { let cause = self.cause(traits::WellFormed(None)); self.out.push(traits::Obligation::with_depth( self.tcx(), cause, self.recursion_depth, self.param_env, ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed( c.into(), ))), )); } ty::ConstKind::Expr(_) => { // FIXME(generic_const_exprs): this doesn't verify that given `Expr(N + 1)` the // trait bound `typeof(N): Add<typeof(1)>` holds. This is currently unnecessary // as `ConstKind::Expr` is only produced via normalization of `ConstKind::Unevaluated` // which means that the `DefId` would have been typeck'd elsewhere. However in // the future we may allow directly lowering to `ConstKind::Expr` in which case // we would not be proving bounds we should. let predicate = ty::Binder::dummy(ty::PredicateKind::Clause( ty::ClauseKind::ConstEvaluatable(c), )); let cause = self.cause(traits::WellFormed(None)); self.out.push(traits::Obligation::with_depth( self.tcx(), cause, self.recursion_depth, self.param_env, predicate, )); } ty::ConstKind::Error(_) | ty::ConstKind::Param(_) | ty::ConstKind::Bound(..) | ty::ConstKind::Placeholder(..) => { // These variants are trivially WF, so nothing to do here. } ty::ConstKind::Value(..) => { // FIXME: Enforce that values are structurally-matchable. } } c.super_visit_with(self) } fn visit_predicate(&mut self, _p: <TyCtxt<'tcx> as ty::Interner>::Predicate) -> Self::Result { bug!("predicate should not be checked for well-formedness"); } } </ins> /// Given an object type like `SomeTrait + Send`, computes the lifetime /// bounds that must hold on the elided self type. These are derived /// from the declarations of `SomeTrait`, `Send`, and friends -- if


<ins> error: recursion limit reached while expanding `concat!` --> $DIR/issue-84632-eager-expansion-recursion-limit.rs:8:28 | LL |     (A, $($A:ident),*) => (concat!("", a!($($A),*))) |                            ^^^^^^^^^^^^^^^^^^^^^^^^ ... LL |     a!(A, A, A, A, A, A, A, A, A, A, A); |     ------------------------------------ in this macro invocation | = help: consider adding a `#![recursion_limit="30"]` attribute to your crate (`issue_84632_eager_expansion_recursion_limit`) = note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error </ins>


} } <ins> /// Appends an element if there is sufficient spare capacity, otherwise an error is returned /// with the element. /// /// Unlike [`push`] this method will not reallocate when there's insufficient capacity. /// The caller should use [`reserve`] or [`try_reserve`] to ensure that there is enough capacity. /// /// [`push`]: Vec::push /// [`reserve`]: Vec::reserve /// [`try_reserve`]: Vec::try_reserve /// /// # Examples /// /// A manual, panic-free alternative to [`FromIterator`]: /// /// ``` /// #![feature(vec_push_within_capacity)] /// /// use std::collections::TryReserveError; /// fn from_iter_fallible<T>(iter: impl Iterator<Item=T>) -> Result<Vec<T>, TryReserveError> { ///     let mut vec = Vec::new(); ///     for value in iter { ///         if let Err(value) = vec.push_within_capacity(value) { ///             vec.try_reserve(1)?; ///             // this cannot fail, the previous line either returned or added at least 1 free slot ///             let _ = vec.push_within_capacity(value); ///         } ///     } ///     Ok(vec) /// } /// assert_eq!(from_iter_fallible(0..100), Ok(Vec::from_iter(0..100))); /// ``` #[inline] #[unstable(feature = "vec_push_within_capacity", issue = "100486")] pub fn push_within_capacity(&mut self, value: T) -> Result<(), T> { if self.len == self.buf.capacity() { return Err(value); } unsafe { let end = self.as_mut_ptr().add(self.len); ptr::write(end, value); self.len += 1; } Ok(()) } </ins> /// Removes the last element from a vector and returns it, or [`None`] if it /// is empty. ///


) { // Every lifetime used in an associated type must be constrained. let impl_self_ty = tcx.type_of(impl_def_id); <ins> if impl_self_ty.references_error() { // Don't complain about unconstrained type params when self ty isn't known due to errors. // (#36836) tcx.sess.delay_span_bug( tcx.def_span(impl_def_id), "potentially unconstrained type parameters weren't evaluated", ); return; } </ins> let impl_generics = tcx.generics_of(impl_def_id); let impl_predicates = tcx.predicates_of(impl_def_id); let impl_trait_ref = tcx.impl_trait_ref(impl_def_id);


<del> Subproject commit a18df16181947edd5eb593ea0f2321e0035448ee </del> <ins> Subproject commit 5db91c7b94ca81eead6b25bcf6196b869a44ece0 </ins>


}; let ident = Ident::new(kw::UnderscoreLifetime, elided_lifetime_span); <del> let node_ids = self.r.next_node_ids(expected_lifetimes); self.record_lifetime_res( segment_id, LifetimeRes::ElidedAnchor { start: node_ids.start, end: node_ids.end }, LifetimeElisionCandidate::Ignore, ); if !missing { // Do not create a parameter for patterns and expressions. for id in node_ids { self.record_lifetime_res( id, LifetimeRes::Infer, LifetimeElisionCandidate::Named, ); } continue; } </del> let missing_lifetime = MissingLifetime { id: node_ids.start, span: elided_lifetime_span,


<ins> // run-rustfix fn main() { for _ in 0..256 as u8 {} //~ ERROR range endpoint is out of range for _ in 0..(256 as u8) {} //~ ERROR range endpoint is out of range } </ins>


impl Stdio { fn to_handle(&self, stdio_id: c::DWORD, pipe: &mut Option<AnonPipe>) -> io::Result<Handle> { match *self { <del> // If no stdio handle is available, then inherit means that it // should still be unavailable so propagate the // INVALID_HANDLE_VALUE. </del> Stdio::Inherit => match stdio::get_handle(stdio_id) { Ok(io) => unsafe { let io = Handle::from_raw_handle(io);


"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 7.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "languageserver-types 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", <ins> "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", </ins> "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "racer 2.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "rls-analysis 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rls-data 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", <del> "rustfmt-nightly 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", </del> <ins> "rustfmt-nightly 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", </ins> "serde 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",


<ins> // edition:2018 #![feature(unboxed_closures)] use std::future::Future; async fn wrapper<F>(f: F) //~^ ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` //~| ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` //~| ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` where F:, for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a, { //~^ ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32` let mut i = 41; &mut i; } fn main() {} </ins>


<ins> fn bar() -> impl Fn() { wrap(wrap(wrap(wrap(foo())))) } fn foo() -> impl Fn() { //~^ WARNING 5:1: 5:22: function cannot return without recursing [unconditional_recursion] //~| ERROR 5:13: 5:22: cannot resolve opaque type [E0720] wrap(wrap(wrap(wrap(wrap(wrap(wrap(foo()))))))) } fn wrap(f: impl Fn()) -> impl Fn() { move || f() } fn main() { } </ins>


nested: Vec<Ty<'tcx>>) -> VtableDefaultImplData<PredicateObligation<'tcx>> { <del> let derived_cause = self.derived_cause(obligation, ImplDerivedObligation); let obligations = nested.iter().map(|&nested_ty| { // the obligation might be higher-ranked, e.g. for<'a> &'a // int : Copy. In that case, we will wind up with // late-bound regions in the `nested` vector. So for each // one we instantiate to a skolemized region, do our work // to produce something like `&'0 int : Copy`, and then // re-bind it. This is a bit of busy-work but preserves // the invariant that we only manipulate free regions, not // bound ones. self.infcx.try(|snapshot| { let (skol_ty, skol_map) = self.infcx().skolemize_late_bound_regions(&ty::Binder(nested_ty), snapshot); let skol_predicate = util::predicate_for_default_trait_impl( self.tcx(), derived_cause.clone(), trait_def_id, obligation.recursion_depth + 1, skol_ty); match skol_predicate { Ok(skol_predicate) => Ok(self.infcx().plug_leaks(skol_map, snapshot, &skol_predicate)), Err(ErrorReported) => Err(ErrorReported) } }) }).collect::<Result<_, _>>(); let mut obligations = match obligations { Ok(o) => o, Err(ErrorReported) => Vec::new() }; </del> <ins> let mut obligations = self.collect_predicates_for_types(obligation, trait_def_id, nested); </ins> let _: Result<(),()> = self.infcx.try(|snapshot| { let (_, skol_map) =


#[license = "MIT/ASL2"]; #[crate_type = "rlib"]; #[crate_type = "dylib"]; <del> #[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png", </del> <ins> #[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", </ins> html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://static.rust-lang.org/doc/master")]; #[deny(unused_result, unused_must_use)];


let out = p.wait_with_output().unwrap(); assert!(!out.status.success()); let s = str::from_utf8(&out.stderr).unwrap(); <del> assert!(!s.contains("stack backtrace") && !s.contains("foo::h"), </del> <ins> assert!(!s.contains("stack backtrace") && !s.contains(" - foo"), </ins> "bad output2: {}", s); // Make sure a stack trace is printed


version = "0.0.0" dependencies = [ "arena 0.0.0", <del> "backtrace 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", </del> <ins> "backtrace 0.3.29 (registry+https://github.com/rust-lang/crates.io-index)", </ins> "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "chalk-engine 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",


fi fi <del> # Unless we're using an older version of LLVM, check that all LLVM components # used by tests are available. if [ "$IS_NOT_LATEST_LLVM" = "" ]; then export COMPILETEST_NEEDS_ALL_LLVM_COMPONENTS=1 fi </del> if [ "$ENABLE_GCC_CODEGEN" = "1" ]; then # If `ENABLE_GCC_CODEGEN` is set and not empty, we add the `--enable-new-symbol-mangling` # argument to `RUST_CONFIGURE_ARGS` and set the `GCC_EXEC_PREFIX` environment variable.


[dependencies] toml = "0.5" serde = { version = "1.0", features = ["derive"] } <ins> serde_json = "1.0" </ins>


<ins> mod a { use std::marker::PhantomData; enum Bug { V = [PhantomData; { [ () ].len() ].len() as isize, //~^ ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` } } mod b { enum Bug { V = [Vec::new; { [].len()  ].len() as isize, //~^ ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR type annotations needed } } mod c { enum Bug { V = [Vec::new; { [0].len() ].len() as isize, //~^ ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR mismatched closing delimiter: `]` //~| ERROR type annotations needed } } fn main() {} </ins>


linker_error.emit(); if sess.target.target.options.is_like_msvc && linker_not_found { <del> sess.note_without_error("the msvc targets depend on the msvc linker  but `link.exe` was not found"); sess.note_without_error("please ensure that VS 2013, VS 2015 or VS 2017  was installed with the Visual C++ option"); </del> <ins> sess.note_without_error( "the msvc targets depend on the msvc linker  but `link.exe` was not found", ); sess.note_without_error( "please ensure that VS 2013, VS 2015, VS 2017 or VS 2019  was installed with the Visual C++ option", ); </ins> } sess.abort_if_errors(); }


use std::ffi::CString; <del> use rustc::hir::CodegenFnAttrFlags; </del> <ins> use rustc::hir::{CodegenFnAttrFlags, CodegenFnAttrs}; </ins> use rustc::hir::def_id::{DefId, LOCAL_CRATE}; use rustc::session::Session; use rustc::session::config::Sanitizer;


COMPILE_FLAGS=-g -Cprofile-generate="$(TMPDIR)" <del> # LLVM doesn't yet support instrumenting binaries that use unwinding on MSVC: # https://github.com/rust-lang/rust/issues/61002 # # Things work fine with -Cpanic=abort though. ifdef IS_MSVC COMPILE_FLAGS+= -Cpanic=abort endif </del> all: $(RUSTC) $(COMPILE_FLAGS) test.rs $(call RUN,test) || exit 1


offset: Size, ) -> Self { let alloc_align = alloc.inner().align; <del> assert_eq!(alloc_align, layout.align.abi); </del> <ins> assert!(alloc_align >= layout.align.abi); </ins> let read_scalar = |start, size, s: abi::Scalar, ty| { match alloc.0.read_scalar(


Ok(true) } ty::Float(_) | ty::Int(_) | ty::Uint(_) => { <del> let value = self.ecx.read_scalar(value)?; </del> <ins> let value = try_validation!( self.ecx.read_scalar(value), self.path, err_unsup!(ReadPointerAsBytes) => { "read of part of a pointer" }, ); </ins> // NOTE: Keep this in sync with the array optimization for int/float // types below! if self.ctfe_mode.is_some() {


use middle::typeck::astconv::ast_ty_to_ty; use middle::typeck::infer; use middle::{typeck, ty, def, pat_util, stability}; <ins> use middle::const_eval::{eval_const_expr_partial, const_int, const_uint}; </ins> use util::ppaux::{ty_to_string}; use util::nodemap::NodeSet; use lint::{Context, LintPass, LintArray};


pub fn takes_non_exhaustive(_: NonExhaustiveEnum) { let _closure = |_: NonExhaustiveEnum| {}; } <ins> // ICE #117033 enum Void {} #[deny(non_exhaustive_omitted_patterns)] pub fn void(v: Void) -> ! { match v {} } </ins>


<ins> error[E0433]: failed to resolve: use of undeclared crate or module `should_panic` --> $DIR/check-builtin-attr-ice.rs:43:7 | LL |     #[should_panic::skip] |       ^^^^^^^^^^^^ use of undeclared crate or module `should_panic` error[E0433]: failed to resolve: use of undeclared crate or module `should_panic` --> $DIR/check-builtin-attr-ice.rs:47:7 | LL |     #[should_panic::a::b::c] |       ^^^^^^^^^^^^ use of undeclared crate or module `should_panic` error[E0433]: failed to resolve: use of undeclared crate or module `deny` --> $DIR/check-builtin-attr-ice.rs:55:7 | LL |     #[deny::skip] |       ^^^^ use of undeclared crate or module `deny` error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0433`. </ins>


} } <del> match r.read(&mut g.buf[g.len..]) { Ok(0) => { ret = Ok(g.len - start_len); break; </del> <ins> let buf = &mut g.buf[g.len..]; match r.read(buf) { Ok(0) => return Ok(g.len - start_len), Ok(n) => { // We can't allow bogus values from read. If it is too large, the returned vec could have its length // set past its capacity, or if it overflows the vec could be shortened which could create an invalid // string if this is called via read_to_string. assert!(n <= buf.len()); g.len += n; </ins> } <del> Ok(n) => g.len += n, </del> Err(ref e) if e.kind() == ErrorKind::Interrupted => {} <del> Err(e) => { ret = Err(e); break; } </del> <ins> Err(e) => return Err(e), </ins> } } <del> ret </del> } pub(crate) fn default_read_vectored<F>(read: F, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>


<ins> // Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(rustc_attrs)] #![deny(non_snake_case)] #[no_mangle] pub extern "C" fn SparklingGenerationForeignFunctionInterface() {} #[rustc_error] fn main() {} //~ ERROR compilation successful </ins>


test(parse(""), None); { <del> let build_dir = if cfg!(windows) { Some("C:tmp") } else { Some("/tmp") }; test(parse("build.build-dir = "/tmp""), build_dir); </del> <ins> let build_dir = if cfg!(windows) { "C:tmp" } else { "/tmp" }; test(parse(&format!("build.build-dir = '{build_dir}'")), Some(build_dir)); </ins> } }


<ins> // check-pass // check that `deref_into_dyn_supertrait` doesn't cause ICE by eagerly converting // a cancelled lint #![allow(deref_into_dyn_supertrait)] trait Trait {} impl std::ops::Deref for dyn Trait + Send + Sync { type Target = dyn Trait; fn deref(&self) -> &Self::Target { self } } fn main() {} </ins>


<del> A control-flow expression was used inside a const context. </del> <ins> An unsupported expression was used inside a const context. </ins> Erroneous code example:


// error-pattern: too big for the current fn main() { <del> let fat : [u8, ..(1<<61)+(1<<31)] = [0, ..(1<<61)+(1<<31)]; </del> <ins> let fat : [u8, ..(1<<61)+(1<<31)] = [0, ..(1u64<<61) as uint +(1u64<<31) as uint]; </ins> }


| LL | fn d<const C: S>() {} |               ^ expected named lifetime parameter <del> | help: consider introducing a named lifetime parameter | LL | fn d<'a, const C: S<'a>>() {} |      +++           ++++ </del> error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/unusual-rib-combinations.rs:29:22


<del> Subproject commit 68ff8b19bc6705724d1e77a8dc17ffb8dfbbe26b </del> <ins> Subproject commit edd90473ec5ba29b9ae1ee706c982e7046a6e63e </ins>


IfExpression(a) => { format!("IfExpression({})", a.repr(tcx)) } <ins> IfExpressionWithNoElse(a) => { format!("IfExpressionWithNoElse({})", a.repr(tcx)) } </ins> } } }


<ins> error[E0229]: associated type bindings are not allowed here --> $DIR/issue-102335-gat.rs:2:21 | LL |     type A: S<C<(), i32 = ()> = ()>; |                     ^^^^^^^^ associated type not allowed here error: aborting due to previous error For more information about this error, try `rustc --explain E0229`. </ins>


#![feature(try_blocks)] fn main() { <del> while try { false } {} //~ ERROR expected expression, found reserved keyword `try` </del> <ins> while try { false } {} //~^ ERROR the trait bound `bool: std::ops::Try` is not satisfied </ins> }


} } } <del> // FIXME: also check auto-trait def-ids? (e.g. `impl Sync for Foo+Sync`)? </del> } }


<ins> error[E0106]: missing lifetime specifier --> $DIR/lifetime-in-const-param.rs:5:23 | LL | struct S<'a, const N: S2>(&'a ()); |                       ^^ expected named lifetime parameter error: `S2<'_>` is forbidden as the type of a const generic parameter --> $DIR/lifetime-in-const-param.rs:5:23 | LL | struct S<'a, const N: S2>(&'a ()); |                       ^^ | = note: the only supported types are integers, `bool` and `char` = help: more complex types are supported with `#![feature(adt_const_params)]` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0106`. </ins>


<ins> error: repetition matches empty token tree --> $DIR/issue-57597.rs:8:7 | LL |     ($($($i:ident)?)+) => {}; |       ^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-57597.rs:13:7 | LL |     ($($($i:ident)?)*) => {}; |       ^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-57597.rs:18:7 | LL |     ($($($i:ident)?)?) => {}; |       ^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-57597.rs:23:7 | LL |     ($($($($i:ident)?)?)?) => {}; |       ^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-57597.rs:28:7 | LL |     ($($($($i:ident)*)?)?) => {}; |       ^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-57597.rs:33:7 | LL |     ($($($($i:ident)?)*)?) => {}; |       ^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-57597.rs:38:7 | LL |     ($($($($i:ident)?)?)*) => {}; |       ^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-57597.rs:43:7 | LL |     ($($($($i:ident)*)*)?) => {}; |       ^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-57597.rs:48:7 | LL |     ($($($($i:ident)?)*)*) => {}; |       ^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-57597.rs:53:7 | LL |     ($($($($i:ident)?)*)+) => {}; |       ^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-57597.rs:58:7 | LL |     ($($($($i:ident)+)?)*) => {}; |       ^^^^^^^^^^^^^^^^^^ error: repetition matches empty token tree --> $DIR/issue-57597.rs:63:7 | LL |     ($($($($i:ident)+)*)?) => {}; |       ^^^^^^^^^^^^^^^^^^ error: aborting due to 12 previous errors </ins>


// Does the expected pattern type originate from an expression and what is the span? let (origin_expr, ty_span) = match (decl.ty, decl.init) { <del> (Some(ty), _) => (false, Some(ty.span)), // Bias towards the explicit user type. </del> <ins> (Some(ty), _) => (None, Some(ty.span)), // Bias towards the explicit user type. </ins> (_, Some(init)) => { <del> (true, Some(init.span.find_ancestor_inside(decl.span).unwrap_or(init.span))) </del> <ins> (Some(init), Some(init.span.find_ancestor_inside(decl.span).unwrap_or(init.span))) </ins> } // No explicit type; so use the scrutinee. <del> _ => (false, None), // We have `let $pat;`, so the expected type is unconstrained. </del> <ins> _ => (None, None), // We have `let $pat;`, so the expected type is unconstrained. </ins> }; // Type check the pattern. Override if necessary to avoid knock-on errors.


#[unstable(feature = "scoped_tls", reason = "scoped TLS has yet to have wide enough use to fully consider  stabilizing its interface")] <del> pub struct ScopedKey<T> { inner: imp::KeyInner<T> } </del> <ins> pub struct ScopedKey<T> { inner: fn() -> &'static imp::KeyInner<T> } </ins> /// Declare a new scoped thread local storage key. ///


/// an underlying type by providing a mutable reference. See [`Borrow<T>`] /// for more information on borrowing as another type. #[stable(feature = "rust1", since = "1.0.0")] <ins> #[rustc_diagnostic_item = "BorrowMut"] </ins> pub trait BorrowMut<Borrowed: ?Sized>: Borrow<Borrowed> { /// Mutably borrows from an owned value. ///


&& let Some(pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id) && let Some(arg) = fn_sig.decl.inputs.get(pos + offset) { <del> let mut span: MultiSpan = arg.span.into(); span.push_span_label( arg.span, "this parameter takes ownership of the value".to_string(), ); let descr = match node.fn_kind() { Some(hir::intravisit::FnKind::ItemFn(..)) | None => "function", Some(hir::intravisit::FnKind::Method(..)) => "method", Some(hir::intravisit::FnKind::Closure) => "closure", }; span.push_span_label(ident.span, format!("in this {descr}")); err.span_note( span, format!( "consider changing this parameter type in {descr} `{ident}` to borrow  instead if owning the value isn't necessary", ), ); </del> <ins> let mut is_mut = false; if let hir::TyKind::Path(hir::QPath::Resolved(None, path)) = arg.kind && let Res::Def(DefKind::TyParam, param_def_id) = path.res && self .infcx .tcx .predicates_of(def_id) .instantiate_identity(self.infcx.tcx) .predicates .into_iter() .any(|pred| { if let ty::ClauseKind::Trait(predicate) = pred.kind().skip_binder() && [ self.infcx.tcx.get_diagnostic_item(sym::AsRef), self.infcx.tcx.get_diagnostic_item(sym::AsMut), self.infcx.tcx.get_diagnostic_item(sym::Borrow), self.infcx.tcx.get_diagnostic_item(sym::BorrowMut), ] .contains(&Some(predicate.def_id())) && let ty::Param(param) = predicate.self_ty().kind() && let generics = self.infcx.tcx.generics_of(def_id) && let param = generics.type_param(*param, self.infcx.tcx) && param.def_id == param_def_id { if [ self.infcx.tcx.get_diagnostic_item(sym::AsMut), self.infcx.tcx.get_diagnostic_item(sym::BorrowMut), ] .contains(&Some(predicate.def_id())) { is_mut = true; } true } else { false } }) { // The type of the argument corresponding to the expression that got moved // is a type parameter `T`, which is has a `T: AsRef` obligation. err.span_suggestion_verbose( expr.span.shrink_to_lo(), "borrow the value to avoid moving it", format!("&{}", if is_mut { "mut " } else { "" }), Applicability::MachineApplicable, ); can_suggest_clone = is_mut; } else { let mut span: MultiSpan = arg.span.into(); span.push_span_label( arg.span, "this parameter takes ownership of the value".to_string(), ); let descr = match node.fn_kind() { Some(hir::intravisit::FnKind::ItemFn(..)) | None => "function", Some(hir::intravisit::FnKind::Method(..)) => "method", Some(hir::intravisit::FnKind::Closure) => "closure", }; span.push_span_label(ident.span, format!("in this {descr}")); err.span_note( span, format!( "consider changing this parameter type in {descr} `{ident}` to  borrow instead if owning the value isn't necessary", ), ); } </ins> } let place = &self.move_data.move_paths[mpi].place; let ty = place.ty(self.body, self.infcx.tcx).ty;


} // Don't report FFI errors for unit return types. This check exists here, and not in <del> // `check_foreign_fn` (where it would make more sense) so that normalization has definitely </del> <ins> // the caller (where it would make more sense) so that normalization has definitely </ins> // happened. if is_return_type && ty.is_unit() { return;


// Computing common supertype in an if expression IfExpression(Span), <ins> // Computing common supertype of an if expression with no else counter-part IfExpressionWithNoElse(Span) </ins> } /// See `error_reporting.rs` for more details


<ins> // Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // Test that wrapping an unsized struct in an enum which gets optimised does // not ICE. struct Str { f: [u8] } fn main() { let str: Option<&Str> = None; str.is_some(); } </ins>


} } } <ins> // just tests by whether or not this compiles fn _pending_impl_all_auto_traits<T>() { use std::panic::{RefUnwindSafe, UnwindSafe}; fn all_auto_traits<T: Send + Sync + Unpin + UnwindSafe + RefUnwindSafe>() {} all_auto_traits::<std::future::Pending<T>>(); } </ins>


() => ((file!(), line!())) } <del> #[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android"), not(all(target_os = "linux", target_arch = "arm"))))] </del> macro_rules! dump_and_die { ($($pos:expr),*) => ({ // FIXME(#18285): we cannot include the current position because // the macro span takes over the last frame's file/line. <del> dump_filelines(&[$($pos),*]); panic!(); </del> <ins> if cfg!(target_os = "macos") || cfg!(target_os = "ios") || cfg!(target_os = "android") || cfg!(all(target_os = "linux", target_arch = "arm")) || cfg!(all(windows, target_env = "gnu")) { // skip these platforms as this support isn't implemented yet. } else { dump_filelines(&[$($pos),*]); panic!(); } </ins> }) } <del> // this does not work on Windows, Android, OSX or iOS #[cfg(not(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android"), not(all(target_os = "linux", target_arch = "arm")))))] macro_rules! dump_and_die { ($($pos:expr),*) => ({ let _ = [$($pos),*]; }) } </del> // we can't use a function as it will alter the backtrace macro_rules! check { ($counter:expr; $($pos:expr),*) => ({


// MACRO_RULES ITEM self.parse_item_macro_rules(vis, has_bang)? } else if self.isnt_macro_invocation() <del> && (self.token.is_ident_named(sym::import) || self.token.is_ident_named(sym::using)) </del> <ins> && (self.token.is_ident_named(sym::import) || self.token.is_ident_named(sym::using) || self.token.is_ident_named(sym::include) || self.token.is_ident_named(sym::require)) </ins> { return self.recover_import_as_use(); } else if self.isnt_macro_invocation() && vis.kind.is_pub() {


)?; write_minify("search.js", static_files::SEARCH_JS)?; write_minify("settings.js", static_files::SETTINGS_JS)?; <ins> write_minify("sidebar-items.js", static_files::sidebar::ITEMS)?; </ins> if cx.shared.include_sources { write_minify("source-script.js", static_files::sidebar::SOURCE_SCRIPT)?; }


<ins> error[E0106]: missing lifetime specifier --> $DIR/opaque-and-lifetime-mismatch.rs:5:24 | LL |     fn bar() -> Wrapper<impl Sized>; |                        ^ expected named lifetime parameter | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values | LL |     fn bar() -> Wrapper<'static, impl Sized>; |                         ++++++++ error[E0412]: cannot find type `T` in this scope --> $DIR/opaque-and-lifetime-mismatch.rs:1:22 | LL | struct Wrapper<'rom>(T); |                      ^ not found in this scope | help: you might be missing a type parameter | LL | struct Wrapper<'rom, T>(T); |                    +++ error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied --> $DIR/opaque-and-lifetime-mismatch.rs:5:17 | LL |     fn bar() -> Wrapper<impl Sized>; |                 ^^^^^^^ ---------- help: remove this generic argument |                 | |                 expected 0 generic arguments | note: struct defined here, with 0 generic parameters --> $DIR/opaque-and-lifetime-mismatch.rs:1:8 | LL | struct Wrapper<'rom>(T); |        ^^^^^^^ error[E0053]: method `bar` has an incompatible return type for trait --> $DIR/opaque-and-lifetime-mismatch.rs:11:17 | LL |     fn bar() -> i32 { |                 ^^^ |                 | |                 expected `Wrapper<'static>`, found `i32` |                 return type in trait error[E0053]: method `bar` has an incompatible type for trait --> $DIR/opaque-and-lifetime-mismatch.rs:11:17 | LL |     fn bar() -> i32 { |                 ^^^ |                 | |                 expected `Wrapper<'static>`, found `i32` |                 help: change the output type to match the trait: `Wrapper<'static>` | note: type in trait --> $DIR/opaque-and-lifetime-mismatch.rs:5:17 | LL |     fn bar() -> Wrapper<impl Sized>; |                 ^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn() -> Wrapper<'static>` found signature `fn() -> i32` error: aborting due to 5 previous errors Some errors have detailed explanations: E0053, E0106, E0107, E0412. For more information about an error, try `rustc --explain E0053`. </ins>


<ins> error[E0596]: cannot borrow `*inner` as mutable, as it is behind a `&` reference --> $DIR/issue-91206.rs:13:5 | LL |     let inner = client.get_inner_ref(); |         ----- help: consider changing this to be a mutable reference: `&mut Vec<usize>` LL | LL |     inner.clear(); |     ^^^^^^^^^^^^^ `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to previous error For more information about this error, try `rustc --explain E0596`. </ins>


use libc::types::os::arch::c95::{c_int, size_t}; pub static SIGTRAP : c_int = 5; <ins> pub static SIGPIPE: c_int = 13; pub static SIG_IGN: size_t = 1; </ins> pub static GLOB_ERR      : c_int = 1 << 0; pub static GLOB_MARK     : c_int = 1 << 1;


<ins> // edition:2021 #![feature(async_closure)] // Don't ICE in ByMove shim builder when MIR body is tainted by writeback errors fn main() { let _ = async || { used_fn(); //~^ ERROR cannot find function `used_fn` in this scope 0 }; } </ins>


<ins> error: invalid asm template string: unmatched `}` found --> $DIR/ice-bad-err-span-in-template-129503.rs:12:10 | LL |     asm!(concat!(r#"lJ𐏿Æ�.𐏿�"#, "r} {}")); |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unmatched `}` in asm template string | = note: if you intended to print `}`, you can escape it using `}}` = note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info) error: invalid asm template string: unmatched `}` found --> $DIR/ice-bad-err-span-in-template-129503.rs:18:10 | LL |     asm!(concat!("abc", "r} {}")); |          ^^^^^^^^^^^^^^^^^^^^^^^ unmatched `}` in asm template string | = note: if you intended to print `}`, you can escape it using `}}` = note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info) error: invalid asm template string: unmatched `}` found --> $DIR/ice-bad-err-span-in-template-129503.rs:24:19 | LL |     asm!("abc", "r} {}"); |                   ^ unmatched `}` in asm template string | = note: if you intended to print `}`, you can escape it using `}}` error: aborting due to 3 previous errors </ins>


} } <ins> let document_hidden = cx.render_options.document_hidden; </ins> let predicates = tcx.explicit_predicates_of(did); let (trait_items, generics) = match impl_item { Some(impl_) => ( impl_ .items .iter() <del> .map(|item| tcx.hir().impl_item(item.id).clean(cx)) </del> <ins> .map(|item| tcx.hir().impl_item(item.id)) .filter(|item| { // Filter out impl items whose corresponding trait item has `doc(hidden)` // not to document such impl items. // For inherent impls, we don't do any filtering, because that's already done in strip_hidden.rs. // When `--document-hidden-items` is passed, we don't // do any filtering, too. if document_hidden { return true; } if let Some(associated_trait) = associated_trait { let assoc_kind = match item.kind { hir::ImplItemKind::Const(..) => ty::AssocKind::Const, hir::ImplItemKind::Fn(..) => ty::AssocKind::Fn, hir::ImplItemKind::TyAlias(..) => ty::AssocKind::Type, }; let trait_item = tcx .associated_items(associated_trait.def_id) .find_by_name_and_kind( tcx, item.ident, assoc_kind, associated_trait.def_id, ) .unwrap(); // SAFETY: For all impl items there exists trait item that has the same name. !tcx.get_attrs(trait_item.def_id).lists(sym::doc).has_word(sym::hidden) } else { true } }) .map(|item| item.clean(cx)) </ins> .collect::<Vec<_>>(), impl_.generics.clean(cx), ),


match ct.ty.kind() { ty::Uint(_) => {} <ins> ty::Bool => {} </ins> _ => { bug!("symbol_names: unsupported constant of type `{}` ({:?})", ct.ty, ct); }


} #[test] <ins> fn test_buf_writer() { let mut buf = [0 as u8, ..8]; { let mut writer = BufWriter::new(buf); assert_eq!(writer.tell(), 0); writer.write([0]); assert_eq!(writer.tell(), 1); writer.write([1, 2, 3]); writer.write([4, 5, 6, 7]); assert_eq!(writer.tell(), 8); } assert_eq!(buf, [0, 1, 2, 3, 4, 5, 6, 7]); } #[test] fn test_buf_writer_seek() { let mut buf = [0 as u8, ..8]; { let mut writer = BufWriter::new(buf); assert_eq!(writer.tell(), 0); writer.write([1]); assert_eq!(writer.tell(), 1); writer.seek(2, SeekSet); assert_eq!(writer.tell(), 2); writer.write([2]); assert_eq!(writer.tell(), 3); writer.seek(-2, SeekCur); assert_eq!(writer.tell(), 1); writer.write([3]); assert_eq!(writer.tell(), 2); writer.seek(-1, SeekEnd); assert_eq!(writer.tell(), 7); writer.write([4]); assert_eq!(writer.tell(), 8); } assert_eq!(buf, [1, 3, 2, 0, 0, 0, 0, 4]); } #[test] fn test_buf_writer_error() { let mut buf = [0 as u8, ..2]; let mut writer = BufWriter::new(buf); writer.write([0]); let mut called = false; do io_error::cond.trap(|err| { assert_eq!(err.kind, OtherIoError); called = true; }).inside { writer.write([0, 0]); } assert!(called); } #[test] </ins> fn test_mem_reader() { let mut reader = MemReader::new(~[0, 1, 2, 3, 4, 5, 6, 7]); let mut buf = [];


let const_did = tcx.def_map.borrow().get_copy(&pat.id).def_id(); let const_pty = ty::lookup_item_type(tcx, const_did); fcx.write_ty(pat.id, const_pty.ty); <del> demand::eqtype(fcx, pat.span, expected, const_pty.ty); </del> <ins> demand::suptype(fcx, pat.span, expected, const_pty.ty); </ins> } ast::PatIdent(bm, ref path, ref sub) if pat_is_binding(&tcx.def_map, pat) => { let typ = fcx.local_ty(pat.span, pat.id);


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


{ continue; } <ins> // opaque types generated when desugaring an async function can have a single // use lifetime even if it is explicitly denied (Issue #77175) if let hir::Node::Item(hir::Item { kind: hir::ItemKind::OpaqueTy(ref opaque), .. }) = self.tcx.hir().get(parent_hir_id) { if opaque.origin != hir::OpaqueTyOrigin::AsyncFn { continue 'lifetimes; } // We want to do this only if the liftime identifier is already defined // in the async function that generated this. Otherwise it could be // an opaque type defined by the developer and we still want this // lint to fail compilation for p in opaque.generics.params { if defined_by.contains_key(&p.name) { continue 'lifetimes; } } } </ins> } }


// FIXME: This can be smarter and take `StorageDead` into account (which // invalidates borrows). if self.ever_borrowed_locals.contains(dest.local) <del> && self.ever_borrowed_locals.contains(src.local) </del> <ins> || self.ever_borrowed_locals.contains(src.local) </ins> { return; }


) .fold_with(&mut collector); <del> if !unnormalized_trait_sig.output().references_error() { debug_assert_ne!( collector.types.len(), 0, "expect >1 RPITITs in call to `collect_return_position_impl_trait_in_trait_tys`" ); } </del> let trait_sig = ocx.normalize(&misc_cause, param_env, unnormalized_trait_sig); trait_sig.error_reported()?; let trait_return_ty = trait_sig.output();


} pub fn ext(&mut self, ext: ArgExtension) -> &mut Self { <del> assert!(self.arg_ext == ArgExtension::None || self.arg_ext == ext); </del> <ins> assert!( self.arg_ext == ArgExtension::None || self.arg_ext == ext, "cannot set {:?} when {:?} is already set", ext, self.arg_ext ); </ins> self.arg_ext = ext; self }


} /// Adds a list of lookup paths to `cmd`'s dynamic library lookup path. <del> /// If The dylib_path_par is already set for this cmd, the old value will be overwritten! </del> <ins> /// If the dylib_path_var is already set for this cmd, the old value will be overwritten! </ins> pub fn add_dylib_path(path: Vec<PathBuf>, cmd: &mut Command) { let mut list = dylib_path(); for path in path {


#[diag(lint_supertrait_as_deref_target)] pub struct SupertraitAsDerefTarget<'a> { pub t: Ty<'a>, <del> pub target_principal: String, // pub target_principal: Binder<'a, ExistentialTraitRef<'b>>, </del> <ins> pub target_principal: PolyExistentialTraitRef<'a>, </ins> #[subdiagnostic] pub label: Option<SupertraitAsDerefTargetLabel>, }