diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index f7ea7eba7b16b..01c97444ae3ae 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -20,9 +20,9 @@ use crate::mem::ManuallyDrop; /// # #![allow(invalid_value)] /// use std::mem::{self, MaybeUninit}; /// -/// let x: &i32 = unsafe { mem::zeroed() }; // undefined behavior! +/// let x: &i32 = unsafe { mem::zeroed() }; // undefined behavior! ⚠️ /// // The equivalent code with `MaybeUninit<&i32>`: -/// let x: &i32 = unsafe { MaybeUninit::zeroed().assume_init() }; // undefined behavior! +/// let x: &i32 = unsafe { MaybeUninit::zeroed().assume_init() }; // undefined behavior! ⚠️ /// ``` /// /// This is exploited by the compiler for various optimizations, such as eliding @@ -35,9 +35,9 @@ use crate::mem::ManuallyDrop; /// # #![allow(invalid_value)] /// use std::mem::{self, MaybeUninit}; /// -/// let b: bool = unsafe { mem::uninitialized() }; // undefined behavior! +/// let b: bool = unsafe { mem::uninitialized() }; // undefined behavior! ⚠️ /// // The equivalent code with `MaybeUninit`: -/// let b: bool = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! +/// let b: bool = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! ⚠️ /// ``` /// /// Moreover, uninitialized memory is special in that the compiler knows that @@ -49,9 +49,9 @@ use crate::mem::ManuallyDrop; /// # #![allow(invalid_value)] /// use std::mem::{self, MaybeUninit}; /// -/// let x: i32 = unsafe { mem::uninitialized() }; // undefined behavior! +/// let x: i32 = unsafe { mem::uninitialized() }; // undefined behavior! ⚠️ /// // The equivalent code with `MaybeUninit`: -/// let x: i32 = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! +/// let x: i32 = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! ⚠️ /// ``` /// (Notice that the rules around uninitialized integers are not finalized yet, but /// until they are, it is advisable to avoid them.) @@ -348,7 +348,7 @@ impl MaybeUninit { /// let x = MaybeUninit::<(u8, NotZero)>::zeroed(); /// let x = unsafe { x.assume_init() }; /// // Inside a pair, we create a `NotZero` that does not have a valid discriminant. - /// // This is undefined behavior. + /// // This is undefined behavior. ⚠️ /// ``` #[stable(feature = "maybe_uninit", since = "1.36.0")] #[inline] @@ -400,7 +400,7 @@ impl MaybeUninit { /// /// let x = MaybeUninit::>::uninit(); /// let x_vec = unsafe { &*x.as_ptr() }; - /// // We have created a reference to an uninitialized vector! This is undefined behavior. + /// // We have created a reference to an uninitialized vector! This is undefined behavior. ⚠️ /// ``` /// /// (Notice that the rules around references to uninitialized data are not finalized yet, but @@ -437,7 +437,7 @@ impl MaybeUninit { /// /// let mut x = MaybeUninit::>::uninit(); /// let x_vec = unsafe { &mut *x.as_mut_ptr() }; - /// // We have created a reference to an uninitialized vector! This is undefined behavior. + /// // We have created a reference to an uninitialized vector! This is undefined behavior. ⚠️ /// ``` /// /// (Notice that the rules around references to uninitialized data are not finalized yet, but @@ -489,7 +489,7 @@ impl MaybeUninit { /// /// let x = MaybeUninit::>::uninit(); /// let x_init = unsafe { x.assume_init() }; - /// // `x` had not been initialized yet, so this last line caused undefined behavior. + /// // `x` had not been initialized yet, so this last line caused undefined behavior. ⚠️ /// ``` #[stable(feature = "maybe_uninit", since = "1.36.0")] #[inline(always)] @@ -553,7 +553,7 @@ impl MaybeUninit { /// x.write(Some(vec![0,1,2])); /// let x1 = unsafe { x.read() }; /// let x2 = unsafe { x.read() }; - /// // We now created two copies of the same vector, leading to a double-free when + /// // We now created two copies of the same vector, leading to a double-free ⚠️ when /// // they both get dropped! /// ``` #[unstable(feature = "maybe_uninit_extra", issue = "63567")] @@ -603,7 +603,7 @@ impl MaybeUninit { /// /// let x = MaybeUninit::>::uninit(); /// let x_vec: &Vec = unsafe { x.get_ref() }; - /// // We have created a reference to an uninitialized vector! This is undefined behavior. + /// // We have created a reference to an uninitialized vector! This is undefined behavior. ⚠️ /// ``` /// /// ```rust,no_run @@ -686,7 +686,7 @@ impl MaybeUninit { /// unsafe { /// *b.get_mut() = true; /// // We have created a (mutable) reference to an uninitialized `bool`! - /// // This is undefined behavior. + /// // This is undefined behavior. ⚠️ /// } /// ``` /// diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index f11401b5a0c7c..2d5bd7e872bd5 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -39,6 +39,7 @@ mod diagnostic; #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] pub use diagnostic::{Diagnostic, Level, MultiSpan}; +use std::cmp::Ordering; use std::ops::{Bound, RangeBounds}; use std::path::PathBuf; use std::str::FromStr; @@ -420,6 +421,20 @@ impl !Send for LineColumn {} #[unstable(feature = "proc_macro_span", issue = "54725")] impl !Sync for LineColumn {} +#[unstable(feature = "proc_macro_span", issue = "54725")] +impl Ord for LineColumn { + fn cmp(&self, other: &Self) -> Ordering { + self.line.cmp(&other.line).then(self.column.cmp(&other.column)) + } +} + +#[unstable(feature = "proc_macro_span", issue = "54725")] +impl PartialOrd for LineColumn { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + /// The source file of a given `Span`. #[unstable(feature = "proc_macro_span", issue = "54725")] #[derive(Clone)] diff --git a/src/libproc_macro/tests/test.rs b/src/libproc_macro/tests/test.rs new file mode 100644 index 0000000000000..331b330cf29f0 --- /dev/null +++ b/src/libproc_macro/tests/test.rs @@ -0,0 +1,12 @@ +#![feature(proc_macro_span)] + +use proc_macro::LineColumn; + +#[test] +fn test_line_column_ord() { + let line0_column0 = LineColumn { line: 0, column: 0 }; + let line0_column1 = LineColumn { line: 0, column: 1 }; + let line1_column0 = LineColumn { line: 1, column: 0 }; + assert!(line0_column0 < line0_column1); + assert!(line0_column1 < line1_column0); +} diff --git a/src/librustc_hir/definitions.rs b/src/librustc_hir/definitions.rs index 30cddac6aac91..c7a0822d27dd6 100644 --- a/src/librustc_hir/definitions.rs +++ b/src/librustc_hir/definitions.rs @@ -327,7 +327,9 @@ impl Definitions { #[inline] pub fn local_def_id(&self, node: ast::NodeId) -> LocalDefId { - self.opt_local_def_id(node).unwrap() + self.opt_local_def_id(node).unwrap_or_else(|| { + panic!("no entry for node id: `{:?}` / `{:?}`", node, self.opt_node_id_to_hir_id(node)) + }) } #[inline] diff --git a/src/librustc_middle/arena.rs b/src/librustc_middle/arena.rs index a97db3134dc9e..2df878c3fb220 100644 --- a/src/librustc_middle/arena.rs +++ b/src/librustc_middle/arena.rs @@ -76,6 +76,12 @@ macro_rules! arena_types { [few] hir_definitions: rustc_hir::definitions::Definitions, [] hir_owner: rustc_middle::hir::Owner<$tcx>, [] hir_owner_nodes: rustc_middle::hir::OwnerNodes<$tcx>, + + // Note that this deliberately duplicates items in the `rustc_hir::arena`, + // since we need to allocate this type on both the `rustc_hir` arena + // (during lowering) and the `librustc_middle` arena (for decoding MIR) + [decode] asm_template: rustc_ast::ast::InlineAsmTemplatePiece, + ], $tcx); ) } diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs index 68c31c68075e0..5b53ab1778e3f 100644 --- a/src/librustc_middle/ty/context.rs +++ b/src/librustc_middle/ty/context.rs @@ -35,7 +35,6 @@ use crate::ty::{InferTy, ParamTy, PolyFnSig, ProjectionTy}; use crate::ty::{List, TyKind, TyS}; use rustc_ast::ast; use rustc_ast::expand::allocator::AllocatorKind; -use rustc_ast::node_id::NodeMap; use rustc_attr as attr; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::profiling::SelfProfilerRef; @@ -926,7 +925,7 @@ pub struct GlobalCtxt<'tcx> { pub consts: CommonConsts<'tcx>, /// Resolutions of `extern crate` items produced by resolver. - extern_crate_map: NodeMap, + extern_crate_map: FxHashMap, /// Map indicating what traits are in scope for places where this /// is relevant; generated by resolve. @@ -1116,13 +1115,8 @@ impl<'tcx> TyCtxt<'tcx> { }; let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default(); - for (k, v) in resolutions.trait_map { - let hir_id = definitions.node_id_to_hir_id(k); + for (hir_id, v) in resolutions.trait_map.into_iter() { let map = trait_map.entry(hir_id.owner).or_default(); - let v = v - .into_iter() - .map(|tc| tc.map_import_ids(|id| definitions.node_id_to_hir_id(id))) - .collect(); map.insert(hir_id.local_id, StableVec::new(v)); } @@ -1139,32 +1133,10 @@ impl<'tcx> TyCtxt<'tcx> { consts: common_consts, extern_crate_map: resolutions.extern_crate_map, trait_map, - export_map: resolutions - .export_map - .into_iter() - .map(|(k, v)| { - let exports: Vec<_> = v - .into_iter() - .map(|e| e.map_id(|id| definitions.node_id_to_hir_id(id))) - .collect(); - (k, exports) - }) - .collect(), - maybe_unused_trait_imports: resolutions - .maybe_unused_trait_imports - .into_iter() - .map(|id| definitions.local_def_id(id)) - .collect(), - maybe_unused_extern_crates: resolutions - .maybe_unused_extern_crates - .into_iter() - .map(|(id, sp)| (definitions.local_def_id(id).to_def_id(), sp)) - .collect(), - glob_map: resolutions - .glob_map - .into_iter() - .map(|(id, names)| (definitions.local_def_id(id), names)) - .collect(), + export_map: resolutions.export_map, + maybe_unused_trait_imports: resolutions.maybe_unused_trait_imports, + maybe_unused_extern_crates: resolutions.maybe_unused_extern_crates, + glob_map: resolutions.glob_map, extern_prelude: resolutions.extern_prelude, untracked_crate: krate, definitions, @@ -2729,10 +2701,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) { let id = tcx.hir().local_def_id_to_hir_id(id.expect_local()); tcx.stability().local_deprecation_entry(id) }; - providers.extern_mod_stmt_cnum = |tcx, id| { - let id = tcx.hir().as_local_node_id(id).unwrap(); - tcx.extern_crate_map.get(&id).cloned() - }; + providers.extern_mod_stmt_cnum = |tcx, id| tcx.extern_crate_map.get(&id).cloned(); providers.all_crate_nums = |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); tcx.arena.alloc_slice(&tcx.cstore.crates_untracked()) diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 9e8456689094f..aad3c6889c3ce 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -17,11 +17,11 @@ use crate::ty; use crate::ty::subst::{InternalSubsts, Subst, SubstsRef}; use crate::ty::util::{Discr, IntTypeExt}; use rustc_ast::ast; -use rustc_ast::node_id::{NodeId, NodeMap, NodeSet}; use rustc_attr as attr; use rustc_data_structures::captures::Captures; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::sorted_map::SortedIndexMultiMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; @@ -31,7 +31,7 @@ use rustc_hir as hir; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Namespace, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX}; use rustc_hir::lang_items::{FnMutTraitLangItem, FnOnceTraitLangItem, FnTraitLangItem}; -use rustc_hir::{Constness, GlobMap, Node, TraitMap}; +use rustc_hir::{Constness, Node}; use rustc_index::vec::{Idx, IndexVec}; use rustc_macros::HashStable; use rustc_serialize::{self, Encodable, Encoder}; @@ -120,12 +120,12 @@ mod sty; pub struct ResolverOutputs { pub definitions: rustc_hir::definitions::Definitions, pub cstore: Box, - pub extern_crate_map: NodeMap, - pub trait_map: TraitMap, - pub maybe_unused_trait_imports: NodeSet, - pub maybe_unused_extern_crates: Vec<(NodeId, Span)>, - pub export_map: ExportMap, - pub glob_map: GlobMap, + pub extern_crate_map: FxHashMap, + pub trait_map: FxHashMap>>, + pub maybe_unused_trait_imports: FxHashSet, + pub maybe_unused_extern_crates: Vec<(DefId, Span)>, + pub export_map: ExportMap, + pub glob_map: FxHashMap>, /// Extern prelude entries. The value is `true` if the entry was introduced /// via `extern crate` item and not `--extern` option or compiler built-in. pub extern_prelude: FxHashMap, diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index bfb7f081fc333..9699aff69c013 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1,3 +1,5 @@ +// ignore-tidy-filelength + //! This crate is responsible for the part of name resolution that doesn't require type checker. //! //! Module structure of the crate is built here. @@ -1271,15 +1273,60 @@ impl<'a> Resolver<'a> { } pub fn into_outputs(self) -> ResolverOutputs { + let definitions = self.definitions; + let extern_crate_map = self + .extern_crate_map + .into_iter() + .map(|(k, v)| (definitions.local_def_id(k).to_def_id(), v)) + .collect(); + let export_map = self + .export_map + .into_iter() + .map(|(k, v)| { + ( + k, + v.into_iter() + .map(|e| e.map_id(|id| definitions.node_id_to_hir_id(id))) + .collect(), + ) + }) + .collect(); + let trait_map = self + .trait_map + .into_iter() + .map(|(k, v)| { + ( + definitions.node_id_to_hir_id(k), + v.into_iter() + .map(|tc| tc.map_import_ids(|id| definitions.node_id_to_hir_id(id))) + .collect(), + ) + }) + .collect(); + let maybe_unused_trait_imports = self + .maybe_unused_trait_imports + .into_iter() + .map(|id| definitions.local_def_id(id)) + .collect(); + let maybe_unused_extern_crates = self + .maybe_unused_extern_crates + .into_iter() + .map(|(id, sp)| (definitions.local_def_id(id).to_def_id(), sp)) + .collect(); + let glob_map = self + .glob_map + .into_iter() + .map(|(id, names)| (definitions.local_def_id(id), names)) + .collect(); ResolverOutputs { - definitions: self.definitions, + definitions: definitions, cstore: Box::new(self.crate_loader.into_cstore()), - extern_crate_map: self.extern_crate_map, - export_map: self.export_map, - trait_map: self.trait_map, - glob_map: self.glob_map, - maybe_unused_trait_imports: self.maybe_unused_trait_imports, - maybe_unused_extern_crates: self.maybe_unused_extern_crates, + extern_crate_map, + export_map, + trait_map, + glob_map, + maybe_unused_trait_imports, + maybe_unused_extern_crates, extern_prelude: self .extern_prelude .iter() @@ -1292,12 +1339,53 @@ impl<'a> Resolver<'a> { ResolverOutputs { definitions: self.definitions.clone(), cstore: Box::new(self.cstore().clone()), - extern_crate_map: self.extern_crate_map.clone(), - export_map: self.export_map.clone(), - trait_map: self.trait_map.clone(), - glob_map: self.glob_map.clone(), - maybe_unused_trait_imports: self.maybe_unused_trait_imports.clone(), - maybe_unused_extern_crates: self.maybe_unused_extern_crates.clone(), + extern_crate_map: self + .extern_crate_map + .iter() + .map(|(&k, &v)| (self.definitions.local_def_id(k).to_def_id(), v)) + .collect(), + export_map: self + .export_map + .iter() + .map(|(&k, v)| { + ( + k, + v.iter() + .map(|e| e.map_id(|id| self.definitions.node_id_to_hir_id(id))) + .collect(), + ) + }) + .collect(), + trait_map: self + .trait_map + .iter() + .map(|(&k, v)| { + ( + self.definitions.node_id_to_hir_id(k), + v.iter() + .cloned() + .map(|tc| { + tc.map_import_ids(|id| self.definitions.node_id_to_hir_id(id)) + }) + .collect(), + ) + }) + .collect(), + glob_map: self + .glob_map + .iter() + .map(|(&id, names)| (self.definitions.local_def_id(id), names.clone())) + .collect(), + maybe_unused_trait_imports: self + .maybe_unused_trait_imports + .iter() + .map(|&id| self.definitions.local_def_id(id)) + .collect(), + maybe_unused_extern_crates: self + .maybe_unused_extern_crates + .iter() + .map(|&(id, sp)| (self.definitions.local_def_id(id).to_def_id(), sp)) + .collect(), extern_prelude: self .extern_prelude .iter() diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 8e743ace99bfb..deb9eb5b4b05c 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -882,7 +882,7 @@ impl f32 { /// Returns `max` if `self` is greater than `max`, and `min` if `self` is /// less than `min`. Otherwise this returns `self`. /// - /// Not that this function returns NaN if the initial value was NaN as + /// Note that this function returns NaN if the initial value was NaN as /// well. /// /// # Panics diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index fe64d27b1efc8..b79e550ed265e 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -884,7 +884,7 @@ impl f64 { /// Returns `max` if `self` is greater than `max`, and `min` if `self` is /// less than `min`. Otherwise this returns `self`. /// - /// Not that this function returns NaN if the initial value was NaN as + /// Note that this function returns NaN if the initial value was NaN as /// well. /// /// # Panics diff --git a/src/test/incremental/issue-72386.rs b/src/test/incremental/issue-72386.rs new file mode 100644 index 0000000000000..7a5213e0cd111 --- /dev/null +++ b/src/test/incremental/issue-72386.rs @@ -0,0 +1,21 @@ +// revisions: rpass1 cfail1 rpass3 +// Regression test for issue #72386 +// Checks that we don't ICE when switching to an invalid register +// and back again + +#![feature(asm)] + +#[cfg(any(rpass1, rpass3))] +fn main() { + unsafe { + asm!("nop") + } +} + +#[cfg(cfail1)] +fn main() { + unsafe { + asm!("nop",out("invalid_reg")_) + //[cfail1]~^ ERROR invalid register + } +} diff --git a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs index 0faa9090f4ebc..9bce274027ee0 100644 --- a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs +++ b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.rs @@ -1,3 +1,6 @@ +// compile-flags: -Zsave-analysis +// This is also a regression test for #69415 and the above flag is needed. + #![feature(untagged_unions)] trait Tr1 { type As1: Copy; } diff --git a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr index bfa59d83c82fa..7f2704e1bc371 100644 --- a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr @@ -1,5 +1,5 @@ error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:12:22 + --> $DIR/feature-gate-associated_type_bounds.rs:15:22 | LL | type A: Iterator; | ^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | type A: Iterator; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:15:22 + --> $DIR/feature-gate-associated_type_bounds.rs:18:22 | LL | type B: Iterator; | ^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | type B: Iterator; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:19:20 + --> $DIR/feature-gate-associated_type_bounds.rs:22:20 | LL | struct _St1> { | ^^^^^^^^ @@ -26,7 +26,7 @@ LL | struct _St1> { = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:26:18 + --> $DIR/feature-gate-associated_type_bounds.rs:29:18 | LL | enum _En1> { | ^^^^^^^^ @@ -35,7 +35,7 @@ LL | enum _En1> { = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:33:19 + --> $DIR/feature-gate-associated_type_bounds.rs:36:19 | LL | union _Un1> { | ^^^^^^^^ @@ -44,7 +44,7 @@ LL | union _Un1> { = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:40:37 + --> $DIR/feature-gate-associated_type_bounds.rs:43:37 | LL | type _TaWhere1 where T: Iterator = T; | ^^^^^^^^^^ @@ -53,7 +53,7 @@ LL | type _TaWhere1 where T: Iterator = T; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:43:22 + --> $DIR/feature-gate-associated_type_bounds.rs:46:22 | LL | fn _apit(_: impl Tr1) {} | ^^^^^^^^^ @@ -62,7 +62,7 @@ LL | fn _apit(_: impl Tr1) {} = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:45:26 + --> $DIR/feature-gate-associated_type_bounds.rs:48:26 | LL | fn _apit_dyn(_: &dyn Tr1) {} | ^^^^^^^^^ @@ -71,7 +71,7 @@ LL | fn _apit_dyn(_: &dyn Tr1) {} = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:48:24 + --> $DIR/feature-gate-associated_type_bounds.rs:51:24 | LL | fn _rpit() -> impl Tr1 { S1 } | ^^^^^^^^^ @@ -80,7 +80,7 @@ LL | fn _rpit() -> impl Tr1 { S1 } = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:51:31 + --> $DIR/feature-gate-associated_type_bounds.rs:54:31 | LL | fn _rpit_dyn() -> Box> { Box::new(S1) } | ^^^^^^^^^ @@ -89,7 +89,7 @@ LL | fn _rpit_dyn() -> Box> { Box::new(S1) } = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:54:23 + --> $DIR/feature-gate-associated_type_bounds.rs:57:23 | LL | const _cdef: impl Tr1 = S1; | ^^^^^^^^^ @@ -98,7 +98,7 @@ LL | const _cdef: impl Tr1 = S1; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:60:24 + --> $DIR/feature-gate-associated_type_bounds.rs:63:24 | LL | static _sdef: impl Tr1 = S1; | ^^^^^^^^^ @@ -107,7 +107,7 @@ LL | static _sdef: impl Tr1 = S1; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:67:21 + --> $DIR/feature-gate-associated_type_bounds.rs:70:21 | LL | let _: impl Tr1 = S1; | ^^^^^^^^^ @@ -116,7 +116,7 @@ LL | let _: impl Tr1 = S1; = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-associated_type_bounds.rs:54:14 + --> $DIR/feature-gate-associated_type_bounds.rs:57:14 | LL | const _cdef: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ @@ -124,7 +124,7 @@ LL | const _cdef: impl Tr1 = S1; = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-associated_type_bounds.rs:60:15 + --> $DIR/feature-gate-associated_type_bounds.rs:63:15 | LL | static _sdef: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ @@ -132,7 +132,7 @@ LL | static _sdef: impl Tr1 = S1; = help: add `#![feature(impl_trait_in_bindings)]` to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types - --> $DIR/feature-gate-associated_type_bounds.rs:67:12 + --> $DIR/feature-gate-associated_type_bounds.rs:70:12 | LL | let _: impl Tr1 = S1; | ^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-72455.rs b/src/test/ui/issues/issue-72455.rs new file mode 100644 index 0000000000000..b6c3bb222876d --- /dev/null +++ b/src/test/ui/issues/issue-72455.rs @@ -0,0 +1,27 @@ +// check-pass + +pub trait ResultExt { + type Ok; + fn err_eprint_and_ignore(self) -> Option; +} + +impl ResultExt for std::result::Result +where + E: std::error::Error, +{ + type Ok = O; + fn err_eprint_and_ignore(self) -> Option + where + Self: , + { + match self { + Err(e) => { + eprintln!("{}", e); + None + } + Ok(o) => Some(o), + } + } +} + +fn main() {}