From 720f9e36b5248a21fce29da68aaf21fd394cbf45 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 7 Oct 2024 15:07:58 +0200 Subject: [PATCH] redo the way we do const feature inheritance --- compiler/rustc_attr/src/builtin.rs | 91 ++++++++++++------ .../rustc_const_eval/src/check_consts/mod.rs | 13 +-- compiler/rustc_expand/src/base.rs | 6 +- compiler/rustc_passes/messages.ftl | 1 - compiler/rustc_passes/src/errors.rs | 2 - compiler/rustc_passes/src/stability.rs | 94 +++++++++---------- library/core/src/iter/traits/collect.rs | 1 - library/core/src/lib.rs | 1 - library/core/src/slice/index.rs | 1 - .../consts/const-eval/simd/insert_extract.rs | 3 + tests/ui/consts/copy-intrinsic.rs | 2 + tests/ui/consts/copy-intrinsic.stderr | 8 +- ...rustc-const-stability-require-const.stderr | 14 +-- 13 files changed, 127 insertions(+), 110 deletions(-) diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index fbb9d3f3f3c37..abcd918a098c5 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -16,9 +16,9 @@ use rustc_session::lint::BuiltinLintDiag; use rustc_session::lint::builtin::UNEXPECTED_CFGS; use rustc_session::parse::feature_err; use rustc_session::{RustcVersion, Session}; +use rustc_span::Span; use rustc_span::hygiene::Transparency; use rustc_span::symbol::{Symbol, kw, sym}; -use rustc_span::{DUMMY_SP, Span}; use crate::fluent_generated; use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause}; @@ -92,13 +92,15 @@ impl Stability { #[derive(HashStable_Generic)] pub struct ConstStability { pub level: StabilityLevel, - /// This can be `None` for functions that are not even const-unstable, but - /// are tracked here for the purpose of `safe_to_expose_on_stable`. + /// Says whether this function has an explicit `rustc_const_(un)stable` attribute. + /// If `false`, the const stability information was inferred from the regular + /// stability information. + pub has_const_stable_attr: bool, + /// This can be `None` for functions that are not const-callable from outside code under any + /// feature gate, but are tracked here for the purpose of `safe_to_expose_on_stable`. pub feature: Option, - /// A function that is marked as "safe to expose on stable" must not use any unstable const - /// language features or intrinsics, and all the functions it calls must also be safe to expose - /// on stable. If `level` is `Stable`, this must be `true`. - pub safe_to_expose_on_stable: bool, + /// This is true iff the `const_stable_indirect` attribute is present. + pub const_stable_indirect: bool, /// whether the function has a `#[rustc_promotable]` attribute pub promotable: bool, } @@ -274,14 +276,10 @@ pub fn find_stability( /// Collects stability info from `rustc_const_stable`/`rustc_const_unstable`/`rustc_promotable` /// attributes in `attrs`. Returns `None` if no stability attributes are found. -/// -/// `inherited_feature_gate` says which feature gate this function should be under if it doesn't -/// declare a gate itself, but has `#[rustc_const_stable_indirect]`. pub fn find_const_stability( sess: &Session, attrs: &[Attribute], item_sp: Span, - inherited_feature_gate: Option, ) -> Option<(ConstStability, Span)> { let mut const_stab: Option<(ConstStability, Span)> = None; let mut promotable = false; @@ -302,8 +300,9 @@ pub fn find_const_stability( const_stab = Some(( ConstStability { level, + has_const_stable_attr: true, feature: Some(feature), - safe_to_expose_on_stable: false, + const_stable_indirect: false, promotable: false, }, attr.span, @@ -320,8 +319,9 @@ pub fn find_const_stability( const_stab = Some(( ConstStability { level, + has_const_stable_attr: true, feature: Some(feature), - safe_to_expose_on_stable: true, + const_stable_indirect: false, promotable: false, }, attr.span, @@ -347,7 +347,7 @@ pub fn find_const_stability( match &mut const_stab { Some((stab, _)) => { if stab.is_const_unstable() { - stab.safe_to_expose_on_stable = true; + stab.const_stable_indirect = true; } else { _ = sess.dcx().emit_err(session_diagnostics::RustcConstStableIndirectPairing { span: item_sp, @@ -355,21 +355,8 @@ pub fn find_const_stability( } } _ => { - // `#[rustc_const_stable_indirect]` implicitly makes the function unstably const, - // inheriting the feature gate from `#[unstable]` if it xists, or without any - // feature gate otherwise. - let c = ConstStability { - feature: inherited_feature_gate, - safe_to_expose_on_stable: true, - promotable: false, - level: StabilityLevel::Unstable { - reason: UnstableReason::Default, - issue: None, - is_soft: false, - implied_by: None, - }, - }; - const_stab = Some((c, DUMMY_SP)); + // We ignore the `#[rustc_const_stable_indirect]` here, it should be picked up by + // the `default_const_unstable` logic. } } } @@ -377,6 +364,52 @@ pub fn find_const_stability( const_stab } +/// Called for `fn` that don't have a const stability. +/// +/// `effective_reg_stability` must be the effecive regular stability, i.e. after applying all the +/// rules about "inherited" stability. +pub fn default_const_stability( + _sess: &Session, + is_const_fn: bool, + attrs: &[Attribute], + effective_reg_stability: Option<&Stability>, +) -> Option { + let const_stable_indirect = + attrs.iter().any(|a| a.name_or_empty() == sym::rustc_const_stable_indirect); + // Intrinsics are *not* `const fn` here, and yet we want to add a default const stability + // for them if they are marked `const_stable_indirect`. + if (is_const_fn || const_stable_indirect) + && let Some(reg_stability) = effective_reg_stability + && reg_stability.level.is_unstable() + { + // This has a feature gate, reuse that for const stability. + // We only want to do this if it is an unstable feature gate. + Some(ConstStability { + feature: Some(reg_stability.feature), + has_const_stable_attr: false, + const_stable_indirect, + promotable: false, + level: reg_stability.level, + }) + } else if const_stable_indirect { + // Make it const-unstable without a feature gate, to record the `const_stable_indirect`. + Some(ConstStability { + feature: None, + has_const_stable_attr: false, + const_stable_indirect, + promotable: false, + level: StabilityLevel::Unstable { + reason: UnstableReason::Default, + issue: None, + is_soft: false, + implied_by: None, + }, + }) + } else { + None + } +} + /// Collects stability info from `rustc_default_body_unstable` attributes in `attrs`. /// Returns `None` if no stability attributes are found. pub fn find_body_stability( diff --git a/compiler/rustc_const_eval/src/check_consts/mod.rs b/compiler/rustc_const_eval/src/check_consts/mod.rs index dc5db2e63cb36..ed2a28fd0500a 100644 --- a/compiler/rustc_const_eval/src/check_consts/mod.rs +++ b/compiler/rustc_const_eval/src/check_consts/mod.rs @@ -120,15 +120,16 @@ pub fn is_safe_to_expose_on_stable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> b // We allow calling unmarked local functions *in the current crate*. For the cross-crate // case we require the other crate to explicitly add `#[rustc_const_stable_indirect]` as // a promise that this function is meant to be indirectly const-stable, which will make - // `lookup_const_stability` return `Some`. + // `lookup_const_stability` return `Some`. This ensures that the other crate checked + // recursive const vailidty on that function, even if the other crate is not using + // `staged_api`. def_id.is_local() } Some(stab) => { - // `safe_to_expose_on_stable` implies `is_const_stable`. - if stab.is_const_stable() { - assert!(stab.safe_to_expose_on_stable); - } - stab.safe_to_expose_on_stable + stab.is_const_stable() || stab.const_stable_indirect || + // Non-intrinsic `const fn` without an explicit const stability attribute (i.e., + // with only the implied attribute) are safe to expose on stable. + (!stab.has_const_stable_attr && tcx.intrinsic(def_id).is_none()) } } } diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index c28164fa15b49..d0552a754feb0 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -865,11 +865,7 @@ impl SyntaxExtension { }) .unwrap_or_else(|| (None, helper_attrs)); let stability = attr::find_stability(sess, attrs, span); - // FIXME: this will give a different result than the normal stability computation, since we - // don't inherit stability from the parent. But that's true even for `stability` above so - // it's probably okay? - let const_stability = - attr::find_const_stability(sess, attrs, span, stability.map(|(s, _)| s.feature)); + let const_stability = attr::find_const_stability(sess, attrs, span); let body_stability = attr::find_body_stability(sess, attrs); if let Some((_, sp)) = const_stability { sess.dcx().emit_err(errors::MacroConstStability { diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index a36de35c698e4..3058f1876aeb0 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -456,7 +456,6 @@ passes_maybe_string_interpolation = you might have meant to use string interpola passes_missing_const_err = attributes `#[rustc_const_unstable]`, `#[rustc_const_stable]` and `#[rustc_const_stable_indirect]` require the function or method to be `const` .help = make the function or method const - .label = attribute specified here passes_missing_const_stab_attr = {$descr} has missing const stability attribute diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 42c8edf5bb765..5ad6ef275738f 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -1551,8 +1551,6 @@ pub(crate) struct MissingConstErr { #[primary_span] #[help] pub fn_sig_span: Span, - #[label] - pub const_span: Span, } #[derive(Diagnostic)] diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index ec289d2ec69b0..cc64852f9815d 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -26,7 +26,6 @@ use rustc_session::lint; use rustc_session::lint::builtin::{INEFFECTIVE_UNSTABLE_TRAIT_IMPL, USELESS_DEPRECATED}; use rustc_span::Span; use rustc_span::symbol::{Symbol, sym}; -use rustc_target::spec::abi::Abi; use tracing::{debug, info}; use crate::errors; @@ -106,6 +105,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { def_id: LocalDefId, item_sp: Span, fn_sig: Option<&'tcx hir::FnSig<'tcx>>, + is_foreign_item: bool, kind: AnnotationKind, inherit_deprecation: InheritDeprecation, inherit_const_stability: InheritConstStability, @@ -162,41 +162,9 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { } let stab = attr::find_stability(self.tcx.sess, attrs, item_sp); - let const_stab = attr::find_const_stability( - self.tcx.sess, - attrs, - item_sp, - // Compute the feature gate we inherit if this - // doesn't have its own feature gate. - self.parent_const_stab.and_then(|c| c.feature).or_else(|| { - // Infer the const feature gate from the regular feature gate, - // but only if that regular gate is unstable. - if let Some((s, _)) = stab { - s.is_unstable().then_some(s.feature) - } else if inherit_deprecation.yes() - && let Some(parent_stab) = self.parent_stab - && parent_stab.is_unstable() - { - Some(parent_stab.feature) - } else { - None - } - }), - ); + let const_stab = attr::find_const_stability(self.tcx.sess, attrs, item_sp); let body_stab = attr::find_body_stability(self.tcx.sess, attrs); - // If the current node is a function, has const stability attributes and if it doesn not have an intrinsic ABI, - // check if the function/method is const or the parent impl block is const - if let (Some((_, const_span)), Some(fn_sig)) = (const_stab, fn_sig) - && fn_sig.header.abi != Abi::RustIntrinsic - && !fn_sig.header.is_const() - && (!self.in_trait_impl || !self.tcx.is_const_fn_raw(def_id.to_def_id())) - { - self.tcx - .dcx() - .emit_err(errors::MissingConstErr { fn_sig_span: fn_sig.span, const_span }); - } - // If this is marked const *stable*, it must also be regular-stable. if let Some((const_stab, const_span)) = const_stab && let Some(fn_sig) = fn_sig @@ -219,6 +187,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { debug!("annotate: const_stab not found, parent = {:?}", self.parent_const_stab); if let Some(parent) = self.parent_const_stab { if parent.is_const_unstable() { + // FIXME: if the functiom has `#[rustc_const_stable_indirect]`, we will now ignore it. self.index.const_stab_map.insert(def_id, parent); } } @@ -303,6 +272,31 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { } } + // If a `fn` ends up without const stability annotation, potentially add a default. + if let Some(fn_sig) = fn_sig + && !self.index.const_stab_map.contains_key(&def_id) + { + let stab = self.index.stab_map.get(&def_id); + if let Some(const_stab) = + attr::default_const_stability(self.tcx.sess, fn_sig.header.is_const(), attrs, stab) + { + self.index.const_stab_map.insert(def_id, const_stab); + } + } + + // If the current node is a function with const stability attributes (directly given or + // implied), check if the function/method is const or the parent impl block is const. + if let Some(fn_sig) = fn_sig + && !fn_sig.header.is_const() + // We have to exclude foreign items as they might be intrinsics. Sadly we can't check + // their ABI; `fn_sig.abi` is *not* correct for foreign functions. + && !is_foreign_item + && self.index.const_stab_map.contains_key(&def_id) + && (!self.in_trait_impl || !self.tcx.is_const_fn_raw(def_id.to_def_id())) + { + self.tcx.dcx().emit_err(errors::MissingConstErr { fn_sig_span: fn_sig.span }); + } + self.recurse_with_stability_attrs( depr.map(|(d, _)| DeprecationEntry::local(d, def_id)), stab, @@ -385,6 +379,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { ctor_def_id, i.span, None, + /* is_foreign_item */ false, AnnotationKind::Required, InheritDeprecation::Yes, InheritConstStability::No, @@ -403,6 +398,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { i.owner_id.def_id, i.span, fn_sig, + /* is_foreign_item */ false, kind, InheritDeprecation::Yes, const_stab_inherit, @@ -422,6 +418,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { ti.owner_id.def_id, ti.span, fn_sig, + /* is_foreign_item */ false, AnnotationKind::Required, InheritDeprecation::Yes, InheritConstStability::No, @@ -445,6 +442,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { ii.owner_id.def_id, ii.span, fn_sig, + /* is_foreign_item */ false, kind, InheritDeprecation::Yes, InheritConstStability::No, @@ -460,6 +458,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { var.def_id, var.span, None, + /* is_foreign_item */ false, AnnotationKind::Required, InheritDeprecation::Yes, InheritConstStability::No, @@ -470,6 +469,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { ctor_def_id, var.span, None, + /* is_foreign_item */ false, AnnotationKind::Required, InheritDeprecation::Yes, InheritConstStability::No, @@ -488,6 +488,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { s.def_id, s.span, None, + /* is_foreign_item */ false, AnnotationKind::Required, InheritDeprecation::Yes, InheritConstStability::No, @@ -499,10 +500,15 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { } fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem<'tcx>) { + let fn_sig = match &i.kind { + rustc_hir::ForeignItemKind::Fn(fn_sig, ..) => Some(fn_sig), + _ => None, + }; self.annotate( i.owner_id.def_id, i.span, - None, + fn_sig, + /* is_foreign_item */ true, AnnotationKind::Required, InheritDeprecation::Yes, InheritConstStability::No, @@ -525,6 +531,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { p.def_id, p.span, None, + /* is_foreign_item */ false, kind, InheritDeprecation::No, InheritConstStability::No, @@ -553,7 +560,7 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> { } } - fn check_missing_const_stability(&self, def_id: LocalDefId, span: Span) { + fn check_missing_or_wrong_const_stability(&self, def_id: LocalDefId, span: Span) { if !self.tcx.features().staged_api { return; } @@ -601,7 +608,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> { } // Ensure stable `const fn` have a const stability attribute. - self.check_missing_const_stability(i.owner_id.def_id, i.span); + self.check_missing_or_wrong_const_stability(i.owner_id.def_id, i.span); intravisit::walk_item(self, i) } @@ -615,7 +622,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> { let impl_def_id = self.tcx.hir().get_parent_item(ii.hir_id()); if self.tcx.impl_trait_ref(impl_def_id).is_none() { self.check_missing_stability(ii.owner_id.def_id, ii.span); - self.check_missing_const_stability(ii.owner_id.def_id, ii.span); + self.check_missing_or_wrong_const_stability(ii.owner_id.def_id, ii.span); } intravisit::walk_impl_item(self, ii); } @@ -684,6 +691,7 @@ fn stability_index(tcx: TyCtxt<'_>, (): ()) -> Index { CRATE_DEF_ID, tcx.hir().span(CRATE_HIR_ID), None, + /* is_foreign_item */ false, AnnotationKind::Required, InheritDeprecation::Yes, InheritConstStability::No, @@ -751,15 +759,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> { if features.staged_api { let attrs = self.tcx.hir().attrs(item.hir_id()); let stab = attr::find_stability(self.tcx.sess, attrs, item.span); - // FIXME: this will give a different result than the normal stability - // computation, since we don't inherit stability from the parent. But that's - // true even for `stab` above so it's probably okay? - let const_stab = attr::find_const_stability( - self.tcx.sess, - attrs, - item.span, - stab.map(|(s, _)| s.feature), - ); + let const_stab = attr::find_const_stability(self.tcx.sess, attrs, item.span); // If this impl block has an #[unstable] attribute, give an // error if all involved types and traits are stable, because diff --git a/library/core/src/iter/traits/collect.rs b/library/core/src/iter/traits/collect.rs index 86660f2e375c3..2cf2ea58fd4ee 100644 --- a/library/core/src/iter/traits/collect.rs +++ b/library/core/src/iter/traits/collect.rs @@ -346,7 +346,6 @@ pub trait IntoIterator { fn into_iter(self) -> Self::IntoIter; } -#[rustc_const_unstable(feature = "const_intoiterator_identity", issue = "90603")] #[stable(feature = "rust1", since = "1.0.0")] impl IntoIterator for I { type Item = I::Item; diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 166ddcfcaa446..b1cc5cb6edbfb 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -125,7 +125,6 @@ #![feature(const_fmt_arguments_new)] #![feature(const_hash)] #![feature(const_heap)] -#![feature(const_index_range_slice_index)] #![feature(const_intrinsic_forget)] #![feature(const_ipv4)] #![feature(const_ipv6)] diff --git a/library/core/src/slice/index.rs b/library/core/src/slice/index.rs index 44881803a3a28..231ab7396adfd 100644 --- a/library/core/src/slice/index.rs +++ b/library/core/src/slice/index.rs @@ -313,7 +313,6 @@ unsafe impl SliceIndex<[T]> for usize { /// Because `IndexRange` guarantees `start <= end`, fewer checks are needed here /// than there are for a general `Range` (which might be `100..3`). -#[rustc_const_unstable(feature = "const_index_range_slice_index", issue = "none")] unsafe impl SliceIndex<[T]> for ops::IndexRange { type Output = [T]; diff --git a/tests/ui/consts/const-eval/simd/insert_extract.rs b/tests/ui/consts/const-eval/simd/insert_extract.rs index f4f25327aaf11..57d4b4888caa9 100644 --- a/tests/ui/consts/const-eval/simd/insert_extract.rs +++ b/tests/ui/consts/const-eval/simd/insert_extract.rs @@ -11,8 +11,11 @@ #[repr(simd)] struct f32x4([f32; 4]); extern "rust-intrinsic" { + #[stable(feature = "foo", since = "1.3.37")] #[rustc_const_stable(feature = "foo", since = "1.3.37")] fn simd_insert(x: T, idx: u32, val: U) -> T; + + #[stable(feature = "foo", since = "1.3.37")] #[rustc_const_stable(feature = "foo", since = "1.3.37")] fn simd_extract(x: T, idx: u32) -> U; } diff --git a/tests/ui/consts/copy-intrinsic.rs b/tests/ui/consts/copy-intrinsic.rs index 805c03da546ab..62917c0b98b2c 100644 --- a/tests/ui/consts/copy-intrinsic.rs +++ b/tests/ui/consts/copy-intrinsic.rs @@ -5,9 +5,11 @@ use std::mem; extern "rust-intrinsic" { + #[stable(feature = "dummy", since = "1.0.0")] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize); + #[stable(feature = "dummy", since = "1.0.0")] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")] fn copy(src: *const T, dst: *mut T, count: usize); } diff --git a/tests/ui/consts/copy-intrinsic.stderr b/tests/ui/consts/copy-intrinsic.stderr index da8139129c9f3..29a88f6270bc6 100644 --- a/tests/ui/consts/copy-intrinsic.stderr +++ b/tests/ui/consts/copy-intrinsic.stderr @@ -1,23 +1,23 @@ error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:28:5 + --> $DIR/copy-intrinsic.rs:30:5 | LL | copy_nonoverlapping(0x100 as *const i32, dangle, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x100[noalloc] which is a dangling pointer (it has no provenance) error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:37:5 + --> $DIR/copy-intrinsic.rs:39:5 | LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x28 which is at or beyond the end of the allocation of size 4 bytes error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:44:5 + --> $DIR/copy-intrinsic.rs:46:5 | LL | copy(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy` error[E0080]: evaluation of constant value failed - --> $DIR/copy-intrinsic.rs:50:5 + --> $DIR/copy-intrinsic.rs:52:5 | LL | copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy_nonoverlapping` diff --git a/tests/ui/consts/rustc-const-stability-require-const.stderr b/tests/ui/consts/rustc-const-stability-require-const.stderr index c539b89121f76..d9a7d37cbcd25 100644 --- a/tests/ui/consts/rustc-const-stability-require-const.stderr +++ b/tests/ui/consts/rustc-const-stability-require-const.stderr @@ -1,8 +1,6 @@ error: attributes `#[rustc_const_unstable]`, `#[rustc_const_stable]` and `#[rustc_const_stable_indirect]` require the function or method to be `const` --> $DIR/rustc-const-stability-require-const.rs:7:1 | -LL | #[rustc_const_unstable(feature = "const_foo", issue = "none")] - | -------------------------------------------------------------- attribute specified here LL | pub fn foo() {} | ^^^^^^^^^^^^ | @@ -15,8 +13,6 @@ LL | pub fn foo() {} error: attributes `#[rustc_const_unstable]`, `#[rustc_const_stable]` and `#[rustc_const_stable_indirect]` require the function or method to be `const` --> $DIR/rustc-const-stability-require-const.rs:12:1 | -LL | #[rustc_const_stable(feature = "const_bar", since = "1.0.0")] - | ------------------------------------------------------------- attribute specified here LL | pub fn bar() {} | ^^^^^^^^^^^^ | @@ -29,8 +25,6 @@ LL | pub fn bar() {} error: attributes `#[rustc_const_unstable]`, `#[rustc_const_stable]` and `#[rustc_const_stable_indirect]` require the function or method to be `const` --> $DIR/rustc-const-stability-require-const.rs:21:5 | -LL | #[rustc_const_unstable(feature = "const_salad", issue = "none")] - | ---------------------------------------------------------------- attribute specified here LL | pub fn salad(&self) -> &'static str { "mmmmmm" } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -43,8 +37,6 @@ LL | pub fn salad(&self) -> &'static str { "mmmmmm" } error: attributes `#[rustc_const_unstable]`, `#[rustc_const_stable]` and `#[rustc_const_stable_indirect]` require the function or method to be `const` --> $DIR/rustc-const-stability-require-const.rs:26:5 | -LL | #[rustc_const_unstable(feature = "const_roasted", issue = "none")] - | ------------------------------------------------------------------ attribute specified here LL | pub fn roasted(&self) -> &'static str { "mmmmmmmmmm" } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -57,8 +49,6 @@ LL | pub fn roasted(&self) -> &'static str { "mmmmmmmmmm" } error: attributes `#[rustc_const_unstable]`, `#[rustc_const_stable]` and `#[rustc_const_stable_indirect]` require the function or method to be `const` --> $DIR/rustc-const-stability-require-const.rs:32:1 | -LL | #[rustc_const_stable(feature = "const_bar", since = "1.0.0")] - | ------------------------------------------------------------- attribute specified here LL | pub extern "C" fn bar_c() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -71,8 +61,6 @@ LL | pub extern "C" fn bar_c() {} error: attributes `#[rustc_const_unstable]`, `#[rustc_const_stable]` and `#[rustc_const_stable_indirect]` require the function or method to be `const` --> $DIR/rustc-const-stability-require-const.rs:37:1 | -LL | #[rustc_const_unstable(feature = "const_foo", issue = "none")] - | -------------------------------------------------------------- attribute specified here LL | pub extern "C" fn foo_c() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -102,7 +90,7 @@ error: attributes `#[rustc_const_unstable]`, `#[rustc_const_stable]` and `#[rust --> $DIR/rustc-const-stability-require-const.rs:63:1 | LL | pub fn not_a_const_fn() {} - | ^^^^^^^^^^^^^^^^^^^^^^^ attribute specified here + | ^^^^^^^^^^^^^^^^^^^^^^^ | help: make the function or method const --> $DIR/rustc-const-stability-require-const.rs:63:1