} } } else { <del> if matches!(def_kind, DefKind::AnonConst) && tcx.features().generic_const_exprs { let hir_id = tcx.local_def_id_to_hir_id(def_id); let parent_def_id = tcx.hir().get_parent_item(hir_id); if let Some(defaulted_param_def_id) = tcx.hir().opt_const_param_default_param_def_id(hir_id) { // In `generics_of` we set the generics' parent to be our parent's parent which means that // we lose out on the predicates of our actual parent if we dont return those predicates here. // (See comment in `generics_of` for more information on why the parent shenanigans is necessary) // // struct Foo<T, const N: usize = { <T as Trait>::ASSOC }>(T) where T: Trait; //        ^^^                     ^^^^^^^^^^^^^^^^^^^^^^^ the def id we are calling //        ^^^                                             explicit_predicates_of on //        parent item we dont have set as the //        parent of generics returned by `generics_of` // // In the above code we want the anon const to have predicates in its param env for `T: Trait` // and we would be calling `explicit_predicates_of(Foo)` here let parent_preds = tcx.explicit_predicates_of(parent_def_id); // If we dont filter out `ConstArgHasType` predicates then every single defaulted const parameter // will ICE because of #106994. FIXME(generic_const_exprs): remove this when a more general solution // to #106994 is implemented. let filtered_predicates = parent_preds .predicates .into_iter() .filter(|(pred, _)| { if let ty::ClauseKind::ConstArgHasType(ct, _) = pred.kind().skip_binder() { match ct.kind() { ty::ConstKind::Param(param_const) => { let defaulted_param_idx = tcx .generics_of(parent_def_id) .param_def_id_to_index[&defaulted_param_def_id.to_def_id()]; param_const.index < defaulted_param_idx } _ => bug!( "`ConstArgHasType` in `predicates_of` that isn't a `Param` const" ), </del> <ins> if matches!(def_kind, DefKind::AnonConst) && tcx.features().generic_const_exprs && let Some(defaulted_param_def_id) = tcx.hir().opt_const_param_default_param_def_id(tcx.local_def_id_to_hir_id(def_id)) { // In `generics_of` we set the generics' parent to be our parent's parent which means that // we lose out on the predicates of our actual parent if we dont return those predicates here. // (See comment in `generics_of` for more information on why the parent shenanigans is necessary) // // struct Foo<T, const N: usize = { <T as Trait>::ASSOC }>(T) where T: Trait; //        ^^^                     ^^^^^^^^^^^^^^^^^^^^^^^ the def id we are calling //        ^^^                                             explicit_predicates_of on //        parent item we dont have set as the //        parent of generics returned by `generics_of` // // In the above code we want the anon const to have predicates in its param env for `T: Trait` // and we would be calling `explicit_predicates_of(Foo)` here let parent_def_id = tcx.local_parent(def_id); let parent_preds = tcx.explicit_predicates_of(parent_def_id); // If we dont filter out `ConstArgHasType` predicates then every single defaulted const parameter // will ICE because of #106994. FIXME(generic_const_exprs): remove this when a more general solution // to #106994 is implemented. let filtered_predicates = parent_preds .predicates .into_iter() .filter(|(pred, _)| { if let ty::ClauseKind::ConstArgHasType(ct, _) = pred.kind().skip_binder() { match ct.kind() { ty::ConstKind::Param(param_const) => { let defaulted_param_idx = tcx .generics_of(parent_def_id) .param_def_id_to_index[&defaulted_param_def_id.to_def_id()]; param_const.index < defaulted_param_idx </ins> } <del> } else { true </del> <ins> _ => bug!( "`ConstArgHasType` in `predicates_of` that isn't a `Param` const" ), </ins> } <del> }) .cloned(); return GenericPredicates { parent: parent_preds.parent, predicates: { tcx.arena.alloc_from_iter(filtered_predicates) }, }; } let parent_def_kind = tcx.def_kind(parent_def_id); if matches!(parent_def_kind, DefKind::OpaqueTy) { // In `instantiate_identity` we inherit the predicates of our parent. // However, opaque types do not have a parent (see `gather_explicit_predicates_of`), which means // that we lose out on the predicates of our actual parent if we dont return those predicates here. // // // fn foo<T: Trait>() -> impl Iterator<Output = Another<{ <T as Trait>::ASSOC }> > { todo!() } //                                                        ^^^^^^^^^^^^^^^^^^^ the def id we are calling //                                                                            explicit_predicates_of on // // In the above code we want the anon const to have predicates in its param env for `T: Trait`. // However, the anon const cannot inherit predicates from its parent since it's opaque. // // To fix this, we call `explicit_predicates_of` directly on `foo`, the parent's parent. // In the above example this is `foo::{opaque#0}` or `impl Iterator` let parent_hir_id = tcx.local_def_id_to_hir_id(parent_def_id.def_id); // In the above example this is the function `foo` let item_def_id = tcx.hir().get_parent_item(parent_hir_id); // In the above code example we would be calling `explicit_predicates_of(foo)` here return tcx.explicit_predicates_of(item_def_id); } </del> <ins> } else { true } }) .cloned(); return GenericPredicates { parent: parent_preds.parent, predicates: { tcx.arena.alloc_from_iter(filtered_predicates) }, }; </ins> } gather_explicit_predicates_of(tcx, def_id) }


<del> //@ known-bug: #118403 #![feature(generic_const_exprs)] pub struct X<const N: usize> {} impl<const Z: usize> X<Z> { pub fn y<'a, U: 'a>(&'a self) -> impl Iterator<Item = impl Iterator<Item = [u8; Z]> + '_> { (0..1).map(move |_| (0..1).map(move |_| loop {})) } } </del>


<del> //@ known-bug: #121574 #![feature(generic_const_exprs)] pub struct DimName<const N: usize> {} impl<const Z: usize> X<Z> { pub fn y<'a, U: 'a>(&'a self) -> impl Iterator<Item = impl Iterator<Item = [u8; Z]> + '_> { "0".as_bytes(move |_| (0..1).map(move |_| loop {})) } } </del>


<del> //@ known-bug: #121574 #![feature(generic_const_exprs)] impl<const Z: usize> X<Z> { pub fn y<'a, U: 'a>(&'a self) -> impl Iterator<Item = impl Iterator<Item = [u8; Z]> + '_> {} } </del>


<ins> //@ check-pass #![feature(generic_const_exprs)] //~^ WARN the feature `generic_const_exprs` is incomplete and may not be safe to use pub fn y<'a, U: 'a>() -> impl IntoIterator<Item = impl IntoIterator<Item = [u8; { 1 + 2 }]> + 'a> { [[[1, 2, 3]]] } // Make sure that the `predicates_of` for `{ 1 + 2 }` don't mention the duplicated lifetimes of // the *outer* iterator. Whether they should mention the duplicated lifetimes of the *inner* // iterator are another question, but not really something we need to answer immediately. fn main() {} </ins>


<ins> warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/double-opaque-parent-predicates.rs:3:12 | LL | #![feature(generic_const_exprs)] |            ^^^^^^^^^^^^^^^^^^^ | = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information = note: `#[warn(incomplete_features)]` on by default warning: 1 warning emitted </ins>


use std::fs::File; use std::io; use std::iter; <ins> use std::mem::ManuallyDrop; </ins> use std::path::Path; use std::slice; use std::sync::Arc;


let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names); let llmod_raw = parse_module(llcx, module_name, thin_module.data(), &diag_handler)? as *const _; let mut module = ModuleCodegen { <del> module_llvm: ModuleLlvm { llmod_raw, llcx, tm }, </del> <ins> module_llvm: ModuleLlvm { llmod_raw, llcx, tm: ManuallyDrop::new(tm) }, </ins> name: thin_module.name().to_string(), kind: ModuleKind::Regular, };


use std::any::Any; use std::ffi::CStr; use std::io::Write; <ins> use std::mem::ManuallyDrop; </ins> mod back { pub mod archive;


llcx: &'static mut llvm::Context, llmod_raw: *const llvm::Module, <del> // independent from llcx and llmod_raw, resources get disposed by drop impl tm: OwnedTargetMachine, </del> <ins> // This field is `ManuallyDrop` because it is important that the `TargetMachine` // is disposed prior to the `Context` being disposed otherwise UAFs can occur. tm: ManuallyDrop<OwnedTargetMachine>, </ins> } unsafe impl Send for ModuleLlvm {}


unsafe { let llcx = llvm::LLVMRustContextCreate(tcx.sess.fewer_names()); let llmod_raw = context::create_module(tcx, llcx, mod_name) as *const _; <del> ModuleLlvm { llmod_raw, llcx, tm: create_target_machine(tcx, mod_name) } </del> <ins> ModuleLlvm { llmod_raw, llcx, tm: ManuallyDrop::new(create_target_machine(tcx, mod_name)), } </ins> } }


unsafe { let llcx = llvm::LLVMRustContextCreate(tcx.sess.fewer_names()); let llmod_raw = context::create_module(tcx, llcx, mod_name) as *const _; <del> ModuleLlvm { llmod_raw, llcx, tm: create_informational_target_machine(tcx.sess) } </del> <ins> ModuleLlvm { llmod_raw, llcx, tm: ManuallyDrop::new(create_informational_target_machine(tcx.sess)), } </ins> } }


} }; <del> Ok(ModuleLlvm { llmod_raw, llcx, tm }) </del> <ins> Ok(ModuleLlvm { llmod_raw, llcx, tm: ManuallyDrop::new(tm) }) </ins> } }


impl Drop for ModuleLlvm { fn drop(&mut self) { unsafe { <ins> ManuallyDrop::drop(&mut self.tm); </ins> llvm::LLVMContextDispose(&mut *(self.llcx as *mut _)); } }


// current number of evaluated terminators is a power of 2. The latter gives us a cheap // way to implement exponential backoff. let span = ecx.cur_span(); <del> ecx.tcx.dcx().emit_warn(LongRunningWarn { span, item_span: ecx.tcx.span }); </del> <ins> // We store a unique number in `force_duplicate` to evade `-Z deduplicate-diagnostics`. // `new_steps` is guaranteed to be unique because `ecx.machine.num_evaluated_steps` is // always increasing. ecx.tcx.dcx().emit_warn(LongRunningWarn { span, item_span: ecx.tcx.span, force_duplicate: new_steps, }); </ins> } }


pub span: Span, #[help] pub item_span: Span, <ins> // Used for evading `-Z deduplicate-diagnostics`. pub force_duplicate: usize, </ins> } #[derive(Subdiagnostic)]


<ins> //@ check-pass #![allow(long_running_const_eval)] //@ compile-flags: -Z tiny-const-eval-limit -Z deduplicate-diagnostics=yes const FOO: () = { let mut i = 0; loop { //~^ WARN is taking a long time //~| WARN is taking a long time //~| WARN is taking a long time //~| WARN is taking a long time //~| WARN is taking a long time if i == 1000 { break; } else { i += 1; } } }; fn main() { FOO } </ins>


<ins> warning: constant evaluation is taking a long time --> $DIR/evade-deduplication-issue-118612.rs:8:5 | LL | /     loop { LL | | LL | | LL | | ...  | LL | |         } LL | |     } | |_____^ the const evaluator is currently interpreting this expression | help: the constant being evaluated --> $DIR/evade-deduplication-issue-118612.rs:6:1 | LL | const FOO: () = { | ^^^^^^^^^^^^^ warning: constant evaluation is taking a long time --> $DIR/evade-deduplication-issue-118612.rs:8:5 | LL | /     loop { LL | | LL | | LL | | ...  | LL | |         } LL | |     } | |_____^ the const evaluator is currently interpreting this expression | help: the constant being evaluated --> $DIR/evade-deduplication-issue-118612.rs:6:1 | LL | const FOO: () = { | ^^^^^^^^^^^^^ warning: constant evaluation is taking a long time --> $DIR/evade-deduplication-issue-118612.rs:8:5 | LL | /     loop { LL | | LL | | LL | | ...  | LL | |         } LL | |     } | |_____^ the const evaluator is currently interpreting this expression | help: the constant being evaluated --> $DIR/evade-deduplication-issue-118612.rs:6:1 | LL | const FOO: () = { | ^^^^^^^^^^^^^ warning: constant evaluation is taking a long time --> $DIR/evade-deduplication-issue-118612.rs:8:5 | LL | /     loop { LL | | LL | | LL | | ...  | LL | |         } LL | |     } | |_____^ the const evaluator is currently interpreting this expression | help: the constant being evaluated --> $DIR/evade-deduplication-issue-118612.rs:6:1 | LL | const FOO: () = { | ^^^^^^^^^^^^^ warning: constant evaluation is taking a long time --> $DIR/evade-deduplication-issue-118612.rs:8:5 | LL | /     loop { LL | | LL | | LL | | ...  | LL | |         } LL | |     } | |_____^ the const evaluator is currently interpreting this expression | help: the constant being evaluated --> $DIR/evade-deduplication-issue-118612.rs:6:1 | LL | const FOO: () = { | ^^^^^^^^^^^^^ warning: 5 warnings emitted </ins>


} .item-info .stab { <del> /* This min-height is needed to unify the height of the stab elements because some of them have emojis. */ min-height: 36px; display: flex; </del> <ins> display: block; </ins> padding: 3px; margin-bottom: 5px; <del> align-items: center; vertical-align: text-bottom; </del> } .item-name .stab { margin-left: 0.3125em;


color: var(--stab-code-color); } <del> .stab .emoji { </del> <ins> .stab .emoji, .item-info .stab::before { </ins> font-size: 1.25rem; <ins> } .stab .emoji { </ins> margin-right: 0.3rem; } <ins> .item-info .stab::before { /* ensure badges with emoji and without it have same height */ content: "0"; width: 0; display: inline-block; color: transparent; } </ins> /* Black one-pixel outline around emoji shapes */ .emoji { text-shadow: 1px 0 0 black, -1px 0 0 black, <del> 0  1px 0 black, </del> <ins> 0 1px 0 black, </ins> 0 -1px 0 black; }


assert-size: (".item-info .stab", {"width": 289}) assert-position: (".item-info .stab", {"x": 245}) <ins> // We check that the display of the feature elements is not broken. It serves as regression // test for <https://github.com/rust-lang/rust/issues/118615>. set-window-size: (850, 800) store-position: ( "//*[@class='stab portability']//code[text()='Win32_System']", {"x": first_line_x, "y": first_line_y}, ) store-position: ( "//*[@class='stab portability']//code[text()='Win32_System_Diagnostics']", {"x": second_line_x, "y": second_line_y}, ) assert: |first_line_x| != |second_line_x| && |first_line_x| == 516 && |second_line_x| == 272 assert: |first_line_y| != |second_line_y| && |first_line_y| == 688 && |second_line_y| == 711 </ins> // Now we ensure that they're not rendered on the same line. <ins> set-window-size: (1100, 800) </ins> go-to: "file://" + |DOC_PATH| + "/lib2/trait.Trait.html" // We first ensure that there are two item info on the trait. assert-count: ("#main-content > .item-info .stab", 2)


[lib] path = "lib.rs" <ins> [features] Win32 = ["Win32_System"] Win32_System = ["Win32_System_Diagnostics"] Win32_System_Diagnostics = ["Win32_System_Diagnostics_Debug"] Win32_System_Diagnostics_Debug = [] default = ["Win32"] </ins> [dependencies] implementors = { path = "./implementors" } http = { path = "./http" }


// ignore-tidy-linelength #![feature(doc_cfg)] <ins> #![feature(doc_auto_cfg)] </ins> pub mod another_folder; pub mod another_mod;


/// Some documentation /// # A Heading pub fn a_method(&self) {} <ins> #[cfg(all( feature = "Win32", feature = "Win32_System", feature = "Win32_System_Diagnostics", feature = "Win32_System_Diagnostics_Debug" ))] pub fn lot_of_features() {} </ins> } #[doc(cfg(feature = "foo-method"))]


return; } }; <del> let (sig, map) = tcx.instantiate_bound_regions(sig, |br| { </del> <ins> let (unnormalized_sig, map) = tcx.instantiate_bound_regions(sig, |br| { </ins> use crate::renumber::RegionCtxt; let region_ctxt_fn = || {


region_ctxt_fn, ) }); <del> debug!(?sig); </del> <ins> debug!(?unnormalized_sig); </ins> // IMPORTANT: We have to prove well formed for the function signature before // we normalize it, as otherwise types like `<&'a &'b () as Trait>::Assoc` // get normalized away, causing us to ignore the `'b: 'a` bound used by the function.


// // See #91068 for an example. self.prove_predicates( <del> sig.inputs_and_output.iter().map(|ty| { </del> <ins> unnormalized_sig.inputs_and_output.iter().map(|ty| { </ins> ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed( ty.into(), )))


term_location.to_locations(), ConstraintCategory::Boring, ); <del> let sig = self.normalize(sig, term_location); </del> <ins> let sig = self.normalize(unnormalized_sig, term_location); // HACK(#114936): `WF(sig)` does not imply `WF(normalized(sig))` // with built-in `Fn` implementations, since the impl may not be // well-formed itself. if sig != unnormalized_sig { self.prove_predicates( sig.inputs_and_output.iter().map(|ty| { ty::Binder::dummy(ty::PredicateKind::Clause( ty::ClauseKind::WellFormed(ty.into()), )) }), term_location.to_locations(), ConstraintCategory::Boring, ); } </ins> self.check_call_dest(body, term, &sig, *destination, *target, term_location); // The ordinary liveness rules will ensure that all


<ins> // <https://github.com/rust-lang/rust/issues/114936> fn whoops( s: String, f: impl for<'s> FnOnce(&'s str) -> (&'static str, [&'static &'s (); 0]), ) -> &'static str { f(&s).0 //~^ ERROR `s` does not live long enough } // <https://github.com/rust-lang/rust/issues/118876> fn extend<T>(input: &T) -> &'static T { struct Bounded<'a, 'b: 'static, T>(&'a T, [&'b (); 0]); let n: Box<dyn FnOnce(&T) -> Bounded<'static, '_, T>> = Box::new(|x| Bounded(x, [])); n(input).0 //~^ ERROR borrowed data escapes outside of function } // <https://github.com/rust-lang/rust/issues/118876> fn extend_mut<'a, T>(input: &'a mut T) -> &'static mut T { struct Bounded<'a, 'b: 'static, T>(&'a mut T, [&'b (); 0]); let mut n: Box<dyn FnMut(&mut T) -> Bounded<'static, '_, T>> = Box::new(|x| Bounded(x, [])); n(input).0 //~^ ERROR borrowed data escapes outside of function } fn main() {} </ins>


<ins> error[E0597]: `s` does not live long enough --> $DIR/check-normalized-sig-for-wf.rs:7:7 | LL |     s: String, |     - binding `s` declared here ... LL |     f(&s).0 |     --^^- |     | | |     | borrowed value does not live long enough |     argument requires that `s` is borrowed for `'static` LL | LL | } | - `s` dropped here while still borrowed error[E0521]: borrowed data escapes outside of function --> $DIR/check-normalized-sig-for-wf.rs:15:5 | LL | fn extend<T>(input: &T) -> &'static T { |              -----  - let's call the lifetime of this reference `'1` |              | |              `input` is a reference that is only valid in the function body ... LL |     n(input).0 |     ^^^^^^^^ |     | |     `input` escapes the function body here |     argument requires that `'1` must outlive `'static` error[E0521]: borrowed data escapes outside of function --> $DIR/check-normalized-sig-for-wf.rs:23:5 | LL | fn extend_mut<'a, T>(input: &'a mut T) -> &'static mut T { |               --     ----- `input` is a reference that is only valid in the function body |               | |               lifetime `'a` defined here ... LL |     n(input).0 |     ^^^^^^^^ |     | |     `input` escapes the function body here |     argument requires that `'a` must outlive `'static` error: aborting due to 3 previous errors Some errors have detailed explanations: E0521, E0597. For more information about an error, try `rustc --explain E0521`. </ins>


id: NodeId, parent_prefix: &[Segment], nested: bool, <ins> list_stem: bool, </ins> // The whole `use` item item: &Item, vis: ty::Visibility,


parent_prefix, use_tree, nested ); <del> if nested { </del> <ins> // Top level use tree reuses the item's id and list stems reuse their parent // use tree's ids, so in both cases their visibilities are already filled. if nested && !list_stem { </ins> self.r.feed_visibility(self.r.local_def_id(id), vis); }


for &(ref tree, id) in items { self.build_reduced_graph_for_use_tree( // This particular use tree <del> tree, id, &prefix, true, // The whole `use` item </del> <ins> tree, id, &prefix, true, false, // The whole `use` item </ins> item, vis, root_span, ); }


id, &prefix, true, <ins> true, </ins> // The whole `use` item item, ty::Visibility::Restricted(


item.id, &[], false, <ins> false, </ins> // The whole `use` item item, vis,


<ins> // check-pass // edition: 2018 mod outer { mod inner { pub mod inner2 {} } pub(crate) use inner::{}; pub(crate) use inner::{{}}; pub(crate) use inner::{inner2::{}}; pub(crate) use inner::{inner2::{{}}}; } fn main() {} </ins>


/// Whether the layout is from a type that implements [`std::marker::PointerLike`]. /// /// Currently, that means that the type is pointer-sized, pointer-aligned, <del> /// and has a scalar ABI. </del> <ins> /// and has a initialized (non-union), scalar ABI. </ins> pub fn is_pointer_like(self, data_layout: &TargetDataLayout) -> bool { self.size() == data_layout.pointer_size && self.align().abi == data_layout.pointer_align.abi <del> && matches!(self.abi(), Abi::Scalar(..)) </del> <ins> && matches!(self.abi(), Abi::Scalar(Scalar::Initialized { .. })) </ins> } }


<ins> #![feature(dyn_star)] //~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes union Union { x: usize, } trait Trait {} impl Trait for Union {} fn bar(_: dyn* Trait) {} fn main() { bar(Union { x: 0usize }); //~^ ERROR `Union` needs to have the same ABI as a pointer } </ins>


<ins> warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/union.rs:1:12 | LL | #![feature(dyn_star)] |            ^^^^^^^^ | = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information = note: `#[warn(incomplete_features)]` on by default error[E0277]: `Union` needs to have the same ABI as a pointer --> $DIR/union.rs:14:9 | LL |     bar(Union { x: 0usize }); |         ^^^^^^^^^^^^^^^^^^^ `Union` needs to be a pointer-like type | = help: the trait `PointerLike` is not implemented for `Union` error: aborting due to 1 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0277`. </ins>


- [wasm32-wasip1](platform-support/wasm32-wasip1.md) - [wasm32-wasip1-threads](platform-support/wasm32-wasip1-threads.md) - [wasm32-wasip2](platform-support/wasm32-wasip2.md) <ins> - [wasm32-unknown-unknown](platform-support/wasm32-unknown-unknown.md) </ins> - [wasm64-unknown-unknown](platform-support/wasm64-unknown-unknown.md) - [*-win7-windows-msvc](platform-support/win7-windows-msvc.md) - [x86_64-fortanix-unknown-sgx](platform-support/x86_64-fortanix-unknown-sgx.md)


[`thumbv8m.main-none-eabi`](platform-support/thumbv8m.main-none-eabi.md) | * | Bare Armv8-M Mainline [`thumbv8m.main-none-eabihf`](platform-support/thumbv8m.main-none-eabi.md) | * | Bare Armv8-M Mainline, hardfloat `wasm32-unknown-emscripten` | ✓ | WebAssembly via Emscripten <del> `wasm32-unknown-unknown` | ✓ | WebAssembly </del> <ins> [`wasm32-unknown-unknown`](platform-support/wasm32-unknown-unknown.md) | ✓ | WebAssembly </ins> `wasm32-wasi` | ✓ | WebAssembly with WASI (undergoing a [rename to `wasm32-wasip1`][wasi-rename]) [`wasm32-wasip1`](platform-support/wasm32-wasip1.md) | ✓ | WebAssembly with WASI [`wasm32-wasip1-threads`](platform-support/wasm32-wasip1-threads.md) | ✓ | WebAssembly with WASI Preview 1 and threads


<ins> # `wasm32-unknown-unknown` **Tier: 2** The `wasm32-unknown-unknown` target is a WebAssembly compilation target which does not import any functions from the host for the standard library. This is the "minimal" WebAssembly in the sense of making the fewest assumptions about the host environment. This target is often used when compiling to the web or JavaScript environments as there is no standard for what functions can be imported on the web. This target can also be useful for creating minimal or bare-bones WebAssembly binaries. The `wasm32-unknown-unknown` target has support for the Rust standard library but many parts of the standard library do not work and return errors. For example `println!` does nothing, `std::fs` always return errors, and `std::thread::spawn` will panic. There is no means by which this can be overridden. For a WebAssembly target that more fully supports the standard library see the [`wasm32-wasip1`](./wasm32-wasip1.md) or [`wasm32-wasip2`](./wasm32-wasip2.md) targets. The `wasm32-unknown-unknown` target has full support for the `core` and `alloc` crates. It additionally supports the `HashMap` type in the `std` crate, although hash maps are not randomized like they are on other platforms. One existing user of this target (please feel free to edit and expand this list too) is the [`wasm-bindgen` project](https://github.com/rustwasm/wasm-bindgen) which facilitates Rust code interoperating with JavaScript code. Note, though, that not all uses of `wasm32-unknown-unknown` are using JavaScript and the web. ## Target maintainers When this target was added to the compiler platform-specific documentation here was not maintained at that time. This means that the list below is not exhaustive and there are more interested parties in this target. That being said since when this document was last updated those interested in maintaining this target are: - Alex Crichton, https://github.com/alexcrichton ## Requirements This target is cross-compiled. The target includes support for `std` itself, but as mentioned above many pieces of functionality that require an operating system do not work and will return errors. This target currently has no equivalent in C/C++. There is no C/C++ toolchain for this target. While interop is theoretically possible it's recommended to instead use one of: * `wasm32-unknown-emscripten` - for web-based use cases the Emscripten toolchain is typically chosen for running C/C++. * [`wasm32-wasip1`](./wasm32-wasip1.md) - the wasi-sdk toolchain is used to compile C/C++ on this target and can interop with Rust code. WASI works on the web so far as there's no blocker, but an implementation of WASI APIs must be either chosen or reimplemented. This target has no build requirements beyond what's in-tree in the Rust repository. Linking binaries requires LLD to be enabled for the `wasm-ld` driver. This target uses the `dlmalloc` crate as the default global allocator. ## Building the target Building this target can be done by: * Configure the `wasm32-unknown-unknown` target to get built. * Configure LLD to be built. * Ensure the `WebAssembly` target backend is not disabled in LLVM. These are all controlled through `config.toml` options. It should be possible to build this target on any platform. ## Building Rust programs Rust programs can be compiled by adding this target via rustup: ```sh $ rustup target add wasm32-unknown-unknown ``` and then compiling with the target: ```sh $ rustc foo.rs --target wasm32-unknown-unknown $ file foo.wasm ``` ## Cross-compilation This target can be cross-compiled from any host. ## Testing This target is not tested in CI for the rust-lang/rust repository. Many tests must be disabled to run on this target and failures are non-obvious because `println!` doesn't work in the standard library. It's recommended to test the `wasm32-wasip1` target instead for WebAssembly compatibility. ## Conditionally compiling code It's recommended to conditionally compile code for this target with: ```text #[cfg(all(target_family = "wasm", target_os = "unknown"))] ``` Note that there is no way to tell via `#[cfg]` whether code will be running on the web or not. ## Enabled WebAssembly features WebAssembly is an evolving standard which adds new features such as new instructions over time. This target's default set of supported WebAssembly features will additionally change over time. The `wasm32-unknown-unknown` target inherits the default settings of LLVM which typically matches the default settings of Emscripten as well. Changes to WebAssembly go through a [proposals process][proposals] but reaching the final stage (stage 5) does not automatically mean that the feature will be enabled in LLVM and Rust by default. At this time the general guidance is that features must be present in most engines for a "good chunk of time" before they're enabled in LLVM by default. There is currently no exact number of months or engines that are required to enable features by default. [proposals]: https://github.com/WebAssembly/proposals As of the time of this writing the proposals that are enabled by default (the `generic` CPU in LLVM terminology) are: * `multivalue` * `mutable-globals` * `reference-types` * `sign-ext` If you're compiling WebAssembly code for an engine that does not support a feature in LLVM's default feature set then the feature must be disabled at compile time. Note, though, that enabled features may be used in the standard library or precompiled libraries shipped via rustup. This means that not only does your own code need to be compiled with the correct set of flags but the Rust standard library additionally must be recompiled. Compiling all code for the initial release of WebAssembly looks like: ```sh $ export RUSTFLAGS=-Ctarget-cpu=mvp $ cargo +nightly build -Zbuild-std=panic_abort,std --target wasm32-unknown-unknown ``` Here the `mvp` "cpu" is a placeholder in LLVM for disabling all supported features by default. Cargo's `-Zbuild-std` feature, a Nightly Rust feature, is then used to recompile the standard library in addition to your own code. This will produce a binary that uses only the original WebAssembly features by default and no proposals since its inception. To enable individual features it can be done with `-Ctarget-feature=+foo`. Available features for Rust code itself are documented in the [reference] and can also be found through: ```sh $ rustc -Ctarget-feature=help --target wasm32-unknown-unknown ``` You'll need to consult your WebAssembly engine's documentation to learn more about the supported WebAssembly features the engine has. [reference]: https://doc.rust-lang.org/reference/attributes/codegen.html#wasm32-or-wasm64 Note that it is still possible for Rust crates and libraries to enable WebAssembly features on a per-function level. This means that the build command above may not be sufficient to disable all WebAssembly features. If the final binary still has SIMD instructions, for example, the function in question will need to be found and the crate in question will likely contain something like: ```rust,ignore (not-always-compiled-to-wasm) #[target_feature(enable = "simd128")] fn foo() { // ... } ``` In this situation there is no compiler flag to disable emission of SIMD instructions and the crate must instead be modified to not include this function at compile time either by default or through a Cargo feature. For crate authors it's recommended to avoid `#[target_feature(enable = "...")]` except where necessary and instead use: ```rust,ignore (not-always-compiled-to-wasm) #[cfg(target_feature = "simd128")] fn foo() { // ... } ``` That is to say instead of enabling target features it's recommended to conditionally compile code instead. This is notably different to the way native platforms such as x86_64 work, and this is due to the fact that WebAssembly binaries must only contain code the engine understands. Native binaries work so long as the CPU doesn't execute unknown code dynamically at runtime. </ins>


Prior to Rust 1.80 the `target_env = "p1"` key was not set. Currently the `target_feature = "atomics"` is Nightly-only. Note that the precise `#[cfg]` necessary to detect this target may change as the target becomes more stable. <ins> ## Enabled WebAssembly features The default set of WebAssembly features enabled for compilation includes two more features in addition to that which [`wasm32-unknown-unknown`](./wasm32-unknown-unknown.md) enables: * `bulk-memory` * `atomics` For more information about features see the documentation for [`wasm32-unknown-unknown`](./wasm32-unknown-unknown.md), but note that the `mvp` CPU in LLVM does not support this target as it's required that `bulk-memory`, `atomics`, and `mutable-globals` are all enabled. </ins>


Note that the `target_env = "p1"` condition first appeared in Rust 1.80. Prior to Rust 1.80 the `target_env` condition was not set. <ins> ## Enabled WebAssembly features The default set of WebAssembly features enabled for compilation is currently the same as [`wasm32-unknown-unknown`](./wasm32-unknown-unknown.md). See the documentation there for more information. </ins>


```text #[cfg(all(target_os = "wasi", target_env = "p2"))] ``` <ins> ## Enabled WebAssembly features The default set of WebAssembly features enabled for compilation is currently the same as [`wasm32-unknown-unknown`](./wasm32-unknown-unknown.md). See the documentation there for more information. </ins>


| ProjectionElem::Subtype(_) | ProjectionElem::Downcast(_, _) | ProjectionElem::Field(_, _) => { <del> write!(fmt, "(").unwrap(); </del> <ins> write!(fmt, "(")?; </ins> } ProjectionElem::Deref => { <del> write!(fmt, "(*").unwrap(); </del> <ins> write!(fmt, "(*")?; </ins> } ProjectionElem::Index(_) | ProjectionElem::ConstantIndex { .. }


// but there's already an item with the same namespace and same name. Rust gives // priority to the not-imported one, so we should, too. items.extend(doc.items.values().flat_map(|(item, renamed, import_id)| { <del> // First, lower everything other than imports. </del> <ins> // First, lower everything other than glob imports. </ins> if matches!(item.kind, hir::ItemKind::Use(_, hir::UseKind::Glob)) { return Vec::new(); }


use rustc_hir::HirId; use rustc_lint_defs::Applicability; use rustc_resolve::rustdoc::source_span_for_markdown_range; <ins> use rustc_span::def_id::DefId; </ins> use rustc_span::Symbol; use crate::clean::utils::find_nearest_parent_module;


return; } <del> if item.link_names(&cx.cache).is_empty() { // If there's no link names in this item, // then we skip resolution querying to // avoid from panicking. return; </del> <ins> if let Some(item_id) = item.def_id() { check_redundant_explicit_link_for_did(cx, item, item_id, hir_id, &doc); </ins> } <ins> if let Some(item_id) = item.inline_stmt_id { check_redundant_explicit_link_for_did(cx, item, item_id, hir_id, &doc); } } </ins> <del> let Some(item_id) = item.def_id() else { return; }; let Some(local_item_id) = item_id.as_local() else { </del> <ins> fn check_redundant_explicit_link_for_did<'md>( cx: &DocContext<'_>, item: &Item, did: DefId, hir_id: HirId, doc: &'md str, ) { let Some(local_item_id) = did.as_local() else { </ins> return; };


return; } let is_private = !cx.render_options.document_private <del> && !cx.cache.effective_visibilities.is_directly_public(cx.tcx, item_id); </del> <ins> && !cx.cache.effective_visibilities.is_directly_public(cx.tcx, did); </ins> if is_private { return; } <del> check_redundant_explicit_link(cx, item, hir_id, &doc); </del> <ins> let module_id = match cx.tcx.def_kind(did) { DefKind::Mod if item.inner_docs(cx.tcx) => did, _ => find_nearest_parent_module(cx.tcx, did).unwrap(), }; let Some(resolutions) = cx.tcx.resolutions(()).doc_link_resolutions.get(&module_id.expect_local()) else { // If there's no resolutions in this module, // then we skip resolution querying to // avoid from panicking. return; }; check_redundant_explicit_link(cx, item, hir_id, &doc, &resolutions); </ins> } fn check_redundant_explicit_link<'md>(


item: &Item, hir_id: HirId, doc: &'md str, <ins> resolutions: &DocLinkResMap, </ins> ) -> Option<()> { let mut broken_line_callback = |link: BrokenLink<'md>| Some((link.reference, "".into())); let mut offset_iter = Parser::new_with_broken_link_callback(


Some(&mut broken_line_callback), ) .into_offset_iter(); <del> let item_id = item.def_id()?; let module_id = match cx.tcx.def_kind(item_id) { DefKind::Mod if item.inner_docs(cx.tcx) => item_id, _ => find_nearest_parent_module(cx.tcx, item_id).unwrap(), }; let resolutions = cx.tcx.doc_link_resolutions(module_id); </del> while let Some((event, link_range)) = offset_iter.next() { match event {


<ins> // compile-flags: --document-private-items #![deny(rustdoc::redundant_explicit_links)] mod webdavfs { pub struct A; pub struct B; } /// [`Vfs`][crate::Vfs] pub use webdavfs::A; //~^^ error: redundant explicit link target /// [`Vfs`] pub use webdavfs::B; pub struct Vfs; </ins>


<ins> error: redundant explicit link target --> $DIR/issue-120444-1.rs:10:13 | LL | /// [`Vfs`][crate::Vfs] |      -----  ^^^^^^^^^^ explicit target is redundant |      | |      because label contains path that resolves to same destination | = note: when a link's destination is not specified, the label is used to resolve intra-doc links note: the lint level is defined here --> $DIR/issue-120444-1.rs:3:9 | LL | #![deny(rustdoc::redundant_explicit_links)] |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove explicit link target | LL | /// [`Vfs`] |     ~~~~~~~ error: aborting due to 1 previous error </ins>


<ins> // compile-flags: --document-private-items #![deny(rustdoc::redundant_explicit_links)] pub mod webdavfs { pub struct A; pub struct B; } /// [`Vfs`][crate::Vfs] pub use webdavfs::A; //~^^ error: redundant explicit link target /// [`Vfs`] pub use webdavfs::B; pub struct Vfs; </ins>


<ins> error: redundant explicit link target --> $DIR/issue-120444-2.rs:10:13 | LL | /// [`Vfs`][crate::Vfs] |      -----  ^^^^^^^^^^ explicit target is redundant |      | |      because label contains path that resolves to same destination | = note: when a link's destination is not specified, the label is used to resolve intra-doc links note: the lint level is defined here --> $DIR/issue-120444-2.rs:3:9 | LL | #![deny(rustdoc::redundant_explicit_links)] |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove explicit link target | LL | /// [`Vfs`] |     ~~~~~~~ error: aborting due to 1 previous error </ins>


"arch": "x86_64", "cpu": "x86-64", "crt-static-respected": true, <del> "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", </del> <ins> "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", </ins> "dynamic-linking": true, "env": "gnu", "has-rpath": true,


"arch": "x86_64", "cpu": "x86-64", "crt-static-respected": true, <del> "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", </del> <ins> "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", </ins> "dynamic-linking": true, "env": "gnu", "executables": true,


{ <del> "data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128", </del> <ins> "data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128", </ins> "linker-flavor": "gcc", "llvm-target": "i686-unknown-linux-gnu", "target-endian": "little",


{ "pre-link-args": {"gcc": ["-m64"]}, <del> "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", </del> <ins> "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", </ins> "linker-flavor": "gcc", "llvm-target": "x86_64-unknown-linux-gnu", "target-endian": "little",


} } <del> fn install_llvm_file(builder: &Builder<'_>, source: &Path, destination: &Path) { </del> <ins> fn install_llvm_file( builder: &Builder<'_>, source: &Path, destination: &Path, install_symlink: bool, ) { </ins> if builder.config.dry_run() { return; } <del> builder.install(source, destination, 0o644); </del> <ins> if source.is_symlink() { // If we have a symlink like libLLVM-18.so -> libLLVM.so.18.1, install the target of the // symlink, which is what will actually get loaded at runtime. builder.install(&t!(fs::canonicalize(source)), destination, 0o644); if install_symlink { // If requested, also install the symlink. This is used by download-ci-llvm. let full_dest = destination.join(source.file_name().unwrap()); builder.copy(&source, &full_dest); } } else { builder.install(&source, destination, 0o644); } </ins> } /// Maybe add LLVM object files to the given destination lib-dir. Allows either static or dynamic linking. /// /// Returns whether the files were actually copied. <del> fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir: &Path) -> bool { </del> <ins> fn maybe_install_llvm( builder: &Builder<'_>, target: TargetSelection, dst_libdir: &Path, install_symlink: bool, ) -> bool { </ins> // If the LLVM was externally provided, then we don't currently copy // artifacts into the sysroot. This is not necessarily the right // choice (in particular, it will require the LLVM dylib to be in


} else { PathBuf::from(file) }; <del> install_llvm_file(builder, &file, dst_libdir); </del> <ins> install_llvm_file(builder, &file, dst_libdir, install_symlink); </ins> } !builder.config.dry_run() } else {


// dynamically linked; it is already included into librustc_llvm // statically. if builder.llvm_link_shared() { <del> maybe_install_llvm(builder, target, &dst_libdir); </del> <ins> maybe_install_llvm(builder, target, &dst_libdir, false); </ins> } }


let mut tarball = Tarball::new(builder, "rust-dev", &target.triple); tarball.set_overlay(OverlayKind::LLVM); <ins> // LLVM requires a shared object symlink to exist on some platforms. tarball.permit_symlinks(true); </ins> builder.ensure(crate::core::build_steps::llvm::Llvm { target });


// of `rustc-dev` to support the inherited `-lLLVM` when using the // compiler libraries. let dst_libdir = tarball.image_dir().join("lib"); <del> maybe_install_llvm(builder, target, &dst_libdir); </del> <ins> maybe_install_llvm(builder, target, &dst_libdir, true); </ins> let link_type = if builder.llvm_link_shared() { "dynamic" } else { "static" }; t!(std::fs::write(tarball.image_dir().join("link-type.txt"), link_type), dst_libdir);


let out_dir = builder.llvm_out(target); let mut llvm_config_ret_dir = builder.llvm_out(builder.config.build); <del> if (!builder.config.build.is_msvc() || builder.ninja()) && !builder.config.llvm_from_ci { llvm_config_ret_dir.push("build"); } </del> llvm_config_ret_dir.push("bin"); let build_llvm_config = llvm_config_ret_dir.join(exe("llvm-config", builder.config.build)); let llvm_cmake_dir = out_dir.join("lib/cmake/llvm");


<del> Subproject commit 9ea7f739f257b049a65deeb1f2455bb2ea021cfa </del> <ins> Subproject commit 7973f3560287d750500718314a0fd4025bd8ac0e </ins>


})?; let libdir = env.build_artifacts().join("stage2").join("lib"); <del> let llvm_lib = io::find_file_in_dir(&libdir, "libLLVM", ".so")?; </del> <ins> // The actual name will be something like libLLVM.so.18.1-rust-dev. let llvm_lib = io::find_file_in_dir(&libdir, "libLLVM.so", "")?; </ins> log::info!("Optimizing {llvm_lib} with BOLT");


resolve_consider_marking_as_pub = consider marking `{$ident}` as `pub` in the imported module <ins> resolve_consider_move_macro_position = consider moving the definition of `{$ident}` before this call </ins> resolve_const_not_member_of_trait = const `{$const_}` is not a member of trait `{$trait_}` .label = not a member of trait `{$trait_}`


attempt to use a non-constant value in a constant .suggestion = try using `Self` <ins> resolve_macro_defined_later = a macro with the same name exists, but it appears later at here </ins> resolve_macro_expected_found = expected {$expected}, found {$found} `{$macro_path}`


use thin_vec::{thin_vec, ThinVec}; use crate::errors::{AddedMacroUse, ChangeImportBinding, ChangeImportBindingSuggestion}; <del> use crate::errors::{ConsiderAddingADerive, ExplicitUnsafeTraits, MaybeMissingMacroRulesName}; </del> <ins> use crate::errors::{ ConsiderAddingADerive, ExplicitUnsafeTraits, MacroDefinedLater, MacroSuggMovePosition, MaybeMissingMacroRulesName, }; </ins> use crate::imports::{Import, ImportKind}; use crate::late::{PatternSource, Rib}; use crate::{errors as errs, BindingKey};


return; } <ins> let unused_macro = self.unused_macros.iter().find_map(|(def_id, (_, unused_ident))| { if unused_ident.name == ident.name { Some((def_id.clone(), unused_ident.clone())) } else { None } }); if let Some((def_id, unused_ident)) = unused_macro { let scope = self.local_macro_def_scopes[&def_id]; let parent_nearest = parent_scope.module.nearest_parent_mod(); if Some(parent_nearest) == scope.opt_def_id() { err.subdiagnostic(self.dcx(), MacroDefinedLater { span: unused_ident.span }); err.subdiagnostic(self.dcx(), MacroSuggMovePosition { span: ident.span, ident }); return; } } </ins> if self.macro_names.contains(&ident.normalize_to_macros_2_0()) { err.subdiagnostic(self.dcx(), AddedMacroUse); return;


} #[derive(Subdiagnostic)] <ins> #[note(resolve_macro_defined_later)] pub(crate) struct MacroDefinedLater { #[primary_span] pub(crate) span: Span, } #[derive(Subdiagnostic)] #[label(resolve_consider_move_macro_position)] pub(crate) struct MacroSuggMovePosition { #[primary_span] pub(crate) span: Span, pub(crate) ident: Ident, } #[derive(Subdiagnostic)] </ins> #[note(resolve_missing_macro_rules_name)] pub(crate) struct MaybeMissingMacroRulesName { #[primary_span]


<ins> mod demo { fn hello() { something_later!(); //~ ERROR cannot find macro `something_later` in this scope } macro_rules! something_later { () => { println!("successfully expanded!"); }; } } fn main() {} </ins>


<ins> error: cannot find macro `something_later` in this scope --> $DIR/defined-later-issue-121061-2.rs:3:9 | LL |         something_later!(); |         ^^^^^^^^^^^^^^^ consider moving the definition of `something_later` before this call | note: a macro with the same name exists, but it appears later at here --> $DIR/defined-later-issue-121061-2.rs:6:18 | LL |     macro_rules! something_later { |                  ^^^^^^^^^^^^^^^ error: aborting due to 1 previous error </ins>


<ins> fn main() { something_later!(); //~ ERROR cannot find macro `something_later` in this scope } macro_rules! something_later { () => { println!("successfully expanded!"); }; } </ins>


<ins> error: cannot find macro `something_later` in this scope --> $DIR/defined-later-issue-121061.rs:2:5 | LL |     something_later!(); |     ^^^^^^^^^^^^^^^ consider moving the definition of `something_later` before this call | note: a macro with the same name exists, but it appears later at here --> $DIR/defined-later-issue-121061.rs:5:14 | LL | macro_rules! something_later { |              ^^^^^^^^^^^^^^^ error: aborting due to 1 previous error </ins>


ItemId { owner_id: self.owner_id } } <ins> /// Check if this is an [`ItemKind::Enum`], [`ItemKind::Struct`] or /// [`ItemKind::Union`]. pub fn is_adt(&self) -> bool { matches!(self.kind, ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..)) } </ins> expect_methods_self_kind! { expect_extern_crate, Option<Symbol>, ItemKind::ExternCrate(s), *s;


hir_analysis_invalid_union_field_sugg = wrap the field type in `ManuallyDrop<...>` <ins> hir_analysis_invalid_unnamed_field_ty = unnamed fields can only have struct or union types </ins> hir_analysis_late_bound_const_in_apit = `impl Trait` can only mention const parameters from an fn or impl .label = const parameter declared here


for field in variant.fields.iter().filter(|f| f.is_unnamed()) { let field_ty = tcx.type_of(field.did).instantiate_identity(); if let Some(adt) = field_ty.ty_adt_def() <del> && !adt.is_anonymous() && !adt.repr().c() </del> <ins> && !adt.is_enum() </ins> { <del> let field_ty_span = tcx.def_span(adt.did()); tcx.dcx().emit_err(errors::UnnamedFieldsRepr::FieldMissingReprC { span: tcx.def_span(field.did), field_ty_span, field_ty, field_adt_kind: adt.descr(), sugg_span: field_ty_span.shrink_to_lo(), }); </del> <ins> if !adt.is_anonymous() && !adt.repr().c() { let field_ty_span = tcx.def_span(adt.did()); tcx.dcx().emit_err(errors::UnnamedFieldsRepr::FieldMissingReprC { span: tcx.def_span(field.did), field_ty_span, field_ty, field_adt_kind: adt.descr(), sugg_span: field_ty_span.shrink_to_lo(), }); } } else { tcx.dcx().emit_err(errors::InvalidUnnamedFieldTy { span: tcx.def_span(field.did) }); </ins> } } }


} } hir::TyKind::Path(hir::QPath::Resolved(_, hir::Path { res, .. })) => { <del> self.check_field_in_nested_adt(self.tcx.adt_def(res.def_id()), field.span); </del> <ins> // If this is a direct path to an ADT, we can check it // If this is a type alias or non-ADT, `check_unnamed_fields` should verify it if let Some(def_id) = res.opt_def_id() && let Some(local) = def_id.as_local() && let Node::Item(item) = self.tcx.hir_node_by_def_id(local) && item.is_adt() { self.check_field_in_nested_adt(self.tcx.adt_def(def_id), field.span); } </ins> } // Abort due to errors (there must be an error if an unnamed field //  has any type kind other than an anonymous adt or a named adt)


} #[derive(Diagnostic)] <ins> #[diag(hir_analysis_invalid_unnamed_field_ty)] pub struct InvalidUnnamedFieldTy { #[primary_span] pub span: Span, } #[derive(Diagnostic)] </ins> #[diag(hir_analysis_return_type_notation_on_non_rpitit)] pub(crate) struct ReturnTypeNotationOnNonRpitit<'tcx> { #[primary_span]


<ins> #[repr(C)] pub struct GoodStruct(()); pub struct BadStruct(()); pub enum BadEnum { A, B, } #[repr(C)] pub enum BadEnum2 { A, B, } pub type GoodAlias = GoodStruct; pub type BadAlias = i32; </ins>


<ins> //@ aux-build:dep.rs // test for #121151 #![allow(incomplete_features)] #![feature(unnamed_fields)] extern crate dep; #[repr(C)] struct A { a: u8, } enum BadEnum { A, B, } #[repr(C)] enum BadEnum2 { A, B, } type MyStruct = A; type MyI32 = i32; #[repr(C)] struct L { _: i32, //~ ERROR unnamed fields can only have struct or union types _: MyI32, //~ ERROR unnamed fields can only have struct or union types _: BadEnum, //~ ERROR unnamed fields can only have struct or union types _: BadEnum2, //~ ERROR unnamed fields can only have struct or union types _: MyStruct, _: dep::BadStruct, //~ ERROR named type of unnamed field must have `#[repr(C)]` representation _: dep::BadEnum, //~ ERROR unnamed fields can only have struct or union types _: dep::BadEnum2, //~ ERROR unnamed fields can only have struct or union types _: dep::BadAlias, //~ ERROR unnamed fields can only have struct or union types _: dep::GoodAlias, _: dep::GoodStruct, } fn main() {} </ins>


<ins> error: unnamed fields can only have struct or union types --> $DIR/restrict_type_hir.rs:31:5 | LL |     _: i32, |     ^^^^^^ error: unnamed fields can only have struct or union types --> $DIR/restrict_type_hir.rs:32:5 | LL |     _: MyI32, |     ^^^^^^^^ error: unnamed fields can only have struct or union types --> $DIR/restrict_type_hir.rs:33:5 | LL |     _: BadEnum, |     ^^^^^^^^^^ error: unnamed fields can only have struct or union types --> $DIR/restrict_type_hir.rs:34:5 | LL |     _: BadEnum2, |     ^^^^^^^^^^^ error: named type of unnamed field must have `#[repr(C)]` representation --> $DIR/restrict_type_hir.rs:36:5 | LL |     _: dep::BadStruct, |     ^^^^^^^^^^^^^^^^^ unnamed field defined here | ::: $DIR/auxiliary/dep.rs:4:1 | LL | pub struct BadStruct(()); | -------------------- `BadStruct` defined here | help: add `#[repr(C)]` to this struct --> $DIR/auxiliary/dep.rs:4:1 | LL + #[repr(C)] LL | pub struct BadStruct(()); | error: unnamed fields can only have struct or union types --> $DIR/restrict_type_hir.rs:37:5 | LL |     _: dep::BadEnum, |     ^^^^^^^^^^^^^^^ error: unnamed fields can only have struct or union types --> $DIR/restrict_type_hir.rs:38:5 | LL |     _: dep::BadEnum2, |     ^^^^^^^^^^^^^^^^ error: unnamed fields can only have struct or union types --> $DIR/restrict_type_hir.rs:39:5 | LL |     _: dep::BadAlias, |     ^^^^^^^^^^^^^^^^ error: aborting due to 8 previous errors </ins>


let func_ty = func.ty(body, tcx); if let ty::FnDef(callee, args) = *func_ty.kind() { <del> let normalized_args = tcx.normalize_erasing_regions(param_env, args); </del> <ins> let Ok(normalized_args) = tcx.try_normalize_erasing_regions(param_env, args) else { return false; }; </ins> let (callee, call_args) = if let Ok(Some(instance)) = Instance::resolve(tcx, param_env, callee, normalized_args) {


<ins> fn problematic_function<Space>(material_surface_element: ()) where DefaultAllocator: FiniteElementAllocator<(), Space>, { let _: Point2<f64> = material_surface_element.map_reference_coords().into(); } impl<N, R> Allocator<N, R> for DefaultAllocator where R::Value: DimName, //~ ERROR: `Value` not found for `R` { type Buffer = (); } impl<N> Allocator<N, ()> for DefaultAllocator {} //~^ ERROR: conflicting implementations impl DimName for () {} impl DimName for u32 {} impl<N, D: DimName> From<VectorN<N, D>> for Point<N, D> { fn from(_: VectorN<N, D>) -> Self { todo!() } } impl FiniteElement<u32> for () {} type VectorN<N, D> = Matrix<<DefaultAllocator as Allocator<N, D>>::Buffer>; type Point2<N> = Point<N, u32>; struct DefaultAllocator; struct Matrix<S>(S); struct Point<N, D>(N, D); trait Allocator<Scalar, R> { type Buffer; } trait DimName {} trait FiniteElementAllocator<GeometryDim, NodalDim>: Allocator<f64, ()> + Allocator<f64, NodalDim> { } trait FiniteElement<GeometryDim> { fn map_reference_coords(&self) -> VectorN<f64, GeometryDim> { todo!() } } fn main() {} </ins>


<ins> error[E0220]: associated type `Value` not found for `R` --> $DIR/normalize-conflicting-impls.rs:10:8 | LL |     R::Value: DimName, |        ^^^^^ associated type `Value` not found error[E0119]: conflicting implementations of trait `Allocator<_, ()>` for type `DefaultAllocator` --> $DIR/normalize-conflicting-impls.rs:14:1 | LL | / impl<N, R> Allocator<N, R> for DefaultAllocator LL | | where LL | |     R::Value: DimName, | |______________________- first implementation here ... LL |   impl<N> Allocator<N, ()> for DefaultAllocator {} |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `DefaultAllocator` error: aborting due to 2 previous errors Some errors have detailed explanations: E0119, E0220. For more information about an error, try `rustc --explain E0119`. </ins>


#![allow(rustc::untranslatable_diagnostic)] use either::Either; <ins> use hir::ClosureKind; </ins> use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxIndexSet; use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag, MultiSpan};


} else if let UseSpans::FnSelfUse { kind: CallKind::Normal { .. }, .. } = move_spans { // We already suggest cloning for these cases in `explain_captures`. <ins> } else if let UseSpans::ClosureUse { closure_kind: ClosureKind::Coroutine(CoroutineKind::Desugared(_, CoroutineSource::Block)), args_span: _, capture_kind_span: _, path_span, } = move_spans { self.suggest_cloning(err, ty, expr, path_span); </ins> } else if self.suggest_hoisting_call_outside_loop(err, expr) { // The place where the the type moves would be misleading to suggest clone. // #121466


} // FIXME: We make sure that this is a normal top-level binding, <del> // but we could suggest `todo!()` for all uninitalized bindings in the pattern pattern </del> <ins> // but we could suggest `todo!()` for all uninitialized bindings in the pattern pattern </ins> if let hir::StmtKind::Let(hir::LetStmt { span, ty, init: None, pat, .. }) = &ex.kind && let hir::PatKind::Binding(..) = pat.kind


true } <del> /// In a move error that occurs on a call wihtin a loop, we try to identify cases where cloning </del> <ins> /// In a move error that occurs on a call within a loop, we try to identify cases where cloning </ins> /// the value would lead to a logic error. We infer these cases by seeing if the moved value is /// part of the logic to break the loop, either through an explicit `break` or if the expression /// is part of a `while let`.


{ // FIXME: We could check that the call's *parent* takes `&mut val` to make the // suggestion more targeted to the `mk_iter(val).next()` case. Maybe do that only to <del> // check for wheter to suggest `let value` or `let mut value`. </del> <ins> // check for whether to suggest `let value` or `let mut value`. </ins> let span = in_loop.span; if !finder.found_breaks.is_empty()


<ins> //@ edition:2021 async fn clone_async_block(value: String) { for _ in 0..10 { async { //~ ERROR: use of moved value: `value` [E0382] drop(value); //~^ HELP: consider cloning the value if the performance cost is acceptable }.await } } fn main() {} </ins>


<ins> error[E0382]: use of moved value: `value` --> $DIR/cloning-in-async-block-121547.rs:5:9 | LL |   async fn clone_async_block(value: String) { |                              ----- move occurs because `value` has type `String`, which does not implement the `Copy` trait LL |       for _ in 0..10 { |       -------------- inside of this loop LL | /         async { LL | |             drop(value); | |                  ----- use occurs due to use in coroutine LL | | LL | |         }.await | |_________^ value moved here, in previous iteration of loop | help: consider cloning the value if the performance cost is acceptable | LL |             drop(value.clone()); |                       ++++++++ error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0382`. </ins>


/// `ManuallyDrop` to control drop order (needs to be dropped after all the nodes). pub(super) alloc: ManuallyDrop<A>, // For dropck; the `Box` avoids making the `Unpin` impl more strict than before <del> _marker: PhantomData<crate::boxed::Box<(K, V)>>, </del> <ins> _marker: PhantomData<crate::boxed::Box<(K, V), A>>, </ins> } #[stable(feature = "btree_drop", since = "1.7.0")]


// If we have a symlink like libLLVM-18.so -> libLLVM.so.18.1, install the target of the // symlink, which is what will actually get loaded at runtime. builder.install(&t!(fs::canonicalize(source)), destination, 0o644); <ins> let full_dest = destination.join(source.file_name().unwrap()); </ins> if install_symlink { <del> // If requested, also install the symlink. This is used by download-ci-llvm. let full_dest = destination.join(source.file_name().unwrap()); </del> <ins> // For download-ci-llvm, also install the symlink, to match what LLVM does. Using a // symlink is fine here, as this is not a rustup component. </ins> builder.copy(&source, &full_dest); <ins> } else { // Otherwise, replace the symlink with an equivalent linker script. This is used when // projects like miri link against librustc_driver.so. We don't use a symlink, as // these are not allowed inside rustup components. let link = t!(fs::read_link(source)); t!(std::fs::write(full_dest, format!("INPUT({})n", link.display()))); </ins> } } else { builder.install(&source, destination, 0o644);


<del> Subproject commit 7973f3560287d750500718314a0fd4025bd8ac0e </del> <ins> Subproject commit 84f190a4abf58bbd5301c0fc831f7a96acea246f </ins>


let suggest_eq = if self.token.kind == token::Dot && let _ = self.bump() && let mut snapshot = self.create_snapshot_for_diagnostic() <del> && let Ok(_) = snapshot.parse_dot_suffix_expr( colon_sp, self.mk_expr_err( </del> <ins> && let Ok(_) = snapshot .parse_dot_suffix_expr( </ins> colon_sp, <del> self.dcx().delayed_bug("error during `:` -> `=` recovery"), ), ) { </del> <ins> self.mk_expr_err( colon_sp, self.dcx() .delayed_bug("error during `:` -> `=` recovery"), ), ) .map_err(Diag::cancel) { </ins> true } else if let Some(op) = self.check_assoc_op() && op.node.can_continue_expr_unambiguously()


<ins> #![allow(unused)] fn test_122112() { // Make sure we don't ICE if parsing in recovery fails let _: std::env::temp_dir().join(&self, push: Box<usize>);  //~ ERROR expected one of } </ins> fn main() { let _: std::env::temp_dir().join("foo"); //~ ERROR expected one of }


error: expected one of `!`, `+`, `->`, `::`, `;`, or `=`, found `.` <del> --> $DIR/recover-colon-instead-of-eq-in-local.rs:2:32 </del> <ins> --> $DIR/recover-colon-instead-of-eq-in-local.rs:5:32 | LL |     let _: std::env::temp_dir().join(&self, push: Box<usize>); |          -                     ^ expected one of `!`, `+`, `->`, `::`, `;`, or `=` |          | |          while parsing the type for `_` error: expected one of `!`, `+`, `->`, `::`, `;`, or `=`, found `.` --> $DIR/recover-colon-instead-of-eq-in-local.rs:9:32 </ins> | LL |     let _: std::env::temp_dir().join("foo"); |          -                     ^ expected one of `!`, `+`, `->`, `::`, `;`, or `=`


|          while parsing the type for `_` |          help: use `=` if you meant to assign <del> error: aborting due to 1 previous error </del> <ins> error: aborting due to 2 previous errors </ins>


kind: hir::GenericParamKind::Type { default: Some(ty), .. }, .. }) => vec![*ty], <ins> hir::Node::AnonConst(_) if let Some(const_param_id) = tcx.hir().opt_const_param_default_param_def_id(hir_id) && let hir::Node::GenericParam(hir::GenericParam { kind: hir::GenericParamKind::Const { ty, .. }, .. }) = tcx.hir_node_by_def_id(const_param_id) => { vec![*ty] } </ins> ref node => bug!("Unexpected node {:?}", node), }, WellFormedLoc::Param { function: _, param_idx } => {


<ins> trait Trait<const N: Trait = bar> { //~^ ERROR cannot find value `bar` in this scope //~| ERROR cycle detected when computing type of `Trait::N` //~| ERROR cycle detected when computing type of `Trait::N` //~| ERROR `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter //~| WARN trait objects without an explicit `dyn` are deprecated //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! fn fnc(&self) { } } fn main() {} </ins>


<ins> error[E0425]: cannot find value `bar` in this scope --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:30 | LL | trait Trait<const N: Trait = bar> { |                              ^^^ not found in this scope warning: trait objects without an explicit `dyn` are deprecated --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:22 | LL | trait Trait<const N: Trait = bar> { |                      ^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: `#[warn(bare_trait_objects)]` on by default help: if this is an object-safe trait, use `dyn` | LL | trait Trait<const N: dyn Trait = bar> { |                      +++ error[E0391]: cycle detected when computing type of `Trait::N` --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:22 | LL | trait Trait<const N: Trait = bar> { |                      ^^^^^ | = note: ...which immediately requires computing type of `Trait::N` again note: cycle used when computing explicit predicates of trait `Trait` --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:1 | LL | trait Trait<const N: Trait = bar> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when computing type of `Trait::N` --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:13 | LL | trait Trait<const N: Trait = bar> { |             ^^^^^^^^^^^^^^^^^^^^ | = note: ...which immediately requires computing type of `Trait::N` again note: cycle used when computing explicit predicates of trait `Trait` --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:1 | LL | trait Trait<const N: Trait = bar> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:22 | LL | trait Trait<const N: Trait = bar> { |                      ^^^^^ | = note: the only supported types are integers, `bool` and `char` error: aborting due to 4 previous errors; 1 warning emitted Some errors have detailed explanations: E0391, E0425. For more information about an error, try `rustc --explain E0391`. </ins>


trait Trait<const N: Trait = bar> { <del> //~^ ERROR cannot find value `bar` in this scope //~| ERROR cycle detected when computing type of `Trait::N` //~| ERROR cycle detected when computing type of `Trait::N` //~| ERROR `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter //~| WARN trait objects without an explicit `dyn` are deprecated //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! fn fnc(&self) { </del> <ins> //~^ ERROR cannot find value `bar` in this scope //~| ERROR cycle detected when computing type of `Trait::N` //~| ERROR cycle detected when computing type of `Trait::N` //~| ERROR the trait `Trait` cannot be made into an object //~| ERROR the trait `Trait` cannot be made into an object //~| ERROR the trait `Trait` cannot be made into an object //~| ERROR `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! fn fnc<const N: Trait = u32>(&self) -> Trait { //~^ ERROR the name `N` is already used for a generic parameter in this item's generic parameters //~| ERROR expected value, found builtin type `u32` //~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions //~| ERROR associated item referring to unboxed trait object for its own trait //~| ERROR the trait `Trait` cannot be made into an object //~| ERROR `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects] //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! bar //~^ ERROR cannot find value `bar` in this scope </ins> } }


<ins> error[E0403]: the name `N` is already used for a generic parameter in this item's generic parameters --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:18 | LL | trait Trait<const N: Trait = bar> { |                   - first use of `N` ... LL |     fn fnc<const N: Trait = u32>(&self) -> Trait { |                  ^ already used </ins> error[E0425]: cannot find value `bar` in this scope --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:30 | LL | trait Trait<const N: Trait = bar> { |                              ^^^ not found in this scope <ins> error[E0423]: expected value, found builtin type `u32` --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:29 | LL |     fn fnc<const N: Trait = u32>(&self) -> Trait { |                             ^^^ not a value error[E0425]: cannot find value `bar` in this scope --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:26:9 | LL |         bar |         ^^^ not found in this scope </ins> warning: trait objects without an explicit `dyn` are deprecated --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:22 |


| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information <ins> error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:12 | LL |     fn fnc<const N: Trait = u32>(&self) -> Trait { |            ^^^^^^^^^^^^^^^^^^^^ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:21 | LL |     fn fnc<const N: Trait = u32>(&self) -> Trait { |                     ^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> help: if this is an object-safe trait, use `dyn` | LL |     fn fnc<const N: dyn Trait = u32>(&self) -> Trait { |                     +++ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:44 | LL |     fn fnc<const N: Trait = u32>(&self) -> Trait { |                                            ^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> help: if this is an object-safe trait, use `dyn` | LL |     fn fnc<const N: Trait = u32>(&self) -> dyn Trait { |                                            +++ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:22 | LL | trait Trait<const N: Trait = bar> { |                      ^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: if this is an object-safe trait, use `dyn` | LL | trait Trait<const N: dyn Trait = bar> { |                      +++ error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:22 | LL | trait Trait<const N: Trait = bar> { |                      ^^^^^ `Trait` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:8 | LL | trait Trait<const N: Trait = bar> { |       ----- this trait cannot be made into an object... ... LL |     fn fnc<const N: Trait = u32>(&self) -> Trait { |        ^^^ ...because method `fnc` has generic type parameters = help: consider moving `fnc` to another trait error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:13 | LL | trait Trait<const N: Trait = bar> { |             ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:8 | LL | trait Trait<const N: Trait = bar> { |       ----- this trait cannot be made into an object... ... LL |     fn fnc<const N: Trait = u32>(&self) -> Trait { |        ^^^ ...because method `fnc` has generic type parameters = help: consider moving `fnc` to another trait </ins> error: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:22 |


| = note: the only supported types are integers, `bool` and `char` <del> error: aborting due to 4 previous errors; 1 warning emitted </del> <ins> error: associated item referring to unboxed trait object for its own trait --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:44 | LL | trait Trait<const N: Trait = bar> { |       ----- in this trait ... LL |     fn fnc<const N: Trait = u32>(&self) -> Trait { |                                            ^^^^^ | help: you might have meant to use `Self` to refer to the implementing type | LL |     fn fnc<const N: Trait = u32>(&self) -> Self { |                                            ~~~~ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:21 | LL |     fn fnc<const N: Trait = u32>(&self) -> Trait { |                     ^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: if this is an object-safe trait, use `dyn` | LL |     fn fnc<const N: dyn Trait = u32>(&self) -> Trait { |                     +++ error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:21 | LL |     fn fnc<const N: Trait = u32>(&self) -> Trait { |                     ^^^^^ `Trait` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:8 | LL | trait Trait<const N: Trait = bar> { |       ----- this trait cannot be made into an object... ... LL |     fn fnc<const N: Trait = u32>(&self) -> Trait { |        ^^^ ...because method `fnc` has generic type parameters = help: consider moving `fnc` to another trait error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:13 | LL | trait Trait<const N: Trait = bar> { |             ^^^^^^^^^^^^^^^^^^^^ `Trait` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:8 | LL | trait Trait<const N: Trait = bar> { |       ----- this trait cannot be made into an object... ... LL |     fn fnc<const N: Trait = u32>(&self) -> Trait { |        ^^^ ...because method `fnc` has generic type parameters = help: consider moving `fnc` to another trait = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `(dyn Trait<{const error}> + 'static)` is forbidden as the type of a const generic parameter --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:13:21 | LL |     fn fnc<const N: Trait = u32>(&self) -> Trait { |                     ^^^^^ | = note: the only supported types are integers, `bool` and `char` error: aborting due to 14 previous errors; 5 warnings emitted </ins> <del> Some errors have detailed explanations: E0391, E0425. For more information about an error, try `rustc --explain E0391`. </del> <ins> Some errors have detailed explanations: E0038, E0391, E0403, E0423, E0425. For more information about an error, try `rustc --explain E0038`. </ins>


use middle::freevars; use middle::pat_util; use middle::ty; <del> use middle::typeck::MethodCall; </del> <ins> use middle::typeck::{MethodCall, MethodObject, MethodOrigin, MethodParam}; use middle::typeck::{MethodStatic}; </ins> use middle::typeck; <del> use syntax::ast; use syntax::codemap::{Span}; </del> use util::ppaux::Repr; use std::gc::Gc; <ins> use syntax::ast; use syntax::codemap::Span; </ins> /////////////////////////////////////////////////////////////////////////// // The Delegate trait


WriteAndRead, // x += y } <ins> enum OverloadedCallType { FnOverloadedCall, FnMutOverloadedCall, FnOnceOverloadedCall, } impl OverloadedCallType { fn from_trait_id(tcx: &ty::ctxt, trait_id: ast::DefId) -> OverloadedCallType { for &(maybe_function_trait, overloaded_call_type) in [ (tcx.lang_items.fn_once_trait(), FnOnceOverloadedCall), (tcx.lang_items.fn_mut_trait(), FnMutOverloadedCall), (tcx.lang_items.fn_trait(), FnOverloadedCall) ].iter() { match maybe_function_trait { Some(function_trait) if function_trait == trait_id => { return overloaded_call_type } _ => continue, } } tcx.sess.bug("overloaded call didn't map to known function trait") } fn from_method_id(tcx: &ty::ctxt, method_id: ast::DefId) -> OverloadedCallType { let method_descriptor = match tcx.methods.borrow_mut().find(&method_id) { None => { tcx.sess.bug("overloaded call method wasn't in method  map") } Some(ref method_descriptor) => (*method_descriptor).clone(), }; let impl_id = match method_descriptor.container { ty::TraitContainer(_) => { tcx.sess.bug("statically resolved overloaded call method  belonged to a trait?!") } ty::ImplContainer(impl_id) => impl_id, }; let trait_ref = match ty::impl_trait_ref(tcx, impl_id) { None => { tcx.sess.bug("statically resolved overloaded call impl  didn't implement a trait?!") } Some(ref trait_ref) => (*trait_ref).clone(), }; OverloadedCallType::from_trait_id(tcx, trait_ref.def_id) } fn from_method_origin(tcx: &ty::ctxt, origin: &MethodOrigin) -> OverloadedCallType { match *origin { MethodStatic(def_id) => { OverloadedCallType::from_method_id(tcx, def_id) } MethodParam(ref method_param) => { OverloadedCallType::from_trait_id(tcx, method_param.trait_id) } MethodObject(ref method_object) => { OverloadedCallType::from_trait_id(tcx, method_object.trait_id) } } } } </ins> /////////////////////////////////////////////////////////////////////////// // The ExprUseVisitor type //


} } _ => { <del> match self.tcx() .method_map .borrow() .find(&MethodCall::expr(call.id)) { Some(_) => { // FIXME(#14774, pcwalton): Implement this. </del> <ins> let overloaded_call_type = match self.tcx() .method_map .borrow() .find(&MethodCall::expr(call.id)) { Some(ref method_callee) => { OverloadedCallType::from_method_origin( self.tcx(), &method_callee.origin) </ins> } None => { self.tcx().sess.span_bug( callee.span, format!("unexpected callee type {}", <del> callee_ty.repr(self.tcx())).as_slice()); </del> <ins> callee_ty.repr(self.tcx())).as_slice()) } }; match overloaded_call_type { FnMutOverloadedCall => { self.borrow_expr(callee, ty::ReScope(call.id), ty::MutBorrow, ClosureInvocation); } FnOverloadedCall => { self.borrow_expr(callee, ty::ReScope(call.id), ty::ImmBorrow, ClosureInvocation); </ins> } <ins> FnOnceOverloadedCall => self.consume_expr(callee), </ins> } } }


<ins> // Copyright 2012 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(overloaded_calls)] use std::ops::{Fn, FnMut, FnOnce}; struct SFn { x: int, y: int, } impl Fn<(int,),int> for SFn { fn call(&self, (z,): (int,)) -> int { self.x * self.y * z } } struct SFnMut { x: int, y: int, } impl FnMut<(int,),int> for SFnMut { fn call_mut(&mut self, (z,): (int,)) -> int { self.x * self.y * z } } struct SFnOnce { x: String, } impl FnOnce<(String,),uint> for SFnOnce { fn call_once(self, (z,): (String,)) -> uint { self.x.len() + z.len() } } fn f() { let mut s = SFn { x: 1, y: 2, }; let sp = &mut s; s(3);   //~ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable //~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable } fn g() { let s = SFnMut { x: 1, y: 2, }; s(3);   //~ ERROR cannot borrow immutable local variable `s` as mutable } fn h() { let s = SFnOnce { x: "hello".to_string(), }; s(" world".to_string()); s(" world".to_string());    //~ ERROR use of moved value: `s` } fn main() {} </ins>


pub UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, Warn, "unrecognized or malformed diagnostic attribute", <del> @feature_gate = sym::diagnostic_namespace; </del> } declare_lint! {


<ins> #![deny(unknown_or_malformed_diagnostic_attributes)] #[diagnostic::unknown_attribute] //~^ERROR unknown diagnostic attribute struct Foo; fn main() {} </ins>


<ins> error: unknown diagnostic attribute --> $DIR/deny_malformed_attribute.rs:3:15 | LL | #[diagnostic::unknown_attribute] |               ^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> $DIR/deny_malformed_attribute.rs:1:9 | LL | #![deny(unknown_or_malformed_diagnostic_attributes)] |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error </ins>


generics_of => { table } inferred_outlives_of => { table_defaulted_array } super_predicates_of => { table } <ins> implied_predicates_of => { table } </ins> type_of => { table } type_alias_is_lazy => { cdata.root.tables.type_alias_is_lazy.get(cdata, def_id.index) } variances_of => { table }


.map(|lazy| lazy.decode((cdata, tcx))) .process_decoded(tcx, || panic!("{def_id:?} does not have trait_impl_trait_tys"))) } <del> implied_predicates_of => { cdata .root .tables .implied_predicates_of .get(cdata, def_id.index) .map(|lazy| lazy.decode((cdata, tcx))) .unwrap_or_else(|| { debug_assert_eq!(tcx.def_kind(def_id), DefKind::Trait); tcx.super_predicates_of(def_id) }) } </del> associated_types_for_impl_traits_in_associated_fn => { table_defaulted_array }


if let DefKind::Trait = def_kind { record!(self.tables.trait_def[def_id] <- self.tcx.trait_def(def_id)); record!(self.tables.super_predicates_of[def_id] <- self.tcx.super_predicates_of(def_id)); <ins> record!(self.tables.implied_predicates_of[def_id] <- self.tcx.implied_predicates_of(def_id)); </ins> let module_children = self.tcx.module_children_local(local_id); record_array!(self.tables.module_children_non_reexports[def_id] <-


<ins> pub trait Bar: Super<SuperAssoc: Bound> {} pub trait Super { type SuperAssoc; } pub trait Bound {} </ins>


<ins> //@ aux-build:implied-predicates.rs //@ check-pass extern crate implied_predicates; use implied_predicates::Bar; fn bar<B: Bar>() {} fn main() {} </ins>


<ins> // Don't panic when iterating through the `hir::Map::parent_iter` of an RPITIT. pub trait Foo { fn demo() -> impl Foo //~^ ERROR the trait bound `String: Copy` is not satisfied where String: Copy; //~^ ERROR the trait bound `String: Copy` is not satisfied } fn main() {} </ins>


<ins> error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/synthetic-hir-has-parent.rs:7:9 | LL |         String: Copy; |         ^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` | = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] | error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/synthetic-hir-has-parent.rs:4:18 | LL |     fn demo() -> impl Foo |                  ^^^^^^^^ the trait `Copy` is not implemented for `String` | = help: see issue #48214 help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | LL + #![feature(trivial_bounds)] | error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. </ins>


pat: &'tcx hir::Pat<'tcx>, ty: Ty<'tcx>, ) { <del> struct V<'tcx> { tcx: TyCtxt<'tcx>, </del> <ins> struct V { </ins> pat_hir_ids: Vec<hir::HirId>, } <del> impl<'tcx> Visitor<'tcx> for V<'tcx> { type NestedFilter = rustc_middle::hir::nested_filter::All; fn nested_visit_map(&mut self) -> Self::Map { self.tcx.hir() } </del> <ins> impl<'tcx> Visitor<'tcx> for V { </ins> fn visit_pat(&mut self, p: &'tcx hir::Pat<'tcx>) { self.pat_hir_ids.push(p.hir_id); hir::intravisit::walk_pat(self, p);


let err = Ty::new_error(self.tcx, guar); self.write_ty(hir_id, err); self.write_ty(pat.hir_id, err); <del> let mut visitor = V { tcx: self.tcx, pat_hir_ids: vec![] }; </del> <ins> let mut visitor = V { pat_hir_ids: vec![] }; </ins> hir::intravisit::walk_pat(&mut visitor, pat); // Mark all the subpatterns as `{type error}` as well. This allows errors for specific // subpatterns to be silenced.


<ins> fn main() { let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes; //~^ ERROR expected a pattern, found an expression //~| ERROR cannot find type `T` in this scope //~| ERROR type and const arguments are not allowed on builtin type `str` //~| ERROR expected unit struct, unit variant or constant, found associated function `str<, T>::as_bytes` } </ins>


<ins> error: expected a pattern, found an expression --> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:31 | LL |     let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes; |                               ^^^^^^^^^^^^^^^^^^ arbitrary expressions are not allowed in patterns error[E0412]: cannot find type `T` in this scope --> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:55 | LL |     let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes; |                                                       ^ not found in this scope error[E0109]: type and const arguments are not allowed on builtin type `str` --> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:15 | LL |     let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes; |         ---   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  ^ type and const arguments not allowed |         | |         not allowed on builtin type `str` | help: primitive type `str` doesn't have generic parameters | LL -     let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes; LL +     let str::as_bytes; | error[E0533]: expected unit struct, unit variant or constant, found associated function `str<, T>::as_bytes` --> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:9 | LL |     let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes; |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a unit struct, unit variant or constant error: aborting due to 4 previous errors Some errors have detailed explanations: E0109, E0412, E0533. For more information about an error, try `rustc --explain E0109`. </ins>


impl_clone! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 <del> f32 f64 </del> <ins> f16 f32 f64 f128 </ins> bool char }


} partial_eq_impl! { <del> bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 </del> <ins> bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128 </ins> } macro_rules! eq_impl {


} } <del> partial_ord_impl! { f32 f64 } </del> <ins> partial_ord_impl! { f16 f32 f64 f128 } </ins> macro_rules! ord_impl { ($($t:ty)*) => ($(


default_impl! { i64, 0, "Returns the default value of `0`" } default_impl! { i128, 0, "Returns the default value of `0`" } <ins> #[cfg(not(bootstrap))] default_impl! { f16, 0.0f16, "Returns the default value of `0.0`" } </ins> default_impl! { f32, 0.0f32, "Returns the default value of `0.0`" } default_impl! { f64, 0.0f64, "Returns the default value of `0.0`" } <ins> #[cfg(not(bootstrap))] default_impl! { f128, 0.0f128, "Returns the default value of `0.0`" } </ins>


#![feature(doc_notable_trait)] #![feature(effects)] #![feature(extern_types)] <ins> #![feature(f128)] #![feature(f16)] </ins> #![feature(freeze_impls)] #![feature(fundamental)] #![feature(generic_arg_infer)]


Copy for usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, <del> f32, f64, </del> <ins> f16, f32, f64, f128, </ins> bool, char, {T: ?Sized} *const T, {T: ?Sized} *mut T,


| = help: the trait `PartialEq<Foo>` is not implemented for `&&{integer}` = help: the following other types implement trait `PartialEq<Rhs>`: <ins> f128 f16 </ins> f32 f64 i128 i16 i32 i64 <del> i8 isize and 6 others </del> <ins> and 8 others </ins> error[E0369]: binary operation `==` cannot be applied to type `Foo` --> $DIR/binary-op-suggest-deref.rs:60:13


| = help: the trait `PartialOrd<String>` is not implemented for `{integer}` = help: the following other types implement trait `PartialOrd<Rhs>`: <ins> f128 f16 </ins> f32 f64 i128 i16 i32 i64 <del> i8 isize and 6 others </del> <ins> and 8 others </ins> error[E0277]: can't compare `{integer}` with `Result<{integer}, _>` --> $DIR/binops.rs:7:7


| = help: the trait `PartialEq<Result<{integer}, _>>` is not implemented for `{integer}` = help: the following other types implement trait `PartialEq<Rhs>`: <ins> f128 f16 </ins> f32 f64 i128 i16 i32 i64 <del> i8 isize and 6 others </del> <ins> and 8 others </ins> error: aborting due to 6 previous errors


let expn_data = prefix_span.ctxt().outer_expn_data(); if expn_data.edition >= Edition::Edition2021 { <del> let mut silence = false; </del> // In Rust 2021, this is a hard error. let sugg = if prefix == "rb" { Some(errors::UnknownPrefixSugg::UseBr(prefix_span))


if self.cursor.first() == ''' && let Some(start) = self.last_lifetime && self.cursor.third() != ''' <ins> && let end = self.mk_sp(self.pos, self.pos + BytePos(1)) && !self.psess.source_map().is_multiline(start.until(end)) </ins> { <del> // An "unclosed `char`" error will be emitted already, silence redundant error. silence = true; Some(errors::UnknownPrefixSugg::MeantStr { start, end: self.mk_sp(self.pos, self.pos + BytePos(1)), }) </del> <ins> // FIXME: An "unclosed `char`" error will be emitted already in some cases, // but it's hard to silence this error while not also silencing important cases // too. We should use the error stashing machinery instead. Some(errors::UnknownPrefixSugg::MeantStr { start, end }) </ins> } else { Some(errors::UnknownPrefixSugg::Whitespace(prefix_span.shrink_to_hi())) } } else { None }; <del> let err = errors::UnknownPrefix { span: prefix_span, prefix, sugg }; if silence { self.dcx().create_err(err).delay_as_bug(); } else { self.dcx().emit_err(err); } </del> <ins> self.dcx().emit_err(errors::UnknownPrefix { span: prefix_span, prefix, sugg }); </ins> } else { // Before Rust 2021, only emit a lint for migration. self.psess.buffer_lint_with_diagnostic(


<ins> //@ edition:2021 macro_rules! a { ( ) => { impl<'b> c for d { e::<f'g> //~ ERROR prefix `f` is unknown } }; } fn main() {} </ins>


<ins> error: prefix `f` is unknown --> $DIR/dont-ice-on-invalid-lifetime-in-macro-definition.rs:5:17 | LL |             e::<f'g> |                 ^ unknown prefix | = note: prefixed identifiers and literals are reserved since Rust 2021 help: consider inserting whitespace here | LL |             e::<f 'g> |                  + error: aborting due to 1 previous error </ins>


//@[rust2021] edition:2021 fn main() { println!('hello world'); <del> //[rust2015,rust2018,rust2021]~^ ERROR unterminated character literal </del> <ins> //~^ ERROR unterminated character literal //[rust2021]~| ERROR prefix `world` is unknown </ins> }


<ins> error: prefix `world` is unknown --> $DIR/lex-bad-str-literal-as-char-3.rs:5:21 | LL |     println!('hello world'); |                     ^^^^^ unknown prefix | = note: prefixed identifiers and literals are reserved since Rust 2021 help: if you meant to write a string literal, use double quotes | LL |     println!("hello world"); |              ~           ~ </ins> error[E0762]: unterminated character literal --> $DIR/lex-bad-str-literal-as-char-3.rs:5:26 |


LL |     println!("hello world"); |              ~           ~ <del> error: aborting due to 1 previous error </del> <ins> error: aborting due to 2 previous errors </ins> For more information about this error, try `rustc --explain E0762`.


<ins> //@edition:2021 macro_rules! foo { () => { println!('hello world'); //~^ ERROR unterminated character literal //~| ERROR prefix `world` is unknown } } fn main() {} </ins>


<ins> error: prefix `world` is unknown --> $DIR/lex-bad-str-literal-as-char-4.rs:4:25 | LL |         println!('hello world'); |                         ^^^^^ unknown prefix | = note: prefixed identifiers and literals are reserved since Rust 2021 help: if you meant to write a string literal, use double quotes | LL |         println!("hello world"); |                  ~           ~ error[E0762]: unterminated character literal --> $DIR/lex-bad-str-literal-as-char-4.rs:4:30 | LL |         println!('hello world'); |                              ^^^ | help: if you meant to write a string literal, use double quotes | LL |         println!("hello world"); |                  ~           ~ error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0762`. </ins>


ast::Path { span, segments, tokens: None } } <ins> pub fn macro_call( &self, span: Span, path: ast::Path, delim: ast::token::Delimiter, tokens: ast::tokenstream::TokenStream, ) -> P<ast::MacCall> { P(ast::MacCall { path, args: P(ast::DelimArgs { dspan: ast::tokenstream::DelimSpan { open: span, close: span }, delim, tokens, }), }) } </ins> pub fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy { ast::MutTy { ty, mutbl } }


self.expr(span, ast::ExprKind::Field(expr, field)) } <ins> pub fn expr_macro_call(&self, span: Span, call: P<ast::MacCall>) -> P<ast::Expr> { self.expr(span, ast::ExprKind::MacCall(call)) } </ins> pub fn expr_binary( &self, sp: Span,


self.expr(sp, ast::ExprKind::Tup(exprs)) } <del> pub fn expr_fail(&self, span: Span, msg: Symbol) -> P<ast::Expr> { self.expr_call_global( </del> <ins> pub fn expr_unreachable(&self, span: Span) -> P<ast::Expr> { self.expr_macro_call( </ins> span, <del> [sym::std, sym::rt, sym::begin_panic].iter().map(|s| Ident::new(*s, span)).collect(), thin_vec![self.expr_str(span, msg)], </del> <ins> self.macro_call( span, self.path_global( span, [sym::std, sym::unreachable].map(|s| Ident::new(s, span)).to_vec(), ), ast::token::Delimiter::Parenthesis, ast::tokenstream::TokenStream::default(), ), </ins> ) } <del> pub fn expr_unreachable(&self, span: Span) -> P<ast::Expr> { self.expr_fail(span, Symbol::intern("internal error: entered unreachable code")) } </del> pub fn expr_ok(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr> { let ok = self.std_path(&[sym::result, sym::Result, sym::Ok]); self.expr_call_global(sp, ok, thin_vec![expr])


<ins> #![crate_type = "lib"] pub trait Decoder { type Error; fn read_enum<T, F>(&mut self, name: &str, f: F) -> Result<T, Self::Error> where F: FnOnce(&mut Self) -> Result<T, Self::Error>; fn read_enum_variant<T, F>(&mut self, names: &[&str], f: F) -> Result<T, Self::Error> where F: FnMut(&mut Self, usize) -> Result<T, Self::Error>; } pub trait Decodable: Sized { fn decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error>; } </ins>


<ins> //@ check-pass //@ edition:2021 //@ aux-build:rustc-serialize.rs #![crate_type = "lib"] #![allow(deprecated, soft_unstable)] extern crate rustc_serialize; #[derive(RustcDecodable)] pub enum Foo {} </ins>


<ins> Future incompatibility report: Future breakage diagnostic: warning: use of unstable library feature 'rustc_encodable_decodable': derive macro for `rustc-serialize`; should not be used in new code --> $DIR/rustc-decodable-issue-123156.rs:10:10 | LL | #[derive(RustcDecodable)] |          ^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266> </ins>


/// Returns an iterator over the remaining elements of the original iterator /// that are not going to be returned by this iterator. The returned /// iterator will yield at most `N-1` elements. <ins> /// /// # Example /// ``` /// # // Also serves as a regression test for https://github.com/rust-lang/rust/issues/123333 /// # #![feature(iter_array_chunks)] /// let x = [1,2,3,4,5].into_iter().array_chunks::<2>(); /// let mut rem = x.into_remainder().unwrap(); /// assert_eq!(rem.next(), Some(5)); /// assert_eq!(rem.next(), None); /// ``` </ins> #[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")] #[inline] <del> pub fn into_remainder(self) -> Option<array::IntoIter<I::Item, N>> { </del> <ins> pub fn into_remainder(mut self) -> Option<array::IntoIter<I::Item, N>> { if self.remainder.is_none() { while let Some(_) = self.next() {} } </ins> self.remainder } }


/// Set the maximum pattern complexity allowed (not limited by default). (internal, pattern_complexity, "1.78.0", None), /// Allows using pattern types. <del> (internal, pattern_types, "CURRENT_RUSTC_VERSION", Some(54882)), </del> <ins> (internal, pattern_types, "CURRENT_RUSTC_VERSION", Some(123646)), </ins> /// Allows using `#[prelude_import]` on glob `use` items. (internal, prelude_import, "1.2.0", None), /// Used to identify crates that contain the profiler runtime.


Ty::new_pat(tcx, ty, pat) } hir::PatKind::Err(e) => Ty::new_error(tcx, e), <del> _ => span_bug!(pat.span, "unsupported pattern for pattern type: {pat:#?}"), </del> <ins> _ => Ty::new_error_with_message( tcx, pat.span, format!("unsupported pattern for pattern type: {pat:#?}"), ), </ins> }; self.record_ty(pat.hir_id, ty, pat.span); pat_ty


<ins> //! This test ensures we do not ICE for unimplemented //! patterns unless the feature gate is enabled. #![feature(core_pattern_type)] #![feature(core_pattern_types)] use std::pat::pattern_type; type Always = pattern_type!(Option<u32> is Some(_)); //~^ ERROR: pattern types are unstable type Binding = pattern_type!(Option<u32> is x); //~^ ERROR: pattern types are unstable fn main() {} </ins>


<ins> error[E0658]: pattern types are unstable --> $DIR/unimplemented_pat.rs:9:15 | LL | type Always = pattern_type!(Option<u32> is Some(_)); |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #123646 <https://github.com/rust-lang/rust/issues/123646> for more information = help: add `#![feature(pattern_types)]` 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[E0658]: pattern types are unstable --> $DIR/unimplemented_pat.rs:12:16 | LL | type Binding = pattern_type!(Option<u32> is x); |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #123646 <https://github.com/rust-lang/rust/issues/123646> for more information = help: add `#![feature(pattern_types)]` 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: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. </ins>


// Don't leak types into signatures unless they're nameable! // For example, if a function returns itself, we don't want that // recursive function definition to leak out into the fn sig. <del> let mut should_recover = false; </del> <ins> let mut recovered_ret_ty = None; </ins> <del> if let Some(ret_ty) = ret_ty.make_suggestable(tcx, false, None) { </del> <ins> if let Some(suggestable_ret_ty) = ret_ty.make_suggestable(tcx, false, None) { </ins> diag.span_suggestion( ty.span, "replace with the correct return type", <del> ret_ty, </del> <ins> suggestable_ret_ty, </ins> Applicability::MachineApplicable, ); <del> should_recover = true; </del> <ins> recovered_ret_ty = Some(suggestable_ret_ty); </ins> } else if let Some(sugg) = suggest_impl_trait(&tcx.infer_ctxt().build(), tcx.param_env(def_id), ret_ty) {


} let guar = diag.emit(); <del> if should_recover { ty::Binder::dummy(fn_sig) } else { ty::Binder::dummy(tcx.mk_fn_sig( fn_sig.inputs().iter().copied(), Ty::new_error(tcx, guar), fn_sig.c_variadic, fn_sig.unsafety, fn_sig.abi, )) } </del> <ins> ty::Binder::dummy(tcx.mk_fn_sig( fn_sig.inputs().iter().copied(), recovered_ret_ty.unwrap_or_else(|| Ty::new_error(tcx, guar)), fn_sig.c_variadic, fn_sig.unsafety, fn_sig.abi, )) </ins> } None => icx.lowerer().lower_fn_ty( hir_id,


} ty::FnDef(..) | ty::Coroutine(..) | ty::Closure(..) | ty::CoroutineClosure(..) => { <del> bug!("Unexpected coroutine/closure type in variance computation"); </del> <ins> bug!("Unexpected unnameable type in variance computation: {ty}"); </ins> } ty::Ref(region, ty, mutbl) => {


<ins> // Test variance computation doesn't explode when we leak unnameable // types due to `-> _` recovery. pub struct Type<'a>(&'a ()); pub fn g() {} pub fn f<T>() -> _ { //~^ ERROR the placeholder `_` is not allowed within types on item signatures g } fn main() {} </ins>