diff --git a/compiler/rustc_borrowck/src/type_check/canonical.rs b/compiler/rustc_borrowck/src/type_check/canonical.rs index 9271a2f4dc718..a581726a15c9c 100644 --- a/compiler/rustc_borrowck/src/type_check/canonical.rs +++ b/compiler/rustc_borrowck/src/type_check/canonical.rs @@ -52,11 +52,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { Some(error_info) => error_info.to_universe_info(old_universe), None => UniverseInfo::other(), }; - for u in old_universe..universe { - self.borrowck_context - .constraints - .universe_causes - .insert(u + 1, universe_info.clone()); + for u in (old_universe + 1)..=universe { + self.borrowck_context.constraints.universe_causes.insert(u, universe_info.clone()); } } @@ -71,15 +68,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { where T: TypeFoldable<'tcx>, { + let old_universe = self.infcx.universe(); + let (instantiated, _) = self.infcx.instantiate_canonical_with_fresh_inference_vars(span, canonical); - for u in 0..canonical.max_universe.as_u32() { - let info = UniverseInfo::other(); - self.borrowck_context - .constraints - .universe_causes - .insert(ty::UniverseIndex::from_u32(u), info); + for u in (old_universe + 1)..=self.infcx.universe() { + self.borrowck_context.constraints.universe_causes.insert(u, UniverseInfo::other()); } instantiated diff --git a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs index 7d4219d70d95b..02909592637d8 100644 --- a/compiler/rustc_borrowck/src/type_check/free_region_relations.rs +++ b/compiler/rustc_borrowck/src/type_check/free_region_relations.rs @@ -8,7 +8,6 @@ use rustc_infer::infer::InferCtxt; use rustc_middle::mir::ConstraintCategory; use rustc_middle::traits::query::OutlivesBound; use rustc_middle::ty::{self, RegionVid, Ty}; -use rustc_span::DUMMY_SP; use rustc_trait_selection::traits::query::type_op::{self, TypeOp}; use std::rc::Rc; use type_op::TypeOpOutput; @@ -219,6 +218,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { } pub(crate) fn create(mut self) -> CreateResult<'tcx> { + let span = self.infcx.tcx.def_span(self.universal_regions.defining_ty.def_id()); let unnormalized_input_output_tys = self .universal_regions .unnormalized_input_tys @@ -250,7 +250,7 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { self.infcx .tcx .sess - .delay_span_bug(DUMMY_SP, &format!("failed to normalize {:?}", ty)); + .delay_span_bug(span, &format!("failed to normalize {:?}", ty)); TypeOpOutput { output: self.infcx.tcx.ty_error(), constraints: None, @@ -301,8 +301,8 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> { &self.region_bound_pairs, self.implicit_region_bound, self.param_env, - Locations::All(DUMMY_SP), - DUMMY_SP, + Locations::All(span), + span, ConstraintCategory::Internal, &mut self.constraints, ) diff --git a/compiler/rustc_borrowck/src/type_check/input_output.rs b/compiler/rustc_borrowck/src/type_check/input_output.rs index 4431a2e8ec60d..a66ddd27dbb2e 100644 --- a/compiler/rustc_borrowck/src/type_check/input_output.rs +++ b/compiler/rustc_borrowck/src/type_check/input_output.rs @@ -7,16 +7,11 @@ //! `RETURN_PLACE` the MIR arguments) are always fully normalized (and //! contain revealed `impl Trait` values). -use crate::type_check::constraint_conversion::ConstraintConversion; use rustc_index::vec::Idx; use rustc_infer::infer::LateBoundRegionConversionTime; use rustc_middle::mir::*; use rustc_middle::ty::Ty; use rustc_span::Span; -use rustc_span::DUMMY_SP; -use rustc_trait_selection::traits::query::type_op::{self, TypeOp}; -use rustc_trait_selection::traits::query::Fallible; -use type_op::TypeOpOutput; use crate::universal_regions::UniversalRegions; @@ -185,7 +180,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } } - #[instrument(skip(self, span), level = "debug")] + #[instrument(skip(self), level = "debug")] fn equate_normalized_input_or_output(&mut self, a: Ty<'tcx>, b: Ty<'tcx>, span: Span) { if let Err(_) = self.eq_types(a, b, Locations::All(span), ConstraintCategory::BoringNoLocation) @@ -194,13 +189,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { // `rustc_traits::normalize_after_erasing_regions`. Ideally, we'd // like to normalize *before* inserting into `local_decls`, but // doing so ends up causing some other trouble. - let b = match self.normalize_and_add_constraints(b) { - Ok(n) => n, - Err(_) => { - debug!("equate_inputs_and_outputs: NoSolution"); - b - } - }; + let b = self.normalize(b, Locations::All(span)); // Note: if we have to introduce new placeholders during normalization above, then we won't have // added those universes to the universe info, which we would want in `relate_tys`. @@ -218,28 +207,4 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } } } - - pub(crate) fn normalize_and_add_constraints(&mut self, t: Ty<'tcx>) -> Fallible> { - let TypeOpOutput { output: norm_ty, constraints, .. } = - self.param_env.and(type_op::normalize::Normalize::new(t)).fully_perform(self.infcx)?; - - debug!("{:?} normalized to {:?}", t, norm_ty); - - for data in constraints { - ConstraintConversion::new( - self.infcx, - &self.borrowck_context.universal_regions, - &self.region_bound_pairs, - self.implicit_region_bound, - self.param_env, - Locations::All(DUMMY_SP), - DUMMY_SP, - ConstraintCategory::Internal, - &mut self.borrowck_context.constraints, - ) - .convert_all(&*data); - } - - Ok(norm_ty) - } } diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 4962d9476b547..6c4b2b3724e34 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -138,8 +138,6 @@ pub(crate) fn type_check<'mir, 'tcx>( use_polonius: bool, ) -> MirTypeckResults<'tcx> { let implicit_region_bound = infcx.tcx.mk_region(ty::ReVar(universal_regions.fr_fn_body)); - let mut universe_causes = FxHashMap::default(); - universe_causes.insert(ty::UniverseIndex::from_u32(0), UniverseInfo::other()); let mut constraints = MirTypeckRegionConstraints { placeholder_indices: PlaceholderIndices::default(), placeholder_index_to_region: IndexVec::default(), @@ -148,7 +146,7 @@ pub(crate) fn type_check<'mir, 'tcx>( member_constraints: MemberConstraintSet::default(), closure_bounds_mapping: Default::default(), type_tests: Vec::default(), - universe_causes, + universe_causes: FxHashMap::default(), }; let CreateResult { @@ -165,9 +163,8 @@ pub(crate) fn type_check<'mir, 'tcx>( debug!(?normalized_inputs_and_output); - for u in ty::UniverseIndex::ROOT..infcx.universe() { - let info = UniverseInfo::other(); - constraints.universe_causes.insert(u, info); + for u in ty::UniverseIndex::ROOT..=infcx.universe() { + constraints.universe_causes.insert(u, UniverseInfo::other()); } let mut borrowck_context = BorrowCheckContext { diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 94a493992e593..2f6686f81965b 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -411,7 +411,7 @@ struct HandlerInner { /// would be unnecessary repetition. taught_diagnostics: FxHashSet, - /// Used to suggest rustc --explain + /// Used to suggest rustc --explain `` emitted_diagnostic_codes: FxIndexSet, /// This set contains a hash of every diagnostic that has been emitted by diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 5ee6c9f238770..92d0fb1aec83f 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -536,7 +536,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ // ========================================================================== rustc_attr!(rustc_allocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), - rustc_attr!(rustc_allocator_nounwind, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), + rustc_attr!(rustc_nounwind, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), rustc_attr!(rustc_reallocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), rustc_attr!(rustc_deallocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), rustc_attr!(rustc_allocator_zeroed, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index ab4b861b6cb60..07a850486294a 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -1580,13 +1580,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs { codegen_fn_attrs.flags |= CodegenFnAttrFlags::TRACK_CALLER; } - // The panic_no_unwind function called by TerminatorKind::Abort will never - // unwind. If the panic handler that it invokes unwind then it will simply - // call the panic handler again. - if Some(did.to_def_id()) == tcx.lang_items().panic_no_unwind() { - codegen_fn_attrs.flags |= CodegenFnAttrFlags::NEVER_UNWIND; - } - let supported_target_features = tcx.supported_target_features(LOCAL_CRATE); let mut inline_span = None; @@ -1647,7 +1640,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs { ) .emit(); } - } else if attr.has_name(sym::rustc_allocator_nounwind) { + } else if attr.has_name(sym::rustc_nounwind) { codegen_fn_attrs.flags |= CodegenFnAttrFlags::NEVER_UNWIND; } else if attr.has_name(sym::rustc_reallocator) { codegen_fn_attrs.flags |= CodegenFnAttrFlags::REALLOCATOR; diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 82d7c0a97cb6a..c0607a102a90e 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2055,7 +2055,14 @@ struct RegionFolder<'a, 'tcx> { tcx: TyCtxt<'tcx>, current_index: ty::DebruijnIndex, region_map: BTreeMap>, - name: &'a mut (dyn FnMut(ty::BoundRegion) -> ty::Region<'tcx> + 'a), + name: &'a mut ( + dyn FnMut( + Option, // Debruijn index of the folded late-bound region + ty::DebruijnIndex, // Index corresponding to binder level + ty::BoundRegion, + ) -> ty::Region<'tcx> + + 'a + ), } impl<'a, 'tcx> ty::TypeFolder<'tcx> for RegionFolder<'a, 'tcx> { @@ -2086,7 +2093,9 @@ impl<'a, 'tcx> ty::TypeFolder<'tcx> for RegionFolder<'a, 'tcx> { fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { let name = &mut self.name; let region = match *r { - ty::ReLateBound(_, br) => *self.region_map.entry(br).or_insert_with(|| name(br)), + ty::ReLateBound(db, br) if db >= self.current_index => { + *self.region_map.entry(br).or_insert_with(|| name(Some(db), self.current_index, br)) + } ty::RePlaceholder(ty::PlaceholderRegion { name: kind, .. }) => { // If this is an anonymous placeholder, don't rename. Otherwise, in some // async fns, we get a `for<'r> Send` bound @@ -2095,7 +2104,10 @@ impl<'a, 'tcx> ty::TypeFolder<'tcx> for RegionFolder<'a, 'tcx> { _ => { // Index doesn't matter, since this is just for naming and these never get bound let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind }; - *self.region_map.entry(br).or_insert_with(|| name(br)) + *self + .region_map + .entry(br) + .or_insert_with(|| name(None, self.current_index, br)) } } } @@ -2234,24 +2246,63 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { }) } else { let tcx = self.tcx; - let mut name = |br: ty::BoundRegion| { - start_or_continue(&mut self, "for<", ", "); - let kind = match br.kind { + + // Closure used in `RegionFolder` to create names for anonymous late-bound + // regions. We use two `DebruijnIndex`es (one for the currently folded + // late-bound region and the other for the binder level) to determine + // whether a name has already been created for the currently folded region, + // see issue #102392. + let mut name = |lifetime_idx: Option, + binder_level_idx: ty::DebruijnIndex, + br: ty::BoundRegion| { + let (name, kind) = match br.kind { ty::BrAnon(_) | ty::BrEnv => { let name = next_name(&self); - do_continue(&mut self, name); - ty::BrNamed(CRATE_DEF_ID.to_def_id(), name) + + if let Some(lt_idx) = lifetime_idx { + if lt_idx > binder_level_idx { + let kind = ty::BrNamed(CRATE_DEF_ID.to_def_id(), name); + return tcx.mk_region(ty::ReLateBound( + ty::INNERMOST, + ty::BoundRegion { var: br.var, kind }, + )); + } + } + + (name, ty::BrNamed(CRATE_DEF_ID.to_def_id(), name)) } ty::BrNamed(def_id, kw::UnderscoreLifetime) => { let name = next_name(&self); - do_continue(&mut self, name); - ty::BrNamed(def_id, name) + + if let Some(lt_idx) = lifetime_idx { + if lt_idx > binder_level_idx { + let kind = ty::BrNamed(def_id, name); + return tcx.mk_region(ty::ReLateBound( + ty::INNERMOST, + ty::BoundRegion { var: br.var, kind }, + )); + } + } + + (name, ty::BrNamed(def_id, name)) } ty::BrNamed(_, name) => { - do_continue(&mut self, name); - br.kind + if let Some(lt_idx) = lifetime_idx { + if lt_idx > binder_level_idx { + let kind = br.kind; + return tcx.mk_region(ty::ReLateBound( + ty::INNERMOST, + ty::BoundRegion { var: br.var, kind }, + )); + } + } + + (name, br.kind) } }; + + start_or_continue(&mut self, "for<", ", "); + do_continue(&mut self, name); tcx.mk_region(ty::ReLateBound(ty::INNERMOST, ty::BoundRegion { var: br.var, kind })) }; let mut folder = RegionFolder { diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 8cb7d147d0253..7f187e0fc7735 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1230,7 +1230,6 @@ symbols! { rust_oom, rustc, rustc_allocator, - rustc_allocator_nounwind, rustc_allocator_zeroed, rustc_allow_const_fn_unstable, rustc_allow_incoherent_impl, @@ -1277,6 +1276,7 @@ symbols! { rustc_mir, rustc_must_implement_one_of, rustc_nonnull_optimization_guaranteed, + rustc_nounwind, rustc_object_lifetime_default, rustc_on_unimplemented, rustc_outlives, diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index 80b067812ba7d..8187517ccfbb4 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -28,16 +28,20 @@ extern "Rust" { // The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to optimize them // like `malloc`, `realloc`, and `free`, respectively. #[rustc_allocator] - #[rustc_allocator_nounwind] + #[cfg_attr(not(bootstrap), rustc_nounwind)] + #[cfg_attr(bootstrap, rustc_allocator_nounwind)] fn __rust_alloc(size: usize, align: usize) -> *mut u8; #[rustc_deallocator] - #[rustc_allocator_nounwind] + #[cfg_attr(not(bootstrap), rustc_nounwind)] + #[cfg_attr(bootstrap, rustc_allocator_nounwind)] fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize); #[rustc_reallocator] - #[rustc_allocator_nounwind] + #[cfg_attr(not(bootstrap), rustc_nounwind)] + #[cfg_attr(bootstrap, rustc_allocator_nounwind)] fn __rust_realloc(ptr: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8; #[rustc_allocator_zeroed] - #[rustc_allocator_nounwind] + #[cfg_attr(not(bootstrap), rustc_nounwind)] + #[cfg_attr(bootstrap, rustc_allocator_nounwind)] fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8; } diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 15ee14398b676..2399262c05b46 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2210,8 +2210,8 @@ macro_rules! assert_unsafe_precondition { #[inline(always)] fn runtime$(<$($tt)*>)?($($i:$ty),*) { if !$e { - // abort instead of panicking to reduce impact on code size - ::core::intrinsics::abort(); + // don't unwind to reduce impact on code size + ::core::panicking::panic_str_nounwind("unsafe precondition violated"); } } #[allow(non_snake_case)] diff --git a/library/core/src/lazy.rs b/library/core/src/lazy.rs deleted file mode 100644 index f8c06c3f9aedb..0000000000000 --- a/library/core/src/lazy.rs +++ /dev/null @@ -1 +0,0 @@ -//! Lazy values and one-time initialization of static data. diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index ca02ae90fdeb2..4c0a3049e75be 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -326,8 +326,6 @@ pub mod cell; pub mod char; pub mod ffi; pub mod iter; -#[unstable(feature = "once_cell", issue = "74465")] -pub mod lazy; pub mod option; pub mod panic; pub mod panicking; diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index d4afe0f5326a3..c4a1b0b0832ab 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -29,6 +29,73 @@ use crate::fmt; use crate::panic::{Location, PanicInfo}; +// First we define the two main entry points that all panics go through. +// In the end both are just convenience wrappers around `panic_impl`. + +/// The entry point for panicking with a formatted message. +/// +/// This is designed to reduce the amount of code required at the call +/// site as much as possible (so that `panic!()` has as low an impact +/// on (e.g.) the inlining of other functions as possible), by moving +/// the actual formatting into this shared place. +#[cold] +// If panic_immediate_abort, inline the abort call, +// otherwise avoid inlining because of it is cold path. +#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] +#[cfg_attr(feature = "panic_immediate_abort", inline)] +#[track_caller] +#[lang = "panic_fmt"] // needed for const-evaluated panics +#[rustc_do_not_const_check] // hooked by const-eval +#[rustc_const_unstable(feature = "core_panic", issue = "none")] +pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! { + if cfg!(feature = "panic_immediate_abort") { + super::intrinsics::abort() + } + + // NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call + // that gets resolved to the `#[panic_handler]` function. + extern "Rust" { + #[lang = "panic_impl"] + fn panic_impl(pi: &PanicInfo<'_>) -> !; + } + + let pi = PanicInfo::internal_constructor(Some(&fmt), Location::caller(), true); + + // SAFETY: `panic_impl` is defined in safe Rust code and thus is safe to call. + unsafe { panic_impl(&pi) } +} + +/// Like panic_fmt, but without unwinding and track_caller to reduce the impact on codesize. +/// Also just works on `str`, as a `fmt::Arguments` needs more space to be passed. +#[cold] +#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] +#[cfg_attr(feature = "panic_immediate_abort", inline)] +#[cfg_attr(not(bootstrap), rustc_nounwind)] +#[cfg_attr(bootstrap, rustc_allocator_nounwind)] +pub fn panic_str_nounwind(msg: &'static str) -> ! { + if cfg!(feature = "panic_immediate_abort") { + super::intrinsics::abort() + } + + // NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call + // that gets resolved to the `#[panic_handler]` function. + extern "Rust" { + #[lang = "panic_impl"] + fn panic_impl(pi: &PanicInfo<'_>) -> !; + } + + // PanicInfo with the `can_unwind` flag set to false forces an abort. + let pieces = [msg]; + let fmt = fmt::Arguments::new_v1(&pieces, &[]); + let pi = PanicInfo::internal_constructor(Some(&fmt), Location::caller(), false); + + // SAFETY: `panic_impl` is defined in safe Rust code and thus is safe to call. + unsafe { panic_impl(&pi) } +} + +// Next we define a bunch of higher-level wrappers that all bottom out in the two core functions +// above. + /// The underlying implementation of libcore's `panic!` macro when no formatting is used. #[cold] // never inline unless panic_immediate_abort to avoid code @@ -84,62 +151,16 @@ fn panic_bounds_check(index: usize, len: usize) -> ! { panic!("index out of bounds: the len is {len} but the index is {index}") } -// This function is called directly by the codegen backend, and must not have -// any extra arguments (including those synthesized by track_caller). +/// Panic because we cannot unwind out of a function. +/// +/// This function is called directly by the codegen backend, and must not have +/// any extra arguments (including those synthesized by track_caller). #[cold] -#[inline(never)] #[lang = "panic_no_unwind"] // needed by codegen for panic in nounwind function +#[cfg_attr(not(bootstrap), rustc_nounwind)] +#[cfg_attr(bootstrap, rustc_allocator_nounwind)] fn panic_no_unwind() -> ! { - if cfg!(feature = "panic_immediate_abort") { - super::intrinsics::abort() - } - - // NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call - // that gets resolved to the `#[panic_handler]` function. - extern "Rust" { - #[lang = "panic_impl"] - fn panic_impl(pi: &PanicInfo<'_>) -> !; - } - - // PanicInfo with the `can_unwind` flag set to false forces an abort. - let fmt = format_args!("panic in a function that cannot unwind"); - let pi = PanicInfo::internal_constructor(Some(&fmt), Location::caller(), false); - - // SAFETY: `panic_impl` is defined in safe Rust code and thus is safe to call. - unsafe { panic_impl(&pi) } -} - -/// The entry point for panicking with a formatted message. -/// -/// This is designed to reduce the amount of code required at the call -/// site as much as possible (so that `panic!()` has as low an impact -/// on (e.g.) the inlining of other functions as possible), by moving -/// the actual formatting into this shared place. -#[cold] -// If panic_immediate_abort, inline the abort call, -// otherwise avoid inlining because of it is cold path. -#[cfg_attr(not(feature = "panic_immediate_abort"), inline(never))] -#[cfg_attr(feature = "panic_immediate_abort", inline)] -#[track_caller] -#[lang = "panic_fmt"] // needed for const-evaluated panics -#[rustc_do_not_const_check] // hooked by const-eval -#[rustc_const_unstable(feature = "core_panic", issue = "none")] -pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! { - if cfg!(feature = "panic_immediate_abort") { - super::intrinsics::abort() - } - - // NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call - // that gets resolved to the `#[panic_handler]` function. - extern "Rust" { - #[lang = "panic_impl"] - fn panic_impl(pi: &PanicInfo<'_>) -> !; - } - - let pi = PanicInfo::internal_constructor(Some(&fmt), Location::caller(), true); - - // SAFETY: `panic_impl` is defined in safe Rust code and thus is safe to call. - unsafe { panic_impl(&pi) } + panic_str_nounwind("panic in a function that cannot unwind") } /// This function is used instead of panic_fmt in const eval. diff --git a/library/std/src/lazy.rs b/library/std/src/lazy.rs deleted file mode 100644 index f8c06c3f9aedb..0000000000000 --- a/library/std/src/lazy.rs +++ /dev/null @@ -1 +0,0 @@ -//! Lazy values and one-time initialization of static data. diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index a497acda4f60c..5484d9c332abd 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -529,9 +529,6 @@ pub mod process; pub mod sync; pub mod time; -#[unstable(feature = "once_cell", issue = "74465")] -pub mod lazy; - // Pull in `std_float` crate into libstd. The contents of // `std_float` are in a different repository: rust-lang/portable-simd. #[path = "../../portable-simd/crates/std_float/src/lib.rs"] diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 7eb8f8bbb30ed..5a7a193897bfa 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -2028,6 +2028,7 @@ impl Step for RustDev { "llvm-nm", "llvm-dwarfdump", "llvm-dis", + "llvm-tblgen", ] { tarball.add_file(src_bindir.join(exe(bin, target)), "bin", 0o755); } diff --git a/src/bootstrap/download-ci-llvm-stamp b/src/bootstrap/download-ci-llvm-stamp index 2e11cf19c3f6a..d19a1ae95cf14 100644 --- a/src/bootstrap/download-ci-llvm-stamp +++ b/src/bootstrap/download-ci-llvm-stamp @@ -1,4 +1,4 @@ Change this file to make users of the `download-ci-llvm` configuration download a new version of LLVM from CI, even if the LLVM submodule hasn’t changed. -Last change is for: https://github.com/rust-lang/rust/pull/97550 +Last change is for: https://github.com/rust-lang/rust/pull/102790 diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 9045354d0b20a..ea97ae4f65127 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -497,18 +497,18 @@ impl Step for Llvm { // https://llvm.org/docs/HowToCrossCompileLLVM.html if target != builder.config.build { - builder.ensure(Llvm { target: builder.config.build }); - // FIXME: if the llvm root for the build triple is overridden then we - // should use llvm-tblgen from there, also should verify that it - // actually exists most of the time in normal installs of LLVM. - let host_bin = builder.llvm_out(builder.config.build).join("bin"); - cfg.define("LLVM_TABLEGEN", host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION)); - // LLVM_NM is required for cross compiling using MSVC - cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION)); - cfg.define( - "LLVM_CONFIG_PATH", - host_bin.join("llvm-config").with_extension(EXE_EXTENSION), - ); + let llvm_config = builder.ensure(Llvm { target: builder.config.build }); + if !builder.config.dry_run { + let llvm_bindir = output(Command::new(&llvm_config).arg("--bindir")); + let host_bin = Path::new(llvm_bindir.trim()); + cfg.define( + "LLVM_TABLEGEN", + host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION), + ); + // LLVM_NM is required for cross compiling using MSVC + cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION)); + } + cfg.define("LLVM_CONFIG_PATH", llvm_config); if builder.config.llvm_clang { let build_bin = builder.llvm_out(builder.config.build).join("build").join("bin"); let clang_tblgen = build_bin.join("clang-tblgen").with_extension(EXE_EXTENSION); diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 32b350074903e..b8b5014ab42e6 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -197,6 +197,35 @@ To do so, the `#[doc(keyword = "...")]` attribute is used. Example: mod empty_mod {} ``` +## Effects of other nightly features + +These nightly-only features are not primarily related to Rustdoc, +but have convenient effects on the documentation produced. + +### `fundamental` types + +Annotating a type with `#[fundamental]` primarily influences coherence rules about generic types, +i.e., they alter whether other crates can provide implementations for that type. +The unstable book [links to further information][unstable-fundamental]. + +[unstable-fundamental]: https://doc.rust-lang.org/unstable-book/language-features/fundamental.html + +For documentation, this has an additional side effect: +If a method is implemented on `F` (or `F<&T>`), +where `F` is a fundamental type, +then the method is not only documented at the page about `F`, +but also on the page about `T`. +In a sense, it makes the type transparent to Rustdoc. +This is especially convenient for types that work as annotated pointers, +such as `Pin<&mut T>`, +as it ensures that methods only implemented through those annotated pointers +can still be found with the type they act on. + +If the `fundamental` feature's effect on coherence is not intended, +such a type can be marked as fundamental only for purposes of documentation +by introducing a custom feature and +limiting the use of `fundamental` to when documentation is built. + ## Unstable command-line arguments These features are enabled by passing a command-line flag to Rustdoc, but the flags in question are @@ -465,6 +494,16 @@ Note that the third item is the crate root, which in this case is undocumented. [JSON format](https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc_json_types/). `--output-format html` has no effect, and is also accepted on stable toolchains. +JSON Output for toolchain crates (`std`, `alloc`, `core`, `test`, and `proc_macro`) +is available via the `rust-docs-json` rustup component. + +```shell +rustup component add --toolchain nightly rust-docs-json +``` + +Then the json files will be present in the `share/doc/rust/json/` directory +of the rustup toolchain directory. + It can also be used with `--show-coverage`. Take a look at its [documentation](#--show-coverage-calculate-the-percentage-of-items-with-documentation) for more information. diff --git a/src/librustdoc/lint.rs b/src/librustdoc/lint.rs index e76c19a61c541..3aad97bc296fb 100644 --- a/src/librustdoc/lint.rs +++ b/src/librustdoc/lint.rs @@ -148,7 +148,7 @@ declare_rustdoc_lint! { /// /// [rustdoc book]: ../../../rustdoc/lints.html#invalid_html_tags INVALID_HTML_TAGS, - Allow, + Warn, "detects invalid HTML tags in doc comments" } diff --git a/src/librustdoc/passes/html_tags.rs b/src/librustdoc/passes/html_tags.rs index 694b03161d929..67fc71665ccf7 100644 --- a/src/librustdoc/passes/html_tags.rs +++ b/src/librustdoc/passes/html_tags.rs @@ -22,10 +22,8 @@ struct InvalidHtmlTagsLinter<'a, 'tcx> { } pub(crate) fn check_invalid_html_tags(krate: Crate, cx: &mut DocContext<'_>) -> Crate { - if cx.tcx.sess.is_nightly_build() { - let mut coll = InvalidHtmlTagsLinter { cx }; - coll.visit_crate(&krate); - } + let mut coll = InvalidHtmlTagsLinter { cx }; + coll.visit_crate(&krate); krate } diff --git a/src/test/rustdoc-ui/intra-doc/malformed-generics.rs b/src/test/rustdoc-ui/intra-doc/malformed-generics.rs index 15e02925ed90d..161625ed28c29 100644 --- a/src/test/rustdoc-ui/intra-doc/malformed-generics.rs +++ b/src/test/rustdoc-ui/intra-doc/malformed-generics.rs @@ -3,17 +3,26 @@ //! [Vec<] //~ ERROR //! [Vec] //~ ERROR +//~^ WARN //! [Vec>>] //~ ERROR +//~^ WARN //! [Vec>>] //~ ERROR +//~^ WARN //! [] //~ ERROR +//~^ WARN //! [] //~ ERROR +//~^ WARN //! [Vec::new()] //~ ERROR +//~^ WARN //! [Vec<>] //~ ERROR +//~^ WARN //! [Vec<>] //~ ERROR //! [Vec<<>>] //~ ERROR // FIXME(#74563) support UFCS //! [::into_iter] //~ ERROR +//~^ WARN //! [ as IntoIterator>::iter] //~ ERROR +//~^ WARN diff --git a/src/test/rustdoc-ui/intra-doc/malformed-generics.stderr b/src/test/rustdoc-ui/intra-doc/malformed-generics.stderr index 5bc0f84e24d13..08349fef88d38 100644 --- a/src/test/rustdoc-ui/intra-doc/malformed-generics.stderr +++ b/src/test/rustdoc-ui/intra-doc/malformed-generics.stderr @@ -23,67 +23,67 @@ LL | //! [Vec] | ^^^^^^^^^^ unbalanced angle brackets error: unresolved link to `Vec>>` - --> $DIR/malformed-generics.rs:6:6 + --> $DIR/malformed-generics.rs:7:6 | LL | //! [Vec>>] | ^^^^^^^^^^^^ unbalanced angle brackets error: unresolved link to `Vec>>` - --> $DIR/malformed-generics.rs:7:6 + --> $DIR/malformed-generics.rs:9:6 | LL | //! [Vec>>] | ^^^^^^^^ unbalanced angle brackets error: unresolved link to ` $DIR/malformed-generics.rs:8:6 + --> $DIR/malformed-generics.rs:11:6 | LL | //! [ $DIR/malformed-generics.rs:9:6 + --> $DIR/malformed-generics.rs:12:6 | LL | //! [Vec::<] | ^^^^^^ unbalanced angle brackets error: unresolved link to `` - --> $DIR/malformed-generics.rs:10:6 + --> $DIR/malformed-generics.rs:13:6 | LL | //! [] | ^^^ missing type for generic parameters error: unresolved link to `` - --> $DIR/malformed-generics.rs:11:6 + --> $DIR/malformed-generics.rs:15:6 | LL | //! [] | ^^^^^^^^^^^^^^^^ missing type for generic parameters error: unresolved link to `Vec::new` - --> $DIR/malformed-generics.rs:12:6 + --> $DIR/malformed-generics.rs:17:6 | LL | //! [Vec::new()] | ^^^^^^^^^^^^^ has invalid path separator error: unresolved link to `Vec<>` - --> $DIR/malformed-generics.rs:13:6 + --> $DIR/malformed-generics.rs:19:6 | LL | //! [Vec<>] | ^^^^^^^^ too many angle brackets error: unresolved link to `Vec<>` - --> $DIR/malformed-generics.rs:14:6 + --> $DIR/malformed-generics.rs:21:6 | LL | //! [Vec<>] | ^^^^^ empty angle brackets error: unresolved link to `Vec<<>>` - --> $DIR/malformed-generics.rs:15:6 + --> $DIR/malformed-generics.rs:22:6 | LL | //! [Vec<<>>] | ^^^^^^^ too many angle brackets error: unresolved link to `::into_iter` - --> $DIR/malformed-generics.rs:18:6 + --> $DIR/malformed-generics.rs:25:6 | LL | //! [::into_iter] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fully-qualified syntax is unsupported @@ -91,12 +91,68 @@ LL | //! [::into_iter] = note: see https://github.com/rust-lang/rust/issues/74563 for more information error: unresolved link to ` as IntoIterator>::iter` - --> $DIR/malformed-generics.rs:19:6 + --> $DIR/malformed-generics.rs:27:6 | LL | //! [ as IntoIterator>::iter] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fully-qualified syntax is unsupported | = note: see https://github.com/rust-lang/rust/issues/74563 for more information -error: aborting due to 15 previous errors +warning: unclosed HTML tag `T` + --> $DIR/malformed-generics.rs:5:13 + | +LL | //! [Vec] + | ^^^ + | + = note: `#[warn(rustdoc::invalid_html_tags)]` on by default + +warning: unclosed HTML tag `T` + --> $DIR/malformed-generics.rs:7:13 + | +LL | //! [Vec>>] + | ^^^ + +warning: unclosed HTML tag `T` + --> $DIR/malformed-generics.rs:9:9 + | +LL | //! [Vec>>] + | ^^^ + +warning: unclosed HTML tag `T` + --> $DIR/malformed-generics.rs:13:6 + | +LL | //! [] + | ^^^ + +warning: unclosed HTML tag `invalid` + --> $DIR/malformed-generics.rs:15:6 + | +LL | //! [] + | ^^^^^^^^ + +warning: unclosed HTML tag `T` + --> $DIR/malformed-generics.rs:17:10 + | +LL | //! [Vec::new()] + | ^^^ + +warning: unclosed HTML tag `T` + --> $DIR/malformed-generics.rs:19:10 + | +LL | //! [Vec<>] + | ^^^ + +warning: unclosed HTML tag `Vec` + --> $DIR/malformed-generics.rs:25:6 + | +LL | //! [::into_iter] + | ^^^^ + +warning: unclosed HTML tag `T` + --> $DIR/malformed-generics.rs:27:10 + | +LL | //! [ as IntoIterator>::iter] + | ^^^ + +error: aborting due to 15 previous errors; 9 warnings emitted diff --git a/src/test/rustdoc/intra-doc/extern-crate-only-used-in-link.rs b/src/test/rustdoc/intra-doc/extern-crate-only-used-in-link.rs index 5d8dcf8bc1d16..ad50887e9221c 100644 --- a/src/test/rustdoc/intra-doc/extern-crate-only-used-in-link.rs +++ b/src/test/rustdoc/intra-doc/extern-crate-only-used-in-link.rs @@ -16,4 +16,4 @@ //! [`empty`] // @has - '//a[@href="../empty2/index.html"]' 'empty2' -//! [empty2] +//! [`empty2`] diff --git a/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr b/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr index 85f7d1dd6748b..7fb8811666536 100644 --- a/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr +++ b/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr @@ -18,7 +18,7 @@ LL | async fn baz(_c: impl FnMut() -> T) where T: Future { | ___________________________________________________________________^ LL | | } | |_^ - = note: required because it captures the following types: `ResumeTy`, `impl for<'a, 'b, 'c> Future`, `()` + = note: required because it captures the following types: `ResumeTy`, `impl Future`, `()` note: required because it's used within this `async` block --> $DIR/issue-70935-complex-spans.rs:16:16 | diff --git a/src/test/ui/coherence/coherence-fn-covariant-bound-vs-static.stderr b/src/test/ui/coherence/coherence-fn-covariant-bound-vs-static.stderr index cfcef9699f372..7dabd97b94e82 100644 --- a/src/test/ui/coherence/coherence-fn-covariant-bound-vs-static.stderr +++ b/src/test/ui/coherence/coherence-fn-covariant-bound-vs-static.stderr @@ -1,10 +1,10 @@ -error[E0119]: conflicting implementations of trait `Trait` for type `for<'r> fn(for<'r> fn(&'r ()))` +error[E0119]: conflicting implementations of trait `Trait` for type `for<'r> fn(fn(&'r ()))` --> $DIR/coherence-fn-covariant-bound-vs-static.rs:17:1 | LL | impl Trait for for<'r> fn(fn(&'r ())) {} | ------------------------------------- first implementation here LL | impl<'a> Trait for fn(fn(&'a ())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'r> fn(for<'r> fn(&'r ()))` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'r> fn(fn(&'r ()))` | = note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details diff --git a/src/test/ui/lifetimes/nested-binder-print.rs b/src/test/ui/lifetimes/nested-binder-print.rs new file mode 100644 index 0000000000000..f97f349fd8243 --- /dev/null +++ b/src/test/ui/lifetimes/nested-binder-print.rs @@ -0,0 +1,10 @@ +struct TwoLt<'a, 'b>(&'a (), &'b ()); +type Foo<'a> = fn(TwoLt<'_, 'a>); + +fn foo() { + let y: for<'a> fn(Foo<'a>); + let x: u32 = y; + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/src/test/ui/lifetimes/nested-binder-print.stderr b/src/test/ui/lifetimes/nested-binder-print.stderr new file mode 100644 index 0000000000000..32dd896932d2e --- /dev/null +++ b/src/test/ui/lifetimes/nested-binder-print.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/nested-binder-print.rs:6:18 + | +LL | let x: u32 = y; + | --- ^ expected `u32`, found fn pointer + | | + | expected due to this + | + = note: expected type `u32` + found fn pointer `for<'a> fn(for<'b> fn(TwoLt<'b, 'a>))` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/lifetimes/re-empty-in-error.stderr b/src/test/ui/lifetimes/re-empty-in-error.stderr index 840707d947081..c35d8ecec5e2d 100644 --- a/src/test/ui/lifetimes/re-empty-in-error.stderr +++ b/src/test/ui/lifetimes/re-empty-in-error.stderr @@ -4,7 +4,7 @@ error: higher-ranked lifetime error LL | foo(&10); | ^^^^^^^^ | - = note: could not prove `for<'b, 'a> &'b (): 'a` + = note: could not prove `for<'b> &'b (): 'a` error: aborting due to previous error diff --git a/src/test/ui/nll/closure-malformed-projection-input-issue-102800.rs b/src/test/ui/nll/closure-malformed-projection-input-issue-102800.rs new file mode 100644 index 0000000000000..25f47f5b6f6c9 --- /dev/null +++ b/src/test/ui/nll/closure-malformed-projection-input-issue-102800.rs @@ -0,0 +1,31 @@ +// Regression test for #102800 +// +// Here we are generating higher-ranked region constraints when normalizing and relating closure +// input types. Previously this was an ICE in the error path because we didn't register enough +// diagnostic information to render the higher-ranked subtyping error. + +// check-fail + +trait Trait { + type Ty; +} + +impl Trait for &'static () { + type Ty = (); +} + +fn main() { + let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; + //~^ ERROR lifetime may not live long enough + //~| ERROR higher-ranked subtype error + //~| ERROR higher-ranked subtype error + //~| ERROR implementation of `Trait` is not general enough + //~| ERROR implementation of `Trait` is not general enough + //~| ERROR implementation of `Trait` is not general enough + //~| ERROR implementation of `Trait` is not general enough + //~| ERROR implementation of `Trait` is not general enough + //~| ERROR implementation of `Trait` is not general enough + //~| ERROR implementation of `Trait` is not general enough + //~| ERROR implementation of `Trait` is not general enough + //~| ERROR implementation of `Trait` is not general enough +} diff --git a/src/test/ui/nll/closure-malformed-projection-input-issue-102800.stderr b/src/test/ui/nll/closure-malformed-projection-input-issue-102800.stderr new file mode 100644 index 0000000000000..dbd5dabd1dacc --- /dev/null +++ b/src/test/ui/nll/closure-malformed-projection-input-issue-102800.stderr @@ -0,0 +1,104 @@ +error: lifetime may not live long enough + --> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 + | +LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; + | ^-^ + | || + | |has type `<&'1 () as Trait>::Ty` + | requires that `'1` must outlive `'static` + +error: higher-ranked subtype error + --> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 + | +LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; + | ^^^ + +error: higher-ranked subtype error + --> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 + | +LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; + | ^^^ + +error: implementation of `Trait` is not general enough + --> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 + | +LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; + | ^^^^^^ implementation of `Trait` is not general enough + | + = note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... + = note: ...but `Trait` is actually implemented for the type `&'static ()` + +error: implementation of `Trait` is not general enough + --> $DIR/closure-malformed-projection-input-issue-102800.rs:18:12 + | +LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Trait` is not general enough + | + = note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... + = note: ...but `Trait` is actually implemented for the type `&'static ()` + +error: implementation of `Trait` is not general enough + --> $DIR/closure-malformed-projection-input-issue-102800.rs:18:12 + | +LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Trait` is not general enough + | + = note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... + = note: ...but `Trait` is actually implemented for the type `&'static ()` + +error: implementation of `Trait` is not general enough + --> $DIR/closure-malformed-projection-input-issue-102800.rs:18:12 + | +LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Trait` is not general enough + | + = note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... + = note: ...but `Trait` is actually implemented for the type `&'static ()` + +error: implementation of `Trait` is not general enough + --> $DIR/closure-malformed-projection-input-issue-102800.rs:18:12 + | +LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Trait` is not general enough + | + = note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... + = note: ...but `Trait` is actually implemented for the type `&'static ()` + +error: implementation of `Trait` is not general enough + --> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 + | +LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; + | ^^^^^^ implementation of `Trait` is not general enough + | + = note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... + = note: ...but `Trait` is actually implemented for the type `&'static ()` + +error: implementation of `Trait` is not general enough + --> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 + | +LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; + | ^^^^^^ implementation of `Trait` is not general enough + | + = note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... + = note: ...but `Trait` is actually implemented for the type `&'static ()` + +error: implementation of `Trait` is not general enough + --> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 + | +LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; + | ^^^^^^ implementation of `Trait` is not general enough + | + = note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... + = note: ...but `Trait` is actually implemented for the type `&'static ()` + +error: implementation of `Trait` is not general enough + --> $DIR/closure-malformed-projection-input-issue-102800.rs:18:48 + | +LL | let _: for<'a> fn(<&'a () as Trait>::Ty) = |_| {}; + | ^^^^^^ implementation of `Trait` is not general enough + | + = note: `&'0 ()` must implement `Trait`, for any lifetime `'0`... + = note: ...but `Trait` is actually implemented for the type `&'static ()` + +error: aborting due to 12 previous errors + diff --git a/src/test/ui/regions/issue-102392.rs b/src/test/ui/regions/issue-102392.rs new file mode 100644 index 0000000000000..87cc1a8e7a88d --- /dev/null +++ b/src/test/ui/regions/issue-102392.rs @@ -0,0 +1,6 @@ +fn g(f: for<'a> fn(fn(&str, &'a str))) -> bool { + f + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/src/test/ui/regions/issue-102392.stderr b/src/test/ui/regions/issue-102392.stderr new file mode 100644 index 0000000000000..56f4c0c5db4b7 --- /dev/null +++ b/src/test/ui/regions/issue-102392.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/issue-102392.rs:2:5 + | +LL | fn g(f: for<'a> fn(fn(&str, &'a str))) -> bool { + | ---- expected `bool` because of return type +LL | f + | ^ expected `bool`, found fn pointer + | + = note: expected type `bool` + found fn pointer `for<'a> fn(for<'b> fn(&'b str, &'a str))` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/where-clauses/higher-ranked-fn-type.quiet.stderr b/src/test/ui/where-clauses/higher-ranked-fn-type.quiet.stderr index d9950a3d9b7cd..30248a7a397b3 100644 --- a/src/test/ui/where-clauses/higher-ranked-fn-type.quiet.stderr +++ b/src/test/ui/where-clauses/higher-ranked-fn-type.quiet.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `for<'b> for<'b> fn(&'b ()): Foo` is not satisfied +error[E0277]: the trait bound `for<'b> fn(&'b ()): Foo` is not satisfied --> $DIR/higher-ranked-fn-type.rs:20:5 | LL | called() - | ^^^^^^ the trait `for<'b> Foo` is not implemented for `for<'b> fn(&'b ())` + | ^^^^^^ the trait `for<'b> Foo` is not implemented for `fn(&'b ())` | note: required by a bound in `called` --> $DIR/higher-ranked-fn-type.rs:12:25 diff --git a/src/test/ui/where-clauses/higher-ranked-fn-type.rs b/src/test/ui/where-clauses/higher-ranked-fn-type.rs index 0d8893e08d319..ab6edde4ee7ea 100644 --- a/src/test/ui/where-clauses/higher-ranked-fn-type.rs +++ b/src/test/ui/where-clauses/higher-ranked-fn-type.rs @@ -18,7 +18,7 @@ where (for<'a> fn(&'a ())): Foo, { called() - //[quiet]~^ ERROR the trait bound `for<'b> for<'b> fn(&'b ()): Foo` is not satisfied + //[quiet]~^ ERROR the trait bound `for<'b> fn(&'b ()): Foo` is not satisfied //[verbose]~^^ ERROR the trait bound `for<'b> fn(&ReLateBound( } diff --git a/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.rs b/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.rs index d9aacdb8aea4e..f85ad5ae5072f 100644 --- a/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.rs +++ b/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.rs @@ -1,7 +1,7 @@ //@revisions: extern_block definition both #![feature(rustc_attrs, c_unwind)] -#[cfg_attr(any(definition, both), rustc_allocator_nounwind)] +#[cfg_attr(any(definition, both), rustc_nounwind)] #[no_mangle] extern "C-unwind" fn nounwind() { //[definition]~^ ERROR: abnormal termination: the program aborted execution @@ -11,7 +11,7 @@ extern "C-unwind" fn nounwind() { fn main() { extern "C-unwind" { - #[cfg_attr(any(extern_block, both), rustc_allocator_nounwind)] + #[cfg_attr(any(extern_block, both), rustc_nounwind)] fn nounwind(); } unsafe { nounwind() } diff --git a/src/tools/rust-analyzer/crates/hir-def/src/builtin_attr.rs b/src/tools/rust-analyzer/crates/hir-def/src/builtin_attr.rs index 0e7ce5f85f966..39581b33a8da2 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/builtin_attr.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/builtin_attr.rs @@ -379,7 +379,7 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[ // ========================================================================== rustc_attr!(rustc_allocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), - rustc_attr!(rustc_allocator_nounwind, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), + rustc_attr!(rustc_nounwind, Normal, template!(Word), WarnFollowing, IMPL_DETAIL), gated!( alloc_error_handler, Normal, template!(Word), WarnFollowing, experimental!(alloc_error_handler)