diff --git a/compiler/rustc_ast_passes/messages.ftl b/compiler/rustc_ast_passes/messages.ftl index 5e10c5a77d97d..7d618f16b26e5 100644 --- a/compiler/rustc_ast_passes/messages.ftl +++ b/compiler/rustc_ast_passes/messages.ftl @@ -290,7 +290,7 @@ ast_passes_trait_fn_const = *[false] {""} } .make_impl_const_sugg = ... and declare the impl to be const instead - .make_trait_const_sugg = ... and declare the trait to be a `#[const_trait]` instead + .make_trait_const_sugg = ... and declare the trait to be const instead ast_passes_trait_object_single_bound = only a single explicit lifetime bound is permitted diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 6b218f34363dd..ffd4c770a6d48 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -48,7 +48,7 @@ enum SelfSemantic { } enum TraitOrTraitImpl { - Trait { span: Span, constness: Const }, + Trait { vis: Span, constness: Const }, TraitImpl { constness: Const, polarity: ImplPolarity, trait_ref_span: Span }, } @@ -109,10 +109,10 @@ impl<'a> AstValidator<'a> { self.outer_trait_or_trait_impl = old; } - fn with_in_trait(&mut self, span: Span, constness: Const, f: impl FnOnce(&mut Self)) { + fn with_in_trait(&mut self, vis: Span, constness: Const, f: impl FnOnce(&mut Self)) { let old = mem::replace( &mut self.outer_trait_or_trait_impl, - Some(TraitOrTraitImpl::Trait { span, constness }), + Some(TraitOrTraitImpl::Trait { vis, constness }), ); f(self); self.outer_trait_or_trait_impl = old; @@ -265,10 +265,12 @@ impl<'a> AstValidator<'a> { None }; + let map = self.sess.source_map(); + let make_trait_const_sugg = if const_trait_impl - && let TraitOrTraitImpl::Trait { span, constness: ast::Const::No } = parent + && let &TraitOrTraitImpl::Trait { vis, constness: ast::Const::No } = parent { - Some(span.shrink_to_lo()) + Some(map.span_extend_while_whitespace(vis).shrink_to_hi()) } else { None }; @@ -279,7 +281,7 @@ impl<'a> AstValidator<'a> { in_impl: matches!(parent, TraitOrTraitImpl::TraitImpl { .. }), const_context_label: parent_constness, remove_const_sugg: ( - self.sess.source_map().span_extend_while_whitespace(span), + map.span_extend_while_whitespace(span), match parent_constness { Some(_) => rustc_errors::Applicability::MachineApplicable, None => rustc_errors::Applicability::MaybeIncorrect, @@ -1165,13 +1167,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> { .. }) => { self.visit_attrs_vis_ident(&item.attrs, &item.vis, ident); - // FIXME(const_trait_impl) remove this - let alt_const_trait_span = - attr::find_by_name(&item.attrs, sym::const_trait).map(|attr| attr.span); - let constness = match (*constness, alt_const_trait_span) { - (Const::Yes(span), _) | (Const::No, Some(span)) => Const::Yes(span), - (Const::No, None) => Const::No, - }; if *is_auto == IsAuto::Yes { // Auto traits cannot have generics, super traits nor contain items. self.deny_generic_params(generics, ident.span); @@ -1188,7 +1183,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { this.visit_generics(generics); walk_list!(this, visit_param_bound, bounds, BoundKind::SuperTraits) }); - self.with_in_trait(item.span, constness, |this| { + self.with_in_trait(item.vis.span, *constness, |this| { walk_list!(this, visit_assoc_item, items, AssocCtxt::Trait); }); } diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/errors.rs index fd75e999d1381..7c63b8e35999e 100644 --- a/compiler/rustc_ast_passes/src/errors.rs +++ b/compiler/rustc_ast_passes/src/errors.rs @@ -56,7 +56,7 @@ pub(crate) struct TraitFnConst { pub make_impl_const_sugg: Option, #[suggestion( ast_passes_make_trait_const_sugg, - code = "#[const_trait]\n", + code = "const ", applicability = "maybe-incorrect" )] pub make_trait_const_sugg: Option, diff --git a/compiler/rustc_attr_parsing/src/attributes/traits.rs b/compiler/rustc_attr_parsing/src/attributes/traits.rs index ced3bcad2293a..03a517efb1bd3 100644 --- a/compiler/rustc_attr_parsing/src/attributes/traits.rs +++ b/compiler/rustc_attr_parsing/src/attributes/traits.rs @@ -101,17 +101,6 @@ impl NoArgsAttributeParser for DoNotImplementViaObjectParser { const CREATE: fn(Span) -> AttributeKind = AttributeKind::DoNotImplementViaObject; } -// FIXME(const_trait_impl): remove this -// Const traits - -pub(crate) struct ConstTraitParser; -impl NoArgsAttributeParser for ConstTraitParser { - const PATH: &[Symbol] = &[sym::const_trait]; - const ON_DUPLICATE: OnDuplicate = OnDuplicate::Warn; - const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Trait)]); - const CREATE: fn(Span) -> AttributeKind = AttributeKind::ConstTrait; -} - // Specialization pub(crate) struct SpecializationTraitParser; diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index a3473c675dd59..4789f27785cb9 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -64,7 +64,7 @@ use crate::attributes::stability::{ }; use crate::attributes::test_attrs::{IgnoreParser, ShouldPanicParser}; use crate::attributes::traits::{ - AllowIncoherentImplParser, CoinductiveParser, ConstTraitParser, DenyExplicitImplParser, + AllowIncoherentImplParser, CoinductiveParser, DenyExplicitImplParser, DoNotImplementViaObjectParser, FundamentalParser, MarkerParser, ParenSugarParser, PointeeParser, SkipDuringMethodDispatchParser, SpecializationTraitParser, TypeConstParser, UnsafeSpecializationMarkerParser, @@ -218,7 +218,6 @@ attribute_parsers!( Single>, Single>, Single>, - Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_const_eval/src/check_consts/ops.rs b/compiler/rustc_const_eval/src/check_consts/ops.rs index d81b31b704b3d..f606158e40180 100644 --- a/compiler/rustc_const_eval/src/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/check_consts/ops.rs @@ -381,23 +381,21 @@ fn build_error_for_const_call<'tcx>( `{trait_name}` is not const", ), ); - if parent.is_local() && ccx.tcx.sess.is_nightly_build() { + if let Some(parent) = parent.as_local() + && ccx.tcx.sess.is_nightly_build() + { if !ccx.tcx.features().const_trait_impl() { err.help( "add `#![feature(const_trait_impl)]` to the crate attributes to \ - enable `#[const_trait]`", + enable const traits", ); } - let indentation = ccx - .tcx - .sess - .source_map() - .indentation_before(trait_span) - .unwrap_or_default(); + let span = ccx.tcx.hir_expect_item(parent).vis_span; + let span = ccx.tcx.sess.source_map().span_extend_while_whitespace(span); err.span_suggestion_verbose( - trait_span.shrink_to_lo(), + span.shrink_to_hi(), format!("consider making trait `{trait_name}` const"), - format!("#[const_trait]\n{indentation}"), + "const ".to_owned(), Applicability::MaybeIncorrect, ); } else if !ccx.tcx.sess.is_nightly_build() { diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 5dcb5df55720c..fd3974922349e 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -846,14 +846,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ EncodeCrossCrate::No, experimental!(register_tool), ), - // RFC 2632 - // FIXME(const_trait_impl) remove this - gated!( - const_trait, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No, const_trait_impl, - "`const_trait` is a temporary placeholder for marking a trait that is suitable for `const` \ - `impls` and all default bodies as `const`, which may be removed or renamed in the \ - future." - ), // lang-team MCP 147 gated!( deprecated_safe, Normal, template!(List: &[r#"since = "version", note = "...""#]), ErrorFollowing, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index a5f7debe1787b..830096527ab32 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -489,9 +489,6 @@ pub enum AttributeKind { /// Represents `#[rustc_const_stable_indirect]`. ConstStabilityIndirect, - /// Represents `#[const_trait]`. - ConstTrait(Span), - /// Represents `#[coroutine]`. Coroutine(Span), diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index d59fccb3f1a0b..2ccfdc2ad983d 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -32,7 +32,6 @@ impl AttributeKind { ConstContinue(..) => No, ConstStability { .. } => Yes, ConstStabilityIndirect => No, - ConstTrait(..) => No, Coroutine(..) => No, Coverage(..) => No, CrateName { .. } => No, diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 6e62e50d3af82..454af28419b0d 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -890,15 +890,6 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef { }; let attrs = tcx.get_all_attrs(def_id); - // Only regular traits can be const. - // FIXME(const_trait_impl): remove this - let constness = if constness == hir::Constness::Const - || !is_alias && find_attr!(attrs, AttributeKind::ConstTrait(_)) - { - hir::Constness::Const - } else { - hir::Constness::NotConst - }; let paren_sugar = find_attr!(attrs, AttributeKind::ParenSugar(_)); if paren_sugar && !tcx.features().unboxed_closures() { @@ -1366,22 +1357,27 @@ fn check_impl_constness( } let trait_name = tcx.item_name(trait_def_id).to_string(); - let (local_trait_span, suggestion_pre) = - match (trait_def_id.is_local(), tcx.sess.is_nightly_build()) { - (true, true) => ( - Some(tcx.def_span(trait_def_id).shrink_to_lo()), + let (suggestion, suggestion_pre) = match (trait_def_id.as_local(), tcx.sess.is_nightly_build()) + { + (Some(trait_def_id), true) => { + let span = tcx.hir_expect_item(trait_def_id).vis_span; + let span = tcx.sess.source_map().span_extend_while_whitespace(span); + + ( + Some(span.shrink_to_hi()), if tcx.features().const_trait_impl() { "" } else { "enable `#![feature(const_trait_impl)]` in your crate and " }, - ), - (false, _) | (_, false) => (None, ""), - }; + ) + } + (None, _) | (_, false) => (None, ""), + }; tcx.dcx().emit_err(errors::ConstImplForNonConstTrait { trait_ref_span: hir_trait_ref.path.span, trait_name, - local_trait_span, + suggestion, suggestion_pre, marking: (), adding: (), diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index dbad98fd79528..209b0156de323 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -500,13 +500,8 @@ pub(crate) struct ConstImplForNonConstTrait { #[label] pub trait_ref_span: Span, pub trait_name: String, - #[suggestion( - applicability = "machine-applicable", - // FIXME(const_trait_impl) fix this suggestion - code = "#[const_trait] ", - style = "verbose" - )] - pub local_trait_span: Option, + #[suggestion(applicability = "machine-applicable", code = "const ", style = "verbose")] + pub suggestion: Option, pub suggestion_pre: &'static str, #[note] pub marking: (), @@ -523,14 +518,9 @@ pub(crate) struct ConstBoundForNonConstTrait { pub modifier: &'static str, #[note] pub def_span: Option, - pub suggestion_pre: &'static str, - #[suggestion( - applicability = "machine-applicable", - // FIXME(const_trait_impl) fix this suggestion - code = "#[const_trait] ", - style = "verbose" - )] + #[suggestion(applicability = "machine-applicable", code = "const ", style = "verbose")] pub suggestion: Option, + pub suggestion_pre: &'static str, pub trait_name: String, } diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index c1eb277b1380b..1edc96a74d26b 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -880,28 +880,33 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { } if let hir::BoundConstness::Always(span) | hir::BoundConstness::Maybe(span) = constness - && !self.tcx().is_const_trait(trait_def_id) + && !tcx.is_const_trait(trait_def_id) { let (def_span, suggestion, suggestion_pre) = - match (trait_def_id.is_local(), self.tcx().sess.is_nightly_build()) { - (true, true) => ( - None, - Some(tcx.def_span(trait_def_id).shrink_to_lo()), - if self.tcx().features().const_trait_impl() { - "" - } else { - "enable `#![feature(const_trait_impl)]` in your crate and " - }, - ), - (false, _) | (_, false) => (Some(tcx.def_span(trait_def_id)), None, ""), + match (trait_def_id.as_local(), tcx.sess.is_nightly_build()) { + (Some(trait_def_id), true) => { + let span = tcx.hir_expect_item(trait_def_id).vis_span; + let span = tcx.sess.source_map().span_extend_while_whitespace(span); + + ( + None, + Some(span.shrink_to_hi()), + if self.tcx().features().const_trait_impl() { + "" + } else { + "enable `#![feature(const_trait_impl)]` in your crate and " + }, + ) + } + (None, _) | (_, false) => (Some(tcx.def_span(trait_def_id)), None, ""), }; self.dcx().emit_err(crate::errors::ConstBoundForNonConstTrait { span, modifier: constness.as_str(), def_span, - trait_name: self.tcx().def_path_str(trait_def_id), - suggestion_pre, + trait_name: tcx.def_path_str(trait_def_id), suggestion, + suggestion_pre, }); } else { match predicate_filter { diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 5944a1e8da5d1..30a36d51c7965 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -235,7 +235,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | AttributeKind::Marker(..) | AttributeKind::SkipDuringMethodDispatch { .. } | AttributeKind::Coinductive(..) - | AttributeKind::ConstTrait(..) | AttributeKind::DenyExplicitImpl(..) | AttributeKind::DoNotImplementViaObject(..) | AttributeKind::SpecializationTrait(..) diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 38718bad9e57e..951f556ff3664 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -746,7 +746,6 @@ symbols! { const_raw_ptr_to_usize_cast, const_refs_to_cell, const_refs_to_static, - const_trait, const_trait_bound_opt_out, const_trait_impl, const_try, diff --git a/library/core/src/array/equality.rs b/library/core/src/array/equality.rs index c2c7ccf0daa23..ec79a657e58e2 100644 --- a/library/core/src/array/equality.rs +++ b/library/core/src/array/equality.rs @@ -132,9 +132,8 @@ where #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] impl const Eq for [T; N] {} -#[const_trait] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] -trait SpecArrayEq: Sized { +const trait SpecArrayEq: Sized { fn spec_eq(a: &[Self; N], b: &[Other; N]) -> bool; fn spec_ne(a: &[Self; N], b: &[Other; N]) -> bool; } diff --git a/library/core/src/cmp/bytewise.rs b/library/core/src/cmp/bytewise.rs index 2265fa7a3531c..f0f5f656405a9 100644 --- a/library/core/src/cmp/bytewise.rs +++ b/library/core/src/cmp/bytewise.rs @@ -17,8 +17,7 @@ use crate::num::NonZero; /// - Neither `Self` nor `Rhs` have provenance, so integer comparisons are correct. /// - `>::{eq,ne}` are equivalent to comparing the bytes. #[rustc_specialization_trait] -#[const_trait] // FIXME(const_trait_impl): Migrate to `const unsafe trait` once #146122 is fixed. -pub(crate) unsafe trait BytewiseEq: +pub(crate) const unsafe trait BytewiseEq: [const] PartialEq + Sized { } diff --git a/library/core/src/ops/range.rs b/library/core/src/ops/range.rs index d781f3f7ace4a..a0b74ff383ea4 100644 --- a/library/core/src/ops/range.rs +++ b/library/core/src/ops/range.rs @@ -816,9 +816,8 @@ impl Bound<&T> { /// by range syntax like `..`, `a..`, `..b`, `..=c`, `d..e`, or `f..=g`. #[stable(feature = "collections_range", since = "1.28.0")] #[rustc_diagnostic_item = "RangeBounds"] -#[const_trait] #[rustc_const_unstable(feature = "const_range", issue = "none")] -pub trait RangeBounds { +pub const trait RangeBounds { /// Start index bound. /// /// Returns the start value as a `Bound`. @@ -954,9 +953,8 @@ pub trait RangeBounds { /// `IntoBounds` is implemented by Rust’s built-in range types, produced /// by range syntax like `..`, `a..`, `..b`, `..=c`, `d..e`, or `f..=g`. #[unstable(feature = "range_into_bounds", issue = "136903")] -#[const_trait] #[rustc_const_unstable(feature = "const_range", issue = "none")] -pub trait IntoBounds: [const] RangeBounds { +pub const trait IntoBounds: [const] RangeBounds { /// Convert this range into the start and end bounds. /// Returns `(start_bound, end_bound)`. /// @@ -1319,9 +1317,8 @@ pub enum OneSidedRangeBound { /// Types that implement `OneSidedRange` must return `Bound::Unbounded` /// from one of `RangeBounds::start_bound` or `RangeBounds::end_bound`. #[unstable(feature = "one_sided_range", issue = "69780")] -#[const_trait] #[rustc_const_unstable(feature = "const_range", issue = "none")] -pub trait OneSidedRange: RangeBounds { +pub const trait OneSidedRange: RangeBounds { /// An internal-only helper function for `split_off` and /// `split_off_mut` that returns the bound of the one-sided range. fn bound(self) -> (OneSidedRangeBound, T); diff --git a/library/core/src/slice/cmp.rs b/library/core/src/slice/cmp.rs index 103630aba0f79..fd1ca23fb79c5 100644 --- a/library/core/src/slice/cmp.rs +++ b/library/core/src/slice/cmp.rs @@ -155,18 +155,16 @@ where } #[doc(hidden)] -#[const_trait] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] // intermediate trait for specialization of slice's PartialOrd -trait SlicePartialOrd: Sized { +const trait SlicePartialOrd: Sized { fn partial_compare(left: &[Self], right: &[Self]) -> Option; } #[doc(hidden)] -#[const_trait] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] // intermediate trait for specialization of slice's PartialOrd chaining methods -trait SliceChain: Sized { +const trait SliceChain: Sized { fn chaining_lt(left: &[Self], right: &[Self]) -> ControlFlow; fn chaining_le(left: &[Self], right: &[Self]) -> ControlFlow; fn chaining_gt(left: &[Self], right: &[Self]) -> ControlFlow; @@ -244,9 +242,8 @@ impl const SlicePartialOrd for A { } #[rustc_specialization_trait] -#[const_trait] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] -trait AlwaysApplicableOrd: [const] SliceOrd + [const] Ord {} +const trait AlwaysApplicableOrd: [const] SliceOrd + [const] Ord {} macro_rules! always_applicable_ord { ($([$($p:tt)*] $t:ty,)*) => { @@ -265,10 +262,9 @@ always_applicable_ord! { } #[doc(hidden)] -#[const_trait] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] // intermediate trait for specialization of slice's Ord -trait SliceOrd: Sized { +const trait SliceOrd: Sized { fn compare(left: &[Self], right: &[Self]) -> Ordering; } @@ -292,8 +288,7 @@ impl SliceOrd for A { /// * For every `x` and `y` of this type, `Ord(x, y)` must return the same /// value as `Ord::cmp(transmute::<_, u8>(x), transmute::<_, u8>(y))`. #[rustc_specialization_trait] -#[const_trait] -unsafe trait UnsignedBytewiseOrd: [const] Ord {} +const unsafe trait UnsignedBytewiseOrd: [const] Ord {} #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] unsafe impl const UnsignedBytewiseOrd for bool {} diff --git a/library/core/src/slice/index.rs b/library/core/src/slice/index.rs index 1a4dcebf36483..d8ed521f44353 100644 --- a/library/core/src/slice/index.rs +++ b/library/core/src/slice/index.rs @@ -159,9 +159,8 @@ mod private_slice_index { message = "the type `{T}` cannot be indexed by `{Self}`", label = "slice indices are of type `usize` or ranges of `usize`" )] -#[const_trait] // FIXME(const_trait_impl): Migrate to `const unsafe trait` once #146122 is fixed. #[rustc_const_unstable(feature = "const_index", issue = "143775")] -pub unsafe trait SliceIndex: private_slice_index::Sealed { +pub const unsafe trait SliceIndex: private_slice_index::Sealed { /// The output type returned by methods. #[stable(feature = "slice_get_slice", since = "1.28.0")] type Output: ?Sized; diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr index 646688604674c..46b0ce96b1fee 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr @@ -38,8 +38,8 @@ LL | trait Bar: [const] Foo {} | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | const trait Foo { + | +++++ error: `[const]` can only be applied to `const` traits --> const-super-trait.rs:9:17 @@ -49,8 +49,8 @@ LL | const fn foo(x: &T) { | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: [const] Foo {} - | ++++++++++++++ +LL | const trait Bar: [const] Foo {} + | +++++ error[E0015]: cannot call non-const method `::a` in constant functions --> const-super-trait.rs:10:7 @@ -65,13 +65,12 @@ LL | trait Foo { | ^^^^^^^^^ this trait is not const LL | fn a(&self); | ------------ this method is not const - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable const traits = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | -LL + #[const_trait] -LL | trait Foo { - | +LL | const trait Foo { + | +++++ error: aborting due to 6 previous errors diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr index d0e7edf42cdd5..c1b35e733a1ff 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr @@ -18,8 +18,8 @@ LL | trait Bar: [const] Foo {} | help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | const trait Foo { + | +++++ error: `[const]` can only be applied to `const` traits --> const-super-trait.rs:9:17 @@ -29,8 +29,8 @@ LL | const fn foo(x: &T) { | help: mark `Bar` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: [const] Foo {} - | ++++++++++++++ +LL | const trait Bar: [const] Foo {} + | +++++ error[E0015]: cannot call non-const method `::a` in constant functions --> const-super-trait.rs:10:7 @@ -48,9 +48,8 @@ LL | fn a(&self); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | -LL + #[const_trait] -LL | trait Foo { - | +LL | const trait Foo { + | +++++ error: aborting due to 4 previous errors diff --git a/tests/rustdoc/constant/const-effect-param.rs b/tests/rustdoc/constant/const-effect-param.rs index 3dc63fb3d30f6..28c1a43fa9daf 100644 --- a/tests/rustdoc/constant/const-effect-param.rs +++ b/tests/rustdoc/constant/const-effect-param.rs @@ -3,8 +3,7 @@ #![crate_name = "foo"] #![feature(const_trait_impl)] -#[const_trait] -pub trait Tr { +pub const trait Tr { fn f(); } diff --git a/tests/rustdoc/constant/const-trait-and-impl-methods.rs b/tests/rustdoc/constant/const-trait-and-impl-methods.rs index 30fc539e5533f..987a816d465bd 100644 --- a/tests/rustdoc/constant/const-trait-and-impl-methods.rs +++ b/tests/rustdoc/constant/const-trait-and-impl-methods.rs @@ -1,5 +1,4 @@ -// check that we don't render `#[const_trait]` methods as `const` - even for -// const `trait`s and `impl`s. +// check that we don't render assoc fns as `const` - even for const `trait`s and `impl`s. #![crate_name = "foo"] #![feature(const_trait_impl)] @@ -8,8 +7,7 @@ //@ !has - '//*[@id="tymethod.required"]' 'const' //@ has - '//*[@id="method.defaulted"]' 'fn defaulted()' //@ !has - '//*[@id="method.defaulted"]' 'const' -#[const_trait] -pub trait Tr { +pub const trait Tr { fn required(); fn defaulted() {} } diff --git a/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs b/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs index e304eff14e8cb..f263410d93afe 100644 --- a/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs +++ b/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs @@ -19,8 +19,7 @@ pub struct S(T); //@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' //@ !has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' '[const]' //@ has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' ': Fn' -#[const_trait] -pub trait Tr { +pub const trait Tr { //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]' '[const]' //@ has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '[const]' diff --git a/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs b/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs index d7d7b32e2b8b7..6f47091b18bf8 100644 --- a/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs +++ b/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs @@ -1,8 +1,7 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -pub trait Resource {} +pub const trait Resource {} pub const fn load() -> i32 { 0 diff --git a/tests/ui/const-generics/const_trait_fn-issue-88433.rs b/tests/ui/const-generics/const_trait_fn-issue-88433.rs index 2f92a528bf728..51c4fefaf70d5 100644 --- a/tests/ui/const-generics/const_trait_fn-issue-88433.rs +++ b/tests/ui/const-generics/const_trait_fn-issue-88433.rs @@ -3,8 +3,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Func { +const trait Func { type Output; fn call_once(self, arg: T) -> Self::Output; diff --git a/tests/ui/const-generics/issues/issue-88119.rs b/tests/ui/const-generics/issues/issue-88119.rs index a49b2ab8b03d1..d44b5ab985b01 100644 --- a/tests/ui/const-generics/issues/issue-88119.rs +++ b/tests/ui/const-generics/issues/issue-88119.rs @@ -3,8 +3,7 @@ #![allow(incomplete_features)] #![feature(const_trait_impl, generic_const_exprs)] -#[const_trait] -trait ConstName { +const trait ConstName { const NAME_BYTES: &'static [u8]; } diff --git a/tests/ui/const-generics/issues/issue-88119.stderr b/tests/ui/const-generics/issues/issue-88119.stderr index 0aabf48011dcd..0bdf153468bcc 100644 --- a/tests/ui/const-generics/issues/issue-88119.stderr +++ b/tests/ui/const-generics/issues/issue-88119.stderr @@ -7,85 +7,85 @@ LL | #![feature(const_trait_impl, generic_const_exprs)] = help: remove one of these features error[E0275]: overflow evaluating the requirement `&T: [const] ConstName` - --> $DIR/issue-88119.rs:19:49 + --> $DIR/issue-88119.rs:18:49 | LL | impl const ConstName for &T | ^^ error[E0275]: overflow evaluating the requirement `&T: ConstName` - --> $DIR/issue-88119.rs:19:49 + --> $DIR/issue-88119.rs:18:49 | LL | impl const ConstName for &T | ^^ error[E0275]: overflow evaluating the requirement `[(); name_len::()] well-formed` - --> $DIR/issue-88119.rs:21:5 + --> $DIR/issue-88119.rs:20:5 | LL | [(); name_len::()]:, | ^^^^^^^^^^^^^^^^^^^^^ | note: required by a bound in `<&T as ConstName>` - --> $DIR/issue-88119.rs:21:5 + --> $DIR/issue-88119.rs:20:5 | LL | [(); name_len::()]:, | ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&T as ConstName>` error[E0275]: overflow evaluating the requirement `[(); name_len::()] well-formed` - --> $DIR/issue-88119.rs:21:10 + --> $DIR/issue-88119.rs:20:10 | LL | [(); name_len::()]:, | ^^^^^^^^^^^^^^^ | note: required by a bound in `<&T as ConstName>` - --> $DIR/issue-88119.rs:21:5 + --> $DIR/issue-88119.rs:20:5 | LL | [(); name_len::()]:, | ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&T as ConstName>` error[E0275]: overflow evaluating the requirement `&mut T: [const] ConstName` - --> $DIR/issue-88119.rs:26:49 + --> $DIR/issue-88119.rs:25:49 | LL | impl const ConstName for &mut T | ^^^^^^ error[E0275]: overflow evaluating the requirement `&mut T: ConstName` - --> $DIR/issue-88119.rs:26:49 + --> $DIR/issue-88119.rs:25:49 | LL | impl const ConstName for &mut T | ^^^^^^ error[E0275]: overflow evaluating the requirement `[(); name_len::()] well-formed` - --> $DIR/issue-88119.rs:28:5 + --> $DIR/issue-88119.rs:27:5 | LL | [(); name_len::()]:, | ^^^^^^^^^^^^^^^^^^^^^ | note: required by a bound in `<&mut T as ConstName>` - --> $DIR/issue-88119.rs:28:5 + --> $DIR/issue-88119.rs:27:5 | LL | [(); name_len::()]:, | ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&mut T as ConstName>` error[E0275]: overflow evaluating the requirement `[(); name_len::()] well-formed` - --> $DIR/issue-88119.rs:28:10 + --> $DIR/issue-88119.rs:27:10 | LL | [(); name_len::()]:, | ^^^^^^^^^^^^^^^ | note: required by a bound in `<&mut T as ConstName>` - --> $DIR/issue-88119.rs:28:5 + --> $DIR/issue-88119.rs:27:5 | LL | [(); name_len::()]:, | ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&mut T as ConstName>` error[E0275]: overflow evaluating the requirement `&&mut u8: ConstName` - --> $DIR/issue-88119.rs:33:35 + --> $DIR/issue-88119.rs:32:35 | LL | pub const ICE_1: &'static [u8] = <&&mut u8 as ConstName>::NAME_BYTES; | ^^^^^^^^ error[E0275]: overflow evaluating the requirement `&mut &u8: ConstName` - --> $DIR/issue-88119.rs:34:35 + --> $DIR/issue-88119.rs:33:35 | LL | pub const ICE_2: &'static [u8] = <&mut &u8 as ConstName>::NAME_BYTES; | ^^^^^^^^ diff --git a/tests/ui/const-generics/issues/issue-98629.rs b/tests/ui/const-generics/issues/issue-98629.rs index 1d2d3012a6ee1..4d65ce8681958 100644 --- a/tests/ui/const-generics/issues/issue-98629.rs +++ b/tests/ui/const-generics/issues/issue-98629.rs @@ -1,7 +1,6 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Trait { +const trait Trait { const N: usize; } diff --git a/tests/ui/const-generics/issues/issue-98629.stderr b/tests/ui/const-generics/issues/issue-98629.stderr index e7582aaae11aa..3e929356d2cdf 100644 --- a/tests/ui/const-generics/issues/issue-98629.stderr +++ b/tests/ui/const-generics/issues/issue-98629.stderr @@ -1,5 +1,5 @@ error[E0046]: not all trait items implemented, missing: `N` - --> $DIR/issue-98629.rs:8:1 + --> $DIR/issue-98629.rs:7:1 | LL | const N: usize; | -------------- `N` from trait diff --git a/tests/ui/consts/constifconst-call-in-const-position.rs b/tests/ui/consts/constifconst-call-in-const-position.rs index da29030dbc746..3069014088bbb 100644 --- a/tests/ui/consts/constifconst-call-in-const-position.rs +++ b/tests/ui/consts/constifconst-call-in-const-position.rs @@ -3,8 +3,7 @@ #![feature(const_trait_impl, generic_const_exprs)] #![allow(incomplete_features)] -#[const_trait] -pub trait Tr { +pub const trait Tr { fn a() -> usize; } diff --git a/tests/ui/consts/constifconst-call-in-const-position.stderr b/tests/ui/consts/constifconst-call-in-const-position.stderr index e84e686251a5b..70e8ac988e515 100644 --- a/tests/ui/consts/constifconst-call-in-const-position.stderr +++ b/tests/ui/consts/constifconst-call-in-const-position.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `T: const Tr` is not satisfied - --> $DIR/constifconst-call-in-const-position.rs:17:39 + --> $DIR/constifconst-call-in-const-position.rs:16:39 | LL | const fn foo() -> [u8; T::a()] { | ^ error[E0277]: the trait bound `T: const Tr` is not satisfied - --> $DIR/constifconst-call-in-const-position.rs:18:9 + --> $DIR/constifconst-call-in-const-position.rs:17:9 | LL | [0; T::a()] | ^ diff --git a/tests/ui/delegation/unsupported.current.stderr b/tests/ui/delegation/unsupported.current.stderr index 55564e8f231f7..5c4115630c002 100644 --- a/tests/ui/delegation/unsupported.current.stderr +++ b/tests/ui/delegation/unsupported.current.stderr @@ -46,7 +46,7 @@ LL | reuse to_reuse1::foo; | ^^^ error[E0283]: type annotations needed - --> $DIR/unsupported.rs:56:18 + --> $DIR/unsupported.rs:55:18 | LL | reuse Trait::foo; | ^^^ cannot infer type diff --git a/tests/ui/delegation/unsupported.next.stderr b/tests/ui/delegation/unsupported.next.stderr index 606a25d4269a1..a626da9a1442c 100644 --- a/tests/ui/delegation/unsupported.next.stderr +++ b/tests/ui/delegation/unsupported.next.stderr @@ -38,7 +38,7 @@ LL | reuse to_reuse1::foo; | ^^^ error[E0283]: type annotations needed - --> $DIR/unsupported.rs:56:18 + --> $DIR/unsupported.rs:55:18 | LL | reuse Trait::foo; | ^^^ cannot infer type diff --git a/tests/ui/delegation/unsupported.rs b/tests/ui/delegation/unsupported.rs index 79bab342da091..5e2bd832a4d84 100644 --- a/tests/ui/delegation/unsupported.rs +++ b/tests/ui/delegation/unsupported.rs @@ -48,8 +48,7 @@ mod recursive { } mod effects { - #[const_trait] - trait Trait { + const trait Trait { fn foo(); } diff --git a/tests/ui/generic-const-items/const-trait-impl.rs b/tests/ui/generic-const-items/const-trait-impl.rs index e11d346b712d8..197c97ef9fed7 100644 --- a/tests/ui/generic-const-items/const-trait-impl.rs +++ b/tests/ui/generic-const-items/const-trait-impl.rs @@ -11,8 +11,7 @@ const CREATE: T = T::create(); pub const K0: i32 = CREATE::; pub const K1: i32 = CREATE; // arg inferred -#[const_trait] -trait Create { +const trait Create { fn create() -> Self; } @@ -22,7 +21,7 @@ impl const Create for i32 { } } -trait Mod { // doesn't need to be a `#[const_trait]` +trait Mod { // doesn't need to be a const trait const CREATE: T; } diff --git a/tests/ui/parser/impls-nested-within-fns-semantic-1.rs b/tests/ui/parser/impls-nested-within-fns-semantic-1.rs index f06d19d7f5ec6..be8a7ddf26693 100644 --- a/tests/ui/parser/impls-nested-within-fns-semantic-1.rs +++ b/tests/ui/parser/impls-nested-within-fns-semantic-1.rs @@ -4,8 +4,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Trait { +const trait Trait { fn required(); } diff --git a/tests/ui/resolve/issue-39559-2.stderr b/tests/ui/resolve/issue-39559-2.stderr index 4bfa1d1b1322f..27b6020dd1c61 100644 --- a/tests/ui/resolve/issue-39559-2.stderr +++ b/tests/ui/resolve/issue-39559-2.stderr @@ -11,13 +11,12 @@ LL | trait Dim { | ^^^^^^^^^ this trait is not const LL | fn dim() -> usize; | ------------------ this associated function is not const - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable const traits = note: calls in constants are limited to constant functions, tuple structs and tuple variants help: consider making trait `Dim` const | -LL + #[const_trait] -LL | trait Dim { - | +LL | const trait Dim { + | +++++ error[E0015]: cannot call non-const associated function `::dim` in constants --> $DIR/issue-39559-2.rs:16:15 @@ -32,13 +31,12 @@ LL | trait Dim { | ^^^^^^^^^ this trait is not const LL | fn dim() -> usize; | ------------------ this associated function is not const - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable const traits = note: calls in constants are limited to constant functions, tuple structs and tuple variants help: consider making trait `Dim` const | -LL + #[const_trait] -LL | trait Dim { - | +LL | const trait Dim { + | +++++ error: aborting due to 2 previous errors diff --git a/tests/ui/specialization/const_trait_impl.rs b/tests/ui/specialization/const_trait_impl.rs index e917263d1936a..adfef77a15ca3 100644 --- a/tests/ui/specialization/const_trait_impl.rs +++ b/tests/ui/specialization/const_trait_impl.rs @@ -5,14 +5,12 @@ use std::fmt::Debug; #[rustc_specialization_trait] -#[const_trait] -pub unsafe trait Sup { +pub const unsafe trait Sup { fn foo() -> u32; } #[rustc_specialization_trait] -#[const_trait] -pub unsafe trait Sub: [const] Sup {} +pub const unsafe trait Sub: [const] Sup {} unsafe impl const Sup for u8 { default fn foo() -> u32 { @@ -28,8 +26,7 @@ unsafe impl const Sup for () { unsafe impl const Sub for () {} -#[const_trait] -pub trait A { +pub const trait A { fn a() -> u32; } diff --git a/tests/ui/specialization/const_trait_impl.stderr b/tests/ui/specialization/const_trait_impl.stderr index a21a48997ee71..93ed7234e5634 100644 --- a/tests/ui/specialization/const_trait_impl.stderr +++ b/tests/ui/specialization/const_trait_impl.stderr @@ -1,5 +1,5 @@ error: `[const]` can only be applied to `const` traits - --> $DIR/const_trait_impl.rs:36:9 + --> $DIR/const_trait_impl.rs:33:9 | LL | impl const A for T { | ^^^^^^^ can't be applied to `Debug` @@ -8,7 +8,7 @@ note: `Debug` can't be used with `[const]` because it isn't `const` --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL error: `[const]` can only be applied to `const` traits - --> $DIR/const_trait_impl.rs:42:9 + --> $DIR/const_trait_impl.rs:39:9 | LL | impl const A for T { | ^^^^^^^ can't be applied to `Debug` @@ -17,7 +17,7 @@ note: `Debug` can't be used with `[const]` because it isn't `const` --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL error: `[const]` can only be applied to `const` traits - --> $DIR/const_trait_impl.rs:48:9 + --> $DIR/const_trait_impl.rs:45:9 | LL | impl const A for T { | ^^^^^^^ can't be applied to `Debug` @@ -26,7 +26,7 @@ note: `Debug` can't be used with `[const]` because it isn't `const` --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL error: `[const]` can only be applied to `const` traits - --> $DIR/const_trait_impl.rs:42:9 + --> $DIR/const_trait_impl.rs:39:9 | LL | impl const A for T { | ^^^^^^^ can't be applied to `Debug` @@ -36,7 +36,7 @@ note: `Debug` can't be used with `[const]` because it isn't `const` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `const` traits - --> $DIR/const_trait_impl.rs:36:9 + --> $DIR/const_trait_impl.rs:33:9 | LL | impl const A for T { | ^^^^^^^ can't be applied to `Debug` @@ -46,7 +46,7 @@ note: `Debug` can't be used with `[const]` because it isn't `const` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `[const]` can only be applied to `const` traits - --> $DIR/const_trait_impl.rs:48:9 + --> $DIR/const_trait_impl.rs:45:9 | LL | impl const A for T { | ^^^^^^^ can't be applied to `Debug` diff --git a/tests/ui/structs/default-field-values/support.rs b/tests/ui/structs/default-field-values/support.rs index 8209d6dd4a093..670557e12c110 100644 --- a/tests/ui/structs/default-field-values/support.rs +++ b/tests/ui/structs/default-field-values/support.rs @@ -27,7 +27,7 @@ pub enum Bar { } } -#[const_trait] pub trait ConstDefault { +pub const trait ConstDefault { fn value() -> Self; } diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs index ff1ce949f097d..0bda247d5f4eb 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs @@ -4,8 +4,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Trait { +const trait Trait { type Assoc: [const] Trait; fn func() -> i32; } diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs index 5773f2281c390..2498a1ad03bf7 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs @@ -3,8 +3,7 @@ #![feature(const_trait_impl, generic_const_exprs)] #![allow(incomplete_features)] -#[const_trait] -trait Trait { +const trait Trait { type Assoc: [const] Trait; fn func() -> i32; } diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr index a0474e65efeba..3976c71899e6b 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `U: [const] Other` is not satisfied - --> $DIR/assoc-type-const-bound-usage-fail-2.rs:24:5 + --> $DIR/assoc-type-const-bound-usage-fail-2.rs:22:5 | LL | T::Assoc::::func(); | ^^^^^^^^^^^^^ error[E0277]: the trait bound `U: [const] Other` is not satisfied - --> $DIR/assoc-type-const-bound-usage-fail-2.rs:26:5 + --> $DIR/assoc-type-const-bound-usage-fail-2.rs:24:5 | LL | ::Assoc::::func(); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr index a0474e65efeba..3976c71899e6b 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `U: [const] Other` is not satisfied - --> $DIR/assoc-type-const-bound-usage-fail-2.rs:24:5 + --> $DIR/assoc-type-const-bound-usage-fail-2.rs:22:5 | LL | T::Assoc::::func(); | ^^^^^^^^^^^^^ error[E0277]: the trait bound `U: [const] Other` is not satisfied - --> $DIR/assoc-type-const-bound-usage-fail-2.rs:26:5 + --> $DIR/assoc-type-const-bound-usage-fail-2.rs:24:5 | LL | ::Assoc::::func(); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs index 5338c27bedca5..a817fff36fa64 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs @@ -8,8 +8,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Trait { +const trait Trait { type Assoc: [const] Trait where U: [const] Other; @@ -17,8 +16,7 @@ trait Trait { fn func(); } -#[const_trait] -trait Other {} +const trait Other {} const fn fails() { T::Assoc::::func(); diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr index 20b01d06e8d5e..1f0248365ce6e 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `T: [const] Trait` is not satisfied - --> $DIR/assoc-type-const-bound-usage-fail.rs:17:5 + --> $DIR/assoc-type-const-bound-usage-fail.rs:16:5 | LL | T::Assoc::func(); | ^^^^^^^^ error[E0277]: the trait bound `T: [const] Trait` is not satisfied - --> $DIR/assoc-type-const-bound-usage-fail.rs:19:5 + --> $DIR/assoc-type-const-bound-usage-fail.rs:18:5 | LL | ::Assoc::func(); | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr index 20b01d06e8d5e..1f0248365ce6e 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `T: [const] Trait` is not satisfied - --> $DIR/assoc-type-const-bound-usage-fail.rs:17:5 + --> $DIR/assoc-type-const-bound-usage-fail.rs:16:5 | LL | T::Assoc::func(); | ^^^^^^^^ error[E0277]: the trait bound `T: [const] Trait` is not satisfied - --> $DIR/assoc-type-const-bound-usage-fail.rs:19:5 + --> $DIR/assoc-type-const-bound-usage-fail.rs:18:5 | LL | ::Assoc::func(); | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs index 4940b3a1aa6ce..65c3a06e89c2d 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs @@ -7,8 +7,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Trait { +const trait Trait { type Assoc: [const] Trait; fn func(); } diff --git a/tests/ui/traits/const-traits/assoc-type.current.stderr b/tests/ui/traits/const-traits/assoc-type.current.stderr index 7fe086550f1c2..b730fd8ad3662 100644 --- a/tests/ui/traits/const-traits/assoc-type.current.stderr +++ b/tests/ui/traits/const-traits/assoc-type.current.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `NonConstAdd: [const] Add` is not satisfied - --> $DIR/assoc-type.rs:37:16 + --> $DIR/assoc-type.rs:35:16 | LL | type Bar = NonConstAdd; | ^^^^^^^^^^^ | note: required by a bound in `Foo::Bar` - --> $DIR/assoc-type.rs:33:15 + --> $DIR/assoc-type.rs:31:15 | LL | type Bar: [const] Add; | ^^^^^^^^^^^ required by this bound in `Foo::Bar` diff --git a/tests/ui/traits/const-traits/assoc-type.next.stderr b/tests/ui/traits/const-traits/assoc-type.next.stderr index 7fe086550f1c2..b730fd8ad3662 100644 --- a/tests/ui/traits/const-traits/assoc-type.next.stderr +++ b/tests/ui/traits/const-traits/assoc-type.next.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `NonConstAdd: [const] Add` is not satisfied - --> $DIR/assoc-type.rs:37:16 + --> $DIR/assoc-type.rs:35:16 | LL | type Bar = NonConstAdd; | ^^^^^^^^^^^ | note: required by a bound in `Foo::Bar` - --> $DIR/assoc-type.rs:33:15 + --> $DIR/assoc-type.rs:31:15 | LL | type Bar: [const] Add; | ^^^^^^^^^^^ required by this bound in `Foo::Bar` diff --git a/tests/ui/traits/const-traits/assoc-type.rs b/tests/ui/traits/const-traits/assoc-type.rs index 1faef1b0a3251..3fb6f679a1933 100644 --- a/tests/ui/traits/const-traits/assoc-type.rs +++ b/tests/ui/traits/const-traits/assoc-type.rs @@ -3,8 +3,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Add { +const trait Add { type Output; fn add(self, other: Rhs) -> Self::Output; @@ -28,8 +27,7 @@ impl Add for NonConstAdd { } } -#[const_trait] -trait Foo { +const trait Foo { type Bar: [const] Add; } @@ -38,8 +36,7 @@ impl const Foo for NonConstAdd { //~^ ERROR the trait bound `NonConstAdd: [const] Add` is not satisfied } -#[const_trait] -trait Baz { +const trait Baz { type Qux: Add; } diff --git a/tests/ui/traits/const-traits/attr-misuse.rs b/tests/ui/traits/const-traits/attr-misuse.rs deleted file mode 100644 index 70dfcbf47d289..0000000000000 --- a/tests/ui/traits/const-traits/attr-misuse.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(const_trait_impl)] - -#[const_trait] -trait A { - #[const_trait] //~ ERROR attribute cannot be used on - fn foo(self); -} - -#[const_trait] //~ ERROR attribute cannot be used on -fn main() {} diff --git a/tests/ui/traits/const-traits/attr-misuse.stderr b/tests/ui/traits/const-traits/attr-misuse.stderr deleted file mode 100644 index 2f86efac4c921..0000000000000 --- a/tests/ui/traits/const-traits/attr-misuse.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: `#[const_trait]` attribute cannot be used on required trait methods - --> $DIR/attr-misuse.rs:5:5 - | -LL | #[const_trait] - | ^^^^^^^^^^^^^^ - | - = help: `#[const_trait]` can only be applied to traits - -error: `#[const_trait]` attribute cannot be used on functions - --> $DIR/attr-misuse.rs:9:1 - | -LL | #[const_trait] - | ^^^^^^^^^^^^^^ - | - = help: `#[const_trait]` can only be applied to traits - -error: aborting due to 2 previous errors - diff --git a/tests/ui/traits/const-traits/auxiliary/cross-crate.rs b/tests/ui/traits/const-traits/auxiliary/cross-crate.rs index 01921c140cbcf..7d464d57c3651 100644 --- a/tests/ui/traits/const-traits/auxiliary/cross-crate.rs +++ b/tests/ui/traits/const-traits/auxiliary/cross-crate.rs @@ -1,8 +1,7 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -pub trait MyTrait { +pub const trait MyTrait { fn defaulted_func(&self) {} fn func(self); } diff --git a/tests/ui/traits/const-traits/auxiliary/minicore.rs b/tests/ui/traits/const-traits/auxiliary/minicore.rs index d2133bbbcaea4..2e5df13d021d5 100644 --- a/tests/ui/traits/const-traits/auxiliary/minicore.rs +++ b/tests/ui/traits/const-traits/auxiliary/minicore.rs @@ -35,8 +35,7 @@ impl Copy for u8 {} impl Copy for &T {} #[lang = "add"] -#[const_trait] -pub trait Add { +pub const trait Add { type Output; fn add(self, rhs: Rhs) -> Self::Output; @@ -58,8 +57,7 @@ const fn bar() { } #[lang = "Try"] -#[const_trait] -pub trait Try: FromResidual { +pub const trait Try: FromResidual { type Output; type Residual; @@ -70,8 +68,7 @@ pub trait Try: FromResidual { fn branch(self) -> ControlFlow; } -#[const_trait] -pub trait FromResidual::Residual> { +pub const trait FromResidual::Residual> { #[lang = "from_residual"] fn from_residual(residual: R) -> Self; } @@ -83,24 +80,21 @@ enum ControlFlow { Break(B), } -#[const_trait] #[lang = "fn"] #[rustc_paren_sugar] -pub trait Fn: [const] FnMut { +pub const trait Fn: [const] FnMut { extern "rust-call" fn call(&self, args: Args) -> Self::Output; } -#[const_trait] #[lang = "fn_mut"] #[rustc_paren_sugar] -pub trait FnMut: [const] FnOnce { +pub const trait FnMut: [const] FnOnce { extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; } -#[const_trait] #[lang = "fn_once"] #[rustc_paren_sugar] -pub trait FnOnce { +pub const trait FnOnce { #[lang = "fn_once_output"] type Output; @@ -128,20 +122,17 @@ impl Receiver for T { } #[lang = "destruct"] -#[const_trait] -pub trait Destruct {} +pub const trait Destruct {} #[lang = "freeze"] pub unsafe auto trait Freeze {} #[lang = "drop"] -#[const_trait] -pub trait Drop { +pub const trait Drop { fn drop(&mut self); } -#[const_trait] -pub trait Residual { +pub const trait Residual { type TryType: [const] Try + Try; } @@ -168,15 +159,13 @@ const fn panic_display() { fn panic_fmt() {} #[lang = "index"] -#[const_trait] -pub trait Index { +pub const trait Index { type Output: MetaSized; fn index(&self, index: Idx) -> &Self::Output; } -#[const_trait] -pub unsafe trait SliceIndex { +pub const unsafe trait SliceIndex { type Output: MetaSized; fn index(self, slice: &T) -> &Self::Output; } @@ -214,8 +203,7 @@ pub trait CoerceUnsized {} impl<'a, 'b: 'a, T: PointeeSized + Unsize, U: PointeeSized> CoerceUnsized<&'a U> for &'b T {} #[lang = "deref"] -#[const_trait] -pub trait Deref { +pub const trait Deref { #[lang = "deref_target"] type Target: MetaSized; @@ -273,13 +261,11 @@ where } } -#[const_trait] -pub trait Into: Sized { +pub const trait Into: Sized { fn into(self) -> T; } -#[const_trait] -pub trait From: Sized { +pub const trait From: Sized { fn from(value: T) -> Self; } @@ -313,8 +299,7 @@ fn from_str(s: &str) -> Result { } #[lang = "eq"] -#[const_trait] -pub trait PartialEq: PointeeSized { +pub const trait PartialEq: PointeeSized { fn eq(&self, other: &Rhs) -> bool; fn ne(&self, other: &Rhs) -> bool { !self.eq(other) @@ -337,8 +322,7 @@ impl PartialEq for str { } #[lang = "not"] -#[const_trait] -pub trait Not { +pub const trait Not { type Output; fn not(self) -> Self::Output; } @@ -462,8 +446,7 @@ impl Deref for Ref<'_, T> { #[lang = "clone"] #[rustc_trivial_field_reads] -#[const_trait] -pub trait Clone: Sized { +pub const trait Clone: Sized { fn clone(&self) -> Self; fn clone_from(&mut self, source: &Self) where diff --git a/tests/ui/traits/const-traits/auxiliary/staged-api.rs b/tests/ui/traits/const-traits/auxiliary/staged-api.rs index 933a25769dca2..b2b1e0615c37f 100644 --- a/tests/ui/traits/const-traits/auxiliary/staged-api.rs +++ b/tests/ui/traits/const-traits/auxiliary/staged-api.rs @@ -5,8 +5,7 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "unstable", issue = "none")] -#[const_trait] -pub trait MyTrait { +pub const trait MyTrait { #[stable(feature = "rust1", since = "1.0.0")] fn func(); } diff --git a/tests/ui/traits/const-traits/call-const-closure.rs b/tests/ui/traits/const-traits/call-const-closure.rs index 70dfaf724c9bd..c4293579aea8e 100644 --- a/tests/ui/traits/const-traits/call-const-closure.rs +++ b/tests/ui/traits/const-traits/call-const-closure.rs @@ -4,8 +4,7 @@ #![feature(const_trait_impl, const_closures)] #![allow(incomplete_features)] -#[const_trait] -trait Bar { +const trait Bar { fn foo(&self); } diff --git a/tests/ui/traits/const-traits/call-const-closure.stderr b/tests/ui/traits/const-traits/call-const-closure.stderr index 9de22759c2003..9a851a97f186a 100644 --- a/tests/ui/traits/const-traits/call-const-closure.stderr +++ b/tests/ui/traits/const-traits/call-const-closure.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `(): [const] Bar` is not satisfied - --> $DIR/call-const-closure.rs:17:18 + --> $DIR/call-const-closure.rs:16:18 | LL | (const || ().foo())(); | ^^^ diff --git a/tests/ui/traits/const-traits/call-const-in-conditionally-const.rs b/tests/ui/traits/const-traits/call-const-in-conditionally-const.rs index 4e8c2cd171e6c..52d25b85c01dc 100644 --- a/tests/ui/traits/const-traits/call-const-in-conditionally-const.rs +++ b/tests/ui/traits/const-traits/call-const-in-conditionally-const.rs @@ -1,7 +1,7 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] trait Foo { +const trait Foo { fn foo(); } diff --git a/tests/ui/traits/const-traits/call-const-trait-method-fail.rs b/tests/ui/traits/const-traits/call-const-trait-method-fail.rs index c03d3e950b0b4..bb481d0d9ea94 100644 --- a/tests/ui/traits/const-traits/call-const-trait-method-fail.rs +++ b/tests/ui/traits/const-traits/call-const-trait-method-fail.rs @@ -1,8 +1,7 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -pub trait Plus { +pub const trait Plus { fn plus(self, rhs: Self) -> Self; } diff --git a/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr b/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr index c6f93629379ac..6e235d9cb6f0c 100644 --- a/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr +++ b/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `u32: [const] Plus` is not satisfied - --> $DIR/call-const-trait-method-fail.rs:26:5 + --> $DIR/call-const-trait-method-fail.rs:25:5 | LL | a.plus(b) | ^ diff --git a/tests/ui/traits/const-traits/call-const-trait-method-pass.rs b/tests/ui/traits/const-traits/call-const-trait-method-pass.rs index 2d9c2ca086178..b12e7e82664b7 100644 --- a/tests/ui/traits/const-traits/call-const-trait-method-pass.rs +++ b/tests/ui/traits/const-traits/call-const-trait-method-pass.rs @@ -20,8 +20,7 @@ impl const PartialEq for Int { } } -#[const_trait] -pub trait Plus { +pub const trait Plus { fn plus(self, rhs: Self) -> Self; } diff --git a/tests/ui/traits/const-traits/call-generic-in-impl.rs b/tests/ui/traits/const-traits/call-generic-in-impl.rs index 72fc80c50e02a..4ed937eacaca4 100644 --- a/tests/ui/traits/const-traits/call-generic-in-impl.rs +++ b/tests/ui/traits/const-traits/call-generic-in-impl.rs @@ -1,8 +1,7 @@ //@ check-pass #![feature(const_trait_impl, const_cmp)] -#[const_trait] -trait MyPartialEq { +const trait MyPartialEq { fn eq(&self, other: &Self) -> bool; } diff --git a/tests/ui/traits/const-traits/call-generic-method-nonconst.rs b/tests/ui/traits/const-traits/call-generic-method-nonconst.rs index 0efc8a954dedb..e23c4d646b7cf 100644 --- a/tests/ui/traits/const-traits/call-generic-method-nonconst.rs +++ b/tests/ui/traits/const-traits/call-generic-method-nonconst.rs @@ -3,8 +3,7 @@ struct S; -#[const_trait] -trait Foo { +const trait Foo { fn eq(&self, _: &Self) -> bool; } diff --git a/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr b/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr index b2ec41182a83b..91d3918372601 100644 --- a/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr +++ b/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `S: const Foo` is not satisfied - --> $DIR/call-generic-method-nonconst.rs:24:34 + --> $DIR/call-generic-method-nonconst.rs:23:34 | LL | pub const EQ: bool = equals_self(&S); | ----------- ^^ @@ -7,7 +7,7 @@ LL | pub const EQ: bool = equals_self(&S); | required by a bound introduced by this call | note: required by a bound in `equals_self` - --> $DIR/call-generic-method-nonconst.rs:17:25 + --> $DIR/call-generic-method-nonconst.rs:16:25 | LL | const fn equals_self(t: &T) -> bool { | ^^^^^^^^^^^ required by this bound in `equals_self` diff --git a/tests/ui/traits/const-traits/conditionally-const-and-const-params.rs b/tests/ui/traits/const-traits/conditionally-const-and-const-params.rs index 29553884b21c2..2241f70cf21e1 100644 --- a/tests/ui/traits/const-traits/conditionally-const-and-const-params.rs +++ b/tests/ui/traits/const-traits/conditionally-const-and-const-params.rs @@ -12,8 +12,7 @@ impl Foo { } } -#[const_trait] -trait Add42 { +const trait Add42 { fn add(a: usize) -> usize; } diff --git a/tests/ui/traits/const-traits/conditionally-const-and-const-params.stderr b/tests/ui/traits/const-traits/conditionally-const-and-const-params.stderr index ebd816ac9a54f..81eff253d7177 100644 --- a/tests/ui/traits/const-traits/conditionally-const-and-const-params.stderr +++ b/tests/ui/traits/const-traits/conditionally-const-and-const-params.stderr @@ -11,19 +11,19 @@ LL | fn add(self) -> Foo<{ A::add(N) }> { | ^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-and-const-params.rs:26:11 + --> $DIR/conditionally-const-and-const-params.rs:25:11 | LL | fn bar(_: Foo) -> Foo<{ A::add(N) }> { | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/conditionally-const-and-const-params.rs:26:4 + --> $DIR/conditionally-const-and-const-params.rs:25:4 | LL | fn bar(_: Foo) -> Foo<{ A::add(N) }> { | ^^^ error[E0277]: the trait bound `A: const Add42` is not satisfied - --> $DIR/conditionally-const-and-const-params.rs:26:62 + --> $DIR/conditionally-const-and-const-params.rs:25:62 | LL | fn bar(_: Foo) -> Foo<{ A::add(N) }> { | ^ diff --git a/tests/ui/traits/const-traits/conditionally-const-assoc-fn-in-trait-impl.rs b/tests/ui/traits/const-traits/conditionally-const-assoc-fn-in-trait-impl.rs index 7f01c0b7a5c96..11ff1ddb79535 100644 --- a/tests/ui/traits/const-traits/conditionally-const-assoc-fn-in-trait-impl.rs +++ b/tests/ui/traits/const-traits/conditionally-const-assoc-fn-in-trait-impl.rs @@ -3,8 +3,7 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -trait Main { +const trait Main { fn compute() -> u32; } @@ -14,8 +13,7 @@ impl const Main for () { } } -#[const_trait] -trait Aux { +const trait Aux { fn generate() -> u32; } diff --git a/tests/ui/traits/const-traits/conditionally-const-in-anon-const.rs b/tests/ui/traits/const-traits/conditionally-const-in-anon-const.rs index 5aebcceb7c75d..21419be29591f 100644 --- a/tests/ui/traits/const-traits/conditionally-const-in-anon-const.rs +++ b/tests/ui/traits/const-traits/conditionally-const-in-anon-const.rs @@ -1,8 +1,7 @@ #![feature(const_trait_impl, impl_trait_in_bindings)] struct S; -#[const_trait] -trait Trait {} +const trait Trait {} impl const Trait<0> for () {} diff --git a/tests/ui/traits/const-traits/conditionally-const-in-anon-const.stderr b/tests/ui/traits/const-traits/conditionally-const-in-anon-const.stderr index c6be249b95a22..94b8ea0970dd9 100644 --- a/tests/ui/traits/const-traits/conditionally-const-in-anon-const.stderr +++ b/tests/ui/traits/const-traits/conditionally-const-in-anon-const.stderr @@ -1,23 +1,23 @@ error: `[const]` is not allowed here - --> $DIR/conditionally-const-in-anon-const.rs:14:25 + --> $DIR/conditionally-const-in-anon-const.rs:13:25 | LL | struct I>(U); | ^^^^^^^ | note: structs cannot have `[const]` trait bounds - --> $DIR/conditionally-const-in-anon-const.rs:14:13 + --> $DIR/conditionally-const-in-anon-const.rs:13:13 | LL | struct I>(U); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-in-anon-const.rs:17:26 + --> $DIR/conditionally-const-in-anon-const.rs:16:26 | LL | let x: &impl [const] Trait<0> = &(); | ^^^^^^^ | note: anonymous constants cannot have `[const]` trait bounds - --> $DIR/conditionally-const-in-anon-const.rs:11:9 + --> $DIR/conditionally-const-in-anon-const.rs:10:9 | LL | / { LL | | const fn g>() {} diff --git a/tests/ui/traits/const-traits/conditionally-const-inherent-assoc-const-fn.rs b/tests/ui/traits/const-traits/conditionally-const-inherent-assoc-const-fn.rs index 56478a6674b0e..083885837cff4 100644 --- a/tests/ui/traits/const-traits/conditionally-const-inherent-assoc-const-fn.rs +++ b/tests/ui/traits/const-traits/conditionally-const-inherent-assoc-const-fn.rs @@ -2,8 +2,7 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -trait Foo { +const trait Foo { fn foo(&self) {} } diff --git a/tests/ui/traits/const-traits/conditionally-const-invalid-places.rs b/tests/ui/traits/const-traits/conditionally-const-invalid-places.rs index 52627004fb246..5e13097b3fa21 100644 --- a/tests/ui/traits/const-traits/conditionally-const-invalid-places.rs +++ b/tests/ui/traits/const-traits/conditionally-const-invalid-places.rs @@ -1,7 +1,6 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Trait {} +const trait Trait {} // Regression test for issue #90052. fn non_const_function() {} //~ ERROR `[const]` is not allowed diff --git a/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr b/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr index 5c3bb2369675e..52b62e7aaccc8 100644 --- a/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr +++ b/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr @@ -1,77 +1,77 @@ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:7:26 + --> $DIR/conditionally-const-invalid-places.rs:6:26 | LL | fn non_const_function() {} | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:7:4 + --> $DIR/conditionally-const-invalid-places.rs:6:4 | LL | fn non_const_function() {} | ^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:9:18 + --> $DIR/conditionally-const-invalid-places.rs:8:18 | LL | struct Struct { field: T } | ^^^^^^^ | note: structs cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:9:1 + --> $DIR/conditionally-const-invalid-places.rs:8:1 | LL | struct Struct { field: T } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:10:23 + --> $DIR/conditionally-const-invalid-places.rs:9:23 | LL | struct TupleStruct(T); | ^^^^^^^ | note: structs cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:10:1 + --> $DIR/conditionally-const-invalid-places.rs:9:1 | LL | struct TupleStruct(T); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:11:22 + --> $DIR/conditionally-const-invalid-places.rs:10:22 | LL | struct UnitStruct; | ^^^^^^^ | note: structs cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:11:1 + --> $DIR/conditionally-const-invalid-places.rs:10:1 | LL | struct UnitStruct; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:14:14 + --> $DIR/conditionally-const-invalid-places.rs:13:14 | LL | enum Enum { Variant(T) } | ^^^^^^^ | note: enums cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:14:1 + --> $DIR/conditionally-const-invalid-places.rs:13:1 | LL | enum Enum { Variant(T) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:16:16 + --> $DIR/conditionally-const-invalid-places.rs:15:16 | LL | union Union { field: T } | ^^^^^^^ | note: unions cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:16:1 + --> $DIR/conditionally-const-invalid-places.rs:15:1 | LL | union Union { field: T } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:19:14 + --> $DIR/conditionally-const-invalid-places.rs:18:14 | LL | type Type = T; | ^^^^^^^ @@ -79,7 +79,7 @@ LL | type Type = T; = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:21:19 + --> $DIR/conditionally-const-invalid-places.rs:20:19 | LL | const CONSTANT: () = (); | ^^^^^^^ @@ -87,43 +87,43 @@ LL | const CONSTANT: () = (); = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:25:18 + --> $DIR/conditionally-const-invalid-places.rs:24:18 | LL | type Type: [const] Trait; | ^^^^^^^ | note: associated types in non-`const` traits cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:25:5 + --> $DIR/conditionally-const-invalid-places.rs:24:5 | LL | type Type: [const] Trait; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:25:34 + --> $DIR/conditionally-const-invalid-places.rs:24:34 | LL | type Type: [const] Trait; | ^^^^^^^ | note: associated types in non-`const` traits cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:25:5 + --> $DIR/conditionally-const-invalid-places.rs:24:5 | LL | type Type: [const] Trait; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:28:30 + --> $DIR/conditionally-const-invalid-places.rs:27:30 | LL | fn non_const_function(); | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:28:8 + --> $DIR/conditionally-const-invalid-places.rs:27:8 | LL | fn non_const_function(); | ^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:29:23 + --> $DIR/conditionally-const-invalid-places.rs:28:23 | LL | const CONSTANT: (); | ^^^^^^^ @@ -131,31 +131,31 @@ LL | const CONSTANT: (); = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:34:18 + --> $DIR/conditionally-const-invalid-places.rs:33:18 | LL | type Type = (); | ^^^^^^^ | note: associated types in non-const impls cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:34:5 + --> $DIR/conditionally-const-invalid-places.rs:33:5 | LL | type Type = (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:36:30 + --> $DIR/conditionally-const-invalid-places.rs:35:30 | LL | fn non_const_function() {} | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:36:8 + --> $DIR/conditionally-const-invalid-places.rs:35:8 | LL | fn non_const_function() {} | ^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:37:23 + --> $DIR/conditionally-const-invalid-places.rs:36:23 | LL | const CONSTANT: () = (); | ^^^^^^^ @@ -163,31 +163,31 @@ LL | const CONSTANT: () = (); = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:44:18 + --> $DIR/conditionally-const-invalid-places.rs:43:18 | LL | type Type = (); | ^^^^^^^ | note: inherent associated types cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:44:5 + --> $DIR/conditionally-const-invalid-places.rs:43:5 | LL | type Type = (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:46:30 + --> $DIR/conditionally-const-invalid-places.rs:45:30 | LL | fn non_const_function() {} | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:46:8 + --> $DIR/conditionally-const-invalid-places.rs:45:8 | LL | fn non_const_function() {} | ^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:47:23 + --> $DIR/conditionally-const-invalid-places.rs:46:23 | LL | const CONSTANT: () = (); | ^^^^^^^ @@ -195,55 +195,55 @@ LL | const CONSTANT: () = (); = note: this item cannot have `[const]` trait bounds error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:52:15 + --> $DIR/conditionally-const-invalid-places.rs:51:15 | LL | trait Child0: [const] Trait {} | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:52:1 + --> $DIR/conditionally-const-invalid-places.rs:51:1 | LL | trait Child0: [const] Trait {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:53:26 + --> $DIR/conditionally-const-invalid-places.rs:52:26 | LL | trait Child1 where Self: [const] Trait {} | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:53:1 + --> $DIR/conditionally-const-invalid-places.rs:52:1 | LL | trait Child1 where Self: [const] Trait {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:56:9 + --> $DIR/conditionally-const-invalid-places.rs:55:9 | LL | impl Trait for T {} | ^^^^^^^ | note: this impl is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:56:1 + --> $DIR/conditionally-const-invalid-places.rs:55:1 | LL | impl Trait for T {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/conditionally-const-invalid-places.rs:59:9 + --> $DIR/conditionally-const-invalid-places.rs:58:9 | LL | impl Struct {} | ^^^^^^^ | note: inherent impls cannot have `[const]` trait bounds - --> $DIR/conditionally-const-invalid-places.rs:59:1 + --> $DIR/conditionally-const-invalid-places.rs:58:1 | LL | impl Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0658]: generic const items are experimental - --> $DIR/conditionally-const-invalid-places.rs:21:15 + --> $DIR/conditionally-const-invalid-places.rs:20:15 | LL | const CONSTANT: () = (); | ^^^^^^^^^^^^^^^^^^ @@ -253,7 +253,7 @@ LL | const CONSTANT: () = (); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: generic const items are experimental - --> $DIR/conditionally-const-invalid-places.rs:29:19 + --> $DIR/conditionally-const-invalid-places.rs:28:19 | LL | const CONSTANT: (); | ^^^^^^^^^^^^^^^^^^ @@ -263,7 +263,7 @@ LL | const CONSTANT: (); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: generic const items are experimental - --> $DIR/conditionally-const-invalid-places.rs:37:19 + --> $DIR/conditionally-const-invalid-places.rs:36:19 | LL | const CONSTANT: () = (); | ^^^^^^^^^^^^^^^^^^ @@ -273,7 +273,7 @@ LL | const CONSTANT: () = (); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: generic const items are experimental - --> $DIR/conditionally-const-invalid-places.rs:47:19 + --> $DIR/conditionally-const-invalid-places.rs:46:19 | LL | const CONSTANT: () = (); | ^^^^^^^^^^^^^^^^^^ @@ -283,7 +283,7 @@ LL | const CONSTANT: () = (); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0392]: type parameter `T` is never used - --> $DIR/conditionally-const-invalid-places.rs:11:19 + --> $DIR/conditionally-const-invalid-places.rs:10:19 | LL | struct UnitStruct; | ^ unused type parameter @@ -291,7 +291,7 @@ LL | struct UnitStruct; = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/conditionally-const-invalid-places.rs:16:33 + --> $DIR/conditionally-const-invalid-places.rs:15:33 | LL | union Union { field: T } | ^^^^^^^^ @@ -303,19 +303,19 @@ LL | union Union { field: std::mem::ManuallyDrop } | +++++++++++++++++++++++ + error[E0275]: overflow evaluating the requirement `(): Trait` - --> $DIR/conditionally-const-invalid-places.rs:34:35 + --> $DIR/conditionally-const-invalid-places.rs:33:35 | LL | type Type = (); | ^^ | note: required by a bound in `NonConstTrait::Type` - --> $DIR/conditionally-const-invalid-places.rs:25:34 + --> $DIR/conditionally-const-invalid-places.rs:24:34 | LL | type Type: [const] Trait; | ^^^^^^^^^^^^^ required by this bound in `NonConstTrait::Type` error[E0658]: inherent associated types are unstable - --> $DIR/conditionally-const-invalid-places.rs:44:5 + --> $DIR/conditionally-const-invalid-places.rs:43:5 | LL | type Type = (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/const-traits/conditionally-const-trait-bound-assoc-tys.rs b/tests/ui/traits/const-traits/conditionally-const-trait-bound-assoc-tys.rs index b0bd8466f66b9..dfb828623ee68 100644 --- a/tests/ui/traits/const-traits/conditionally-const-trait-bound-assoc-tys.rs +++ b/tests/ui/traits/const-traits/conditionally-const-trait-bound-assoc-tys.rs @@ -2,8 +2,7 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -trait Trait { +const trait Trait { type Assoc; } @@ -11,7 +10,6 @@ impl const Trait for () { type Assoc = T; } -#[const_trait] -trait Bound {} +const trait Bound {} fn main() {} diff --git a/tests/ui/traits/const-traits/const-assoc-bound-in-trait-wc.rs b/tests/ui/traits/const-traits/const-assoc-bound-in-trait-wc.rs index 81acce65f2a9d..ccc6e0e4d51d8 100644 --- a/tests/ui/traits/const-traits/const-assoc-bound-in-trait-wc.rs +++ b/tests/ui/traits/const-traits/const-assoc-bound-in-trait-wc.rs @@ -3,8 +3,7 @@ #![feature(const_clone)] #![feature(const_trait_impl)] -#[const_trait] -trait A where Self::Target: [const] Clone { +const trait A where Self::Target: [const] Clone { type Target; } diff --git a/tests/ui/traits/const-traits/const-bound-in-host.rs b/tests/ui/traits/const-traits/const-bound-in-host.rs index b4c4f5a6de1d0..a6f607617f15c 100644 --- a/tests/ui/traits/const-traits/const-bound-in-host.rs +++ b/tests/ui/traits/const-traits/const-bound-in-host.rs @@ -3,7 +3,7 @@ #![feature(const_trait_impl)] -#[const_trait] trait Foo { +const trait Foo { fn foo(); } diff --git a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs index 9411127270833..9b2e93fa0dede 100644 --- a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs +++ b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs @@ -2,8 +2,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait MyTrait { +const trait MyTrait { fn do_something(&self); } diff --git a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr index 901c2cbd8a712..55106cf431159 100644 --- a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr +++ b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr @@ -1,23 +1,23 @@ error: `[const]` is not allowed here - --> $DIR/const-bound-on-not-const-associated-fn.rs:11:40 + --> $DIR/const-bound-on-not-const-associated-fn.rs:10:40 | LL | fn do_something_else() where Self: [const] MyTrait; | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/const-bound-on-not-const-associated-fn.rs:11:8 + --> $DIR/const-bound-on-not-const-associated-fn.rs:10:8 | LL | fn do_something_else() where Self: [const] MyTrait; | ^^^^^^^^^^^^^^^^^ error: `[const]` is not allowed here - --> $DIR/const-bound-on-not-const-associated-fn.rs:22:32 + --> $DIR/const-bound-on-not-const-associated-fn.rs:21:32 | LL | pub fn foo(&self) where T: [const] MyTrait { | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/const-bound-on-not-const-associated-fn.rs:22:12 + --> $DIR/const-bound-on-not-const-associated-fn.rs:21:12 | LL | pub fn foo(&self) where T: [const] MyTrait { | ^^^ diff --git a/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr b/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr index 304d81bb91711..9990d1b3b9e56 100644 --- a/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr +++ b/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr @@ -6,8 +6,8 @@ LL | const fn perform() {} | help: mark `NonConst` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait NonConst {} - | ++++++++++++++ +LL | const trait NonConst {} + | +++++ error: `[const]` can only be applied to `const` traits --> $DIR/const-bounds-non-const-trait.rs:6:21 @@ -18,8 +18,8 @@ LL | const fn perform() {} = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `NonConst` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait NonConst {} - | ++++++++++++++ +LL | const trait NonConst {} + | +++++ error: `const` can only be applied to `const` traits --> $DIR/const-bounds-non-const-trait.rs:10:15 @@ -29,8 +29,8 @@ LL | fn operate() {} | help: mark `NonConst` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait NonConst {} - | ++++++++++++++ +LL | const trait NonConst {} + | +++++ error: aborting due to 3 previous errors diff --git a/tests/ui/traits/const-traits/const-check-fns-in-const-impl.rs b/tests/ui/traits/const-traits/const-check-fns-in-const-impl.rs index f7686ea6139b5..f80e379a13174 100644 --- a/tests/ui/traits/const-traits/const-check-fns-in-const-impl.rs +++ b/tests/ui/traits/const-traits/const-check-fns-in-const-impl.rs @@ -3,8 +3,7 @@ #![feature(const_trait_impl)] struct S; -#[const_trait] -trait T { +const trait T { fn foo(); } diff --git a/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr b/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr index 1a7ec35f3ddba..04da8f730e209 100644 --- a/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr +++ b/tests/ui/traits/const-traits/const-check-fns-in-const-impl.stderr @@ -1,11 +1,11 @@ error[E0015]: cannot call non-const function `non_const` in constant functions - --> $DIR/const-check-fns-in-const-impl.rs:14:16 + --> $DIR/const-check-fns-in-const-impl.rs:13:16 | LL | fn foo() { non_const() } | ^^^^^^^^^^^ | note: function `non_const` is not const - --> $DIR/const-check-fns-in-const-impl.rs:11:1 + --> $DIR/const-check-fns-in-const-impl.rs:10:1 | LL | fn non_const() {} | ^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/const-traits/const-closure-trait-method-fail.rs b/tests/ui/traits/const-traits/const-closure-trait-method-fail.rs index cbcc4aa7c3cdb..da9327226f771 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method-fail.rs +++ b/tests/ui/traits/const-traits/const-closure-trait-method-fail.rs @@ -2,8 +2,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Tr { +const trait Tr { fn a(self) -> i32; } diff --git a/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr b/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr index faacc86512441..93563dd12f952 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr +++ b/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `(): const Tr` is not satisfied - --> $DIR/const-closure-trait-method-fail.rs:18:23 + --> $DIR/const-closure-trait-method-fail.rs:17:23 | LL | const _: () = assert!(need_const_closure(Tr::a) == 42); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/const-traits/const-closure-trait-method.rs b/tests/ui/traits/const-traits/const-closure-trait-method.rs index 6477aa63c680b..62de7c533ffb8 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method.rs +++ b/tests/ui/traits/const-traits/const-closure-trait-method.rs @@ -3,8 +3,7 @@ //@[next] compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -trait Tr { +const trait Tr { fn a(self) -> i32; } diff --git a/tests/ui/traits/const-traits/const-cond-for-rpitit.rs b/tests/ui/traits/const-traits/const-cond-for-rpitit.rs index da83e054dd9bb..0d010fe0de97a 100644 --- a/tests/ui/traits/const-traits/const-cond-for-rpitit.rs +++ b/tests/ui/traits/const-traits/const-cond-for-rpitit.rs @@ -4,13 +4,11 @@ #![feature(const_trait_impl)] #![allow(refining_impl_trait)] -#[const_trait] -pub trait Foo { +pub const trait Foo { fn method(self) -> impl [const] Bar; } -#[const_trait] -pub trait Bar {} +pub const trait Bar {} struct A(T); impl const Foo for A where A: [const] Bar { diff --git a/tests/ui/traits/const-traits/const-default-method-bodies.rs b/tests/ui/traits/const-traits/const-default-method-bodies.rs index 27e828c7ab91a..b2ddf1ba541e6 100644 --- a/tests/ui/traits/const-traits/const-default-method-bodies.rs +++ b/tests/ui/traits/const-traits/const-default-method-bodies.rs @@ -1,8 +1,7 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -trait ConstDefaultFn: Sized { +const trait ConstDefaultFn: Sized { fn b(self); fn a(self) { diff --git a/tests/ui/traits/const-traits/const-default-method-bodies.stderr b/tests/ui/traits/const-traits/const-default-method-bodies.stderr index 22b6a9b5613a8..55a12f95a6d19 100644 --- a/tests/ui/traits/const-traits/const-default-method-bodies.stderr +++ b/tests/ui/traits/const-traits/const-default-method-bodies.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `NonConstImpl: [const] ConstDefaultFn` is not satisfied - --> $DIR/const-default-method-bodies.rs:25:18 + --> $DIR/const-default-method-bodies.rs:24:18 | LL | NonConstImpl.a(); | ^ diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr b/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr index 48c8852a7b8d4..b4603f4882cc9 100644 --- a/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr @@ -1,18 +1,18 @@ error[E0277]: the trait bound `NonTrivialDrop: const A` is not satisfied - --> $DIR/const-drop-fail-2.rs:31:23 + --> $DIR/const-drop-fail-2.rs:30:23 | LL | const _: () = check::>( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: required for `ConstDropImplWithBounds` to implement `const Drop` - --> $DIR/const-drop-fail-2.rs:25:26 + --> $DIR/const-drop-fail-2.rs:24:26 | LL | impl const Drop for ConstDropImplWithBounds { | --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | unsatisfied trait bound introduced here note: required by a bound in `check` - --> $DIR/const-drop-fail-2.rs:21:19 + --> $DIR/const-drop-fail-2.rs:20:19 | LL | const fn check(_: T) {} | ^^^^^^^^^^^^^^^^ required by this bound in `check` diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.rs b/tests/ui/traits/const-traits/const-drop-fail-2.rs index 3f98a9f715e8b..f5e5793b95c1c 100644 --- a/tests/ui/traits/const-traits/const-drop-fail-2.rs +++ b/tests/ui/traits/const-traits/const-drop-fail-2.rs @@ -13,8 +13,7 @@ impl Drop for NonTrivialDrop { } } -#[const_trait] -trait A { fn a() { } } +const trait A { fn a() { } } impl A for NonTrivialDrop {} diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr b/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr index 48c8852a7b8d4..b4603f4882cc9 100644 --- a/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr @@ -1,18 +1,18 @@ error[E0277]: the trait bound `NonTrivialDrop: const A` is not satisfied - --> $DIR/const-drop-fail-2.rs:31:23 + --> $DIR/const-drop-fail-2.rs:30:23 | LL | const _: () = check::>( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: required for `ConstDropImplWithBounds` to implement `const Drop` - --> $DIR/const-drop-fail-2.rs:25:26 + --> $DIR/const-drop-fail-2.rs:24:26 | LL | impl const Drop for ConstDropImplWithBounds { | --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | unsatisfied trait bound introduced here note: required by a bound in `check` - --> $DIR/const-drop-fail-2.rs:21:19 + --> $DIR/const-drop-fail-2.rs:20:19 | LL | const fn check(_: T) {} | ^^^^^^^^^^^^^^^^ required by this bound in `check` diff --git a/tests/ui/traits/const-traits/const-drop.rs b/tests/ui/traits/const-traits/const-drop.rs index dc985a8f62073..f7c3ec9be331d 100644 --- a/tests/ui/traits/const-traits/const-drop.rs +++ b/tests/ui/traits/const-traits/const-drop.rs @@ -49,8 +49,7 @@ mod t { pub struct HasConstDrop(pub ConstDrop); pub struct TrivialFields(pub u8, pub i8, pub usize, pub isize); - #[const_trait] - pub trait SomeTrait { + pub const trait SomeTrait { fn foo(); } impl const SomeTrait for () { diff --git a/tests/ui/traits/const-traits/const-impl-recovery.rs b/tests/ui/traits/const-traits/const-impl-recovery.rs index 837124db04e20..0f1c6225d8f0a 100644 --- a/tests/ui/traits/const-traits/const-impl-recovery.rs +++ b/tests/ui/traits/const-traits/const-impl-recovery.rs @@ -1,12 +1,10 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Foo {} +const trait Foo {} const impl Foo for i32 {} //~ ERROR: expected identifier, found keyword -#[const_trait] -trait Bar {} +const trait Bar {} const impl Bar for T {} //~ ERROR: expected identifier, found keyword diff --git a/tests/ui/traits/const-traits/const-impl-recovery.stderr b/tests/ui/traits/const-traits/const-impl-recovery.stderr index 7217fc8554356..709084c86e0ae 100644 --- a/tests/ui/traits/const-traits/const-impl-recovery.stderr +++ b/tests/ui/traits/const-traits/const-impl-recovery.stderr @@ -1,5 +1,5 @@ error: expected identifier, found keyword `impl` - --> $DIR/const-impl-recovery.rs:6:7 + --> $DIR/const-impl-recovery.rs:5:7 | LL | const impl Foo for i32 {} | ^^^^ expected identifier, found keyword @@ -11,7 +11,7 @@ LL + impl const Foo for i32 {} | error: expected identifier, found keyword `impl` - --> $DIR/const-impl-recovery.rs:11:7 + --> $DIR/const-impl-recovery.rs:9:7 | LL | const impl Bar for T {} | ^^^^ expected identifier, found keyword diff --git a/tests/ui/traits/const-traits/const-impl-requires-const-trait.stderr b/tests/ui/traits/const-traits/const-impl-requires-const-trait.stderr index bf73436b78d38..705ade389436b 100644 --- a/tests/ui/traits/const-traits/const-impl-requires-const-trait.stderr +++ b/tests/ui/traits/const-traits/const-impl-requires-const-trait.stderr @@ -8,8 +8,8 @@ LL | impl const A for () {} = note: adding a non-const method body in the future would be a breaking change help: mark `A` as `const` to allow it to have `const` implementations | -LL | #[const_trait] pub trait A {} - | ++++++++++++++ +LL | pub const trait A {} + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/const-impl-trait.rs b/tests/ui/traits/const-traits/const-impl-trait.rs index c89aaa62d9922..e3fcf540643a9 100644 --- a/tests/ui/traits/const-traits/const-impl-trait.rs +++ b/tests/ui/traits/const-traits/const-impl-trait.rs @@ -16,8 +16,7 @@ const fn wrap( x } -#[const_trait] -trait Foo { +const trait Foo { fn huh() -> impl [const] PartialEq + [const] Destruct + Copy; } @@ -36,8 +35,7 @@ const _: () = { assert!(x == x); }; -#[const_trait] -trait T {} +const trait T {} struct S; impl const T for S {} diff --git a/tests/ui/traits/const-traits/const-in-closure.rs b/tests/ui/traits/const-traits/const-in-closure.rs index 0657c5af58837..73e348d022ae3 100644 --- a/tests/ui/traits/const-traits/const-in-closure.rs +++ b/tests/ui/traits/const-traits/const-in-closure.rs @@ -3,8 +3,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Trait { +const trait Trait { fn method(); } diff --git a/tests/ui/traits/const-traits/const-opaque.no.stderr b/tests/ui/traits/const-traits/const-opaque.no.stderr index 591b81f976745..9f17b0d4354d7 100644 --- a/tests/ui/traits/const-traits/const-opaque.no.stderr +++ b/tests/ui/traits/const-traits/const-opaque.no.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `(): const Foo` is not satisfied - --> $DIR/const-opaque.rs:31:22 + --> $DIR/const-opaque.rs:30:22 | LL | let opaque = bar(()); | --- ^^ @@ -7,7 +7,7 @@ LL | let opaque = bar(()); | required by a bound introduced by this call | note: required by a bound in `bar` - --> $DIR/const-opaque.rs:26:17 + --> $DIR/const-opaque.rs:25:17 | LL | const fn bar(t: T) -> impl [const] Foo { | ^^^^^^^^^^^ required by this bound in `bar` @@ -17,7 +17,7 @@ LL | impl const Foo for () { | +++++ error[E0277]: the trait bound `(): const Foo` is not satisfied - --> $DIR/const-opaque.rs:33:12 + --> $DIR/const-opaque.rs:32:12 | LL | opaque.method(); | ^^^^^^ diff --git a/tests/ui/traits/const-traits/const-opaque.rs b/tests/ui/traits/const-traits/const-opaque.rs index 56ebf0aefccfd..9b24cfa69a863 100644 --- a/tests/ui/traits/const-traits/const-opaque.rs +++ b/tests/ui/traits/const-traits/const-opaque.rs @@ -4,8 +4,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Foo { +const trait Foo { fn method(&self); } diff --git a/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr b/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr index 3ba5da39106d6..b78dc0e98abe8 100644 --- a/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr +++ b/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr @@ -34,8 +34,8 @@ LL | const fn handle(_: &dyn const NonConst) {} | help: mark `NonConst` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait NonConst {} - | ++++++++++++++ +LL | const trait NonConst {} + | +++++ error: `[const]` can only be applied to `const` traits --> $DIR/const-trait-bounds-trait-objects.rs:16:23 @@ -45,8 +45,8 @@ LL | const fn take(_: &dyn [const] NonConst) {} | help: mark `NonConst` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait NonConst {} - | ++++++++++++++ +LL | const trait NonConst {} + | +++++ error: aborting due to 6 previous errors diff --git a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs index 5376baf15e0f1..fcc23fbb65104 100644 --- a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs +++ b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs @@ -10,8 +10,7 @@ #![feature(const_trait_impl, effects)] //~^ ERROR feature has been removed -#[const_trait] -trait Main { +const trait Main { fn compute() -> u32; } @@ -22,8 +21,7 @@ impl const Main for () { } } -#[const_trait] -trait Aux {} +const trait Aux {} impl const Aux for () {} diff --git a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr index 736fde33ce3a3..70add14c3712f 100644 --- a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr +++ b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr @@ -8,7 +8,7 @@ LL | #![feature(const_trait_impl, effects)] = note: removed, redundant with `#![feature(const_trait_impl)]` error[E0049]: associated function `compute` has 0 type parameters but its trait declaration has 1 type parameter - --> $DIR/const-trait-impl-parameter-mismatch.rs:19:16 + --> $DIR/const-trait-impl-parameter-mismatch.rs:18:16 | LL | fn compute() -> u32; | - expected 1 type parameter diff --git a/tests/ui/traits/const-traits/const-via-item-bound.rs b/tests/ui/traits/const-traits/const-via-item-bound.rs index 23f122b741308..c927e1f73ce71 100644 --- a/tests/ui/traits/const-traits/const-via-item-bound.rs +++ b/tests/ui/traits/const-traits/const-via-item-bound.rs @@ -5,8 +5,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Bar {} +const trait Bar {} trait Baz: const Bar {} diff --git a/tests/ui/traits/const-traits/cross-crate.gatednc.stderr b/tests/ui/traits/const-traits/cross-crate.gatednc.stderr index fe45ff188efb4..45e06c78cfb25 100644 --- a/tests/ui/traits/const-traits/cross-crate.gatednc.stderr +++ b/tests/ui/traits/const-traits/cross-crate.gatednc.stderr @@ -5,7 +5,7 @@ LL | NonConst.func(); | ^^^^ | note: trait `MyTrait` is implemented but not `const` - --> $DIR/auxiliary/cross-crate.rs:12:1 + --> $DIR/auxiliary/cross-crate.rs:11:1 | LL | impl MyTrait for NonConst { | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.rs b/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.rs index ea97f755d55c4..3de92f571e707 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.rs +++ b/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.rs @@ -1,13 +1,11 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Tr {} +const trait Tr {} impl Tr for () {} const fn foo() where T: [const] Tr {} -#[const_trait] -pub trait Foo { +pub const trait Foo { fn foo() { foo::<()>(); //~^ ERROR the trait bound `(): [const] Tr` is not satisfied diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr b/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr index 3ce646ec5027f..a436221d75412 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr +++ b/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `(): [const] Tr` is not satisfied - --> $DIR/default-method-body-is-const-body-checking.rs:12:15 + --> $DIR/default-method-body-is-const-body-checking.rs:10:15 | LL | foo::<()>(); | ^^ | note: required by a bound in `foo` - --> $DIR/default-method-body-is-const-body-checking.rs:7:28 + --> $DIR/default-method-body-is-const-body-checking.rs:6:28 | LL | const fn foo() where T: [const] Tr {} | ^^^^^^^^^^ required by this bound in `foo` diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.rs b/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.rs index eb2c472e3bf7b..6de82edfbedc7 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.rs +++ b/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.rs @@ -1,8 +1,7 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -pub trait Tr { +pub const trait Tr { fn a(&self) {} fn b(&self) { diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr b/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr index f473a687efcb0..f93e57d5fd6b2 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr +++ b/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `(): [const] Tr` is not satisfied - --> $DIR/default-method-body-is-const-same-trait-ck.rs:9:12 + --> $DIR/default-method-body-is-const-same-trait-ck.rs:8:12 | LL | ().a() | ^ diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-with-staged-api.rs b/tests/ui/traits/const-traits/default-method-body-is-const-with-staged-api.rs index 8b264ebd0e42a..9fccef759bb94 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-with-staged-api.rs +++ b/tests/ui/traits/const-traits/default-method-body-is-const-with-staged-api.rs @@ -9,8 +9,7 @@ #![feature(const_trait_impl)] #![stable(feature = "foo", since = "3.3.3")] -#[const_trait] -trait Tr { +const trait Tr { fn a() {} } diff --git a/tests/ui/traits/const-traits/do-not-const-check-override.rs b/tests/ui/traits/const-traits/do-not-const-check-override.rs index 2b8e1d38ac99f..caa3e192e71f3 100644 --- a/tests/ui/traits/const-traits/do-not-const-check-override.rs +++ b/tests/ui/traits/const-traits/do-not-const-check-override.rs @@ -3,8 +3,7 @@ #![allow(incomplete_features)] #![feature(const_trait_impl, rustc_attrs)] -#[const_trait] -trait Foo { +const trait Foo { #[rustc_do_not_const_check] fn into_iter(&self) { println!("FEAR ME!") } } diff --git a/tests/ui/traits/const-traits/do-not-const-check.rs b/tests/ui/traits/const-traits/do-not-const-check.rs index 443b638573576..fecbfea8467bd 100644 --- a/tests/ui/traits/const-traits/do-not-const-check.rs +++ b/tests/ui/traits/const-traits/do-not-const-check.rs @@ -1,13 +1,11 @@ //@ check-pass #![feature(const_trait_impl, rustc_attrs)] -#[const_trait] -trait IntoIter { +const trait IntoIter { fn into_iter(self); } -#[const_trait] -trait Hmm: Sized { +const trait Hmm: Sized { #[rustc_do_not_const_check] fn chain(self, other: U) where U: IntoIter, { diff --git a/tests/ui/traits/const-traits/dont-ice-on-const-pred-for-bounds.rs b/tests/ui/traits/const-traits/dont-ice-on-const-pred-for-bounds.rs index d39e661ed9205..ae87d1c4e9c25 100644 --- a/tests/ui/traits/const-traits/dont-ice-on-const-pred-for-bounds.rs +++ b/tests/ui/traits/const-traits/dont-ice-on-const-pred-for-bounds.rs @@ -8,8 +8,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Trait { +const trait Trait { type Assoc: const Trait; } diff --git a/tests/ui/traits/const-traits/dont-observe-host.rs b/tests/ui/traits/const-traits/dont-observe-host.rs index 06050385f9168..f8477a3e5ea8e 100644 --- a/tests/ui/traits/const-traits/dont-observe-host.rs +++ b/tests/ui/traits/const-traits/dont-observe-host.rs @@ -3,8 +3,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Trait { +const trait Trait { fn method() {} } diff --git a/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs b/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs index f1fc98d72a547..f45265c2cc758 100644 --- a/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs +++ b/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs @@ -2,8 +2,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Foo {} +const trait Foo {} impl const Foo for (T,) where T: [const] Foo {} diff --git a/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs b/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs index 414b80ca0daab..062853635f285 100644 --- a/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs +++ b/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs @@ -2,8 +2,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Trait { +const trait Trait { type Out; } diff --git a/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.stderr b/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.stderr index 740a05be06ba6..1ae376c8b6b27 100644 --- a/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.stderr +++ b/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `(): Trait` is not satisfied - --> $DIR/double-error-for-unimplemented-trait.rs:13:15 + --> $DIR/double-error-for-unimplemented-trait.rs:12:15 | LL | needs_const(&()); | ----------- ^^^ the trait `Trait` is not implemented for `()` @@ -7,18 +7,18 @@ LL | needs_const(&()); | required by a bound introduced by this call | help: this trait has no implementations, consider adding one - --> $DIR/double-error-for-unimplemented-trait.rs:6:1 + --> $DIR/double-error-for-unimplemented-trait.rs:5:1 | -LL | trait Trait { - | ^^^^^^^^^^^ +LL | const trait Trait { + | ^^^^^^^^^^^^^^^^^ note: required by a bound in `needs_const` - --> $DIR/double-error-for-unimplemented-trait.rs:10:25 + --> $DIR/double-error-for-unimplemented-trait.rs:9:25 | LL | const fn needs_const(_: &T) {} | ^^^^^^^^^^^^^ required by this bound in `needs_const` error[E0277]: the trait bound `(): Trait` is not satisfied - --> $DIR/double-error-for-unimplemented-trait.rs:18:15 + --> $DIR/double-error-for-unimplemented-trait.rs:17:15 | LL | needs_const(&()); | ----------- ^^^ the trait `Trait` is not implemented for `()` @@ -26,12 +26,12 @@ LL | needs_const(&()); | required by a bound introduced by this call | help: this trait has no implementations, consider adding one - --> $DIR/double-error-for-unimplemented-trait.rs:6:1 + --> $DIR/double-error-for-unimplemented-trait.rs:5:1 | -LL | trait Trait { - | ^^^^^^^^^^^ +LL | const trait Trait { + | ^^^^^^^^^^^^^^^^^ note: required by a bound in `needs_const` - --> $DIR/double-error-for-unimplemented-trait.rs:10:25 + --> $DIR/double-error-for-unimplemented-trait.rs:9:25 | LL | const fn needs_const(_: &T) {} | ^^^^^^^^^^^^^ required by this bound in `needs_const` diff --git a/tests/ui/traits/const-traits/effect-param-infer.rs b/tests/ui/traits/const-traits/effect-param-infer.rs index fcacf458a9fa5..4ff2406ed15fd 100644 --- a/tests/ui/traits/const-traits/effect-param-infer.rs +++ b/tests/ui/traits/const-traits/effect-param-infer.rs @@ -5,8 +5,7 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -pub trait Foo { +pub const trait Foo { /* stuff */ } diff --git a/tests/ui/traits/const-traits/eval-bad-signature.rs b/tests/ui/traits/const-traits/eval-bad-signature.rs index 66e296d438806..02afdb93d2407 100644 --- a/tests/ui/traits/const-traits/eval-bad-signature.rs +++ b/tests/ui/traits/const-traits/eval-bad-signature.rs @@ -2,8 +2,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Value { +const trait Value { fn value() -> u32; } diff --git a/tests/ui/traits/const-traits/eval-bad-signature.stderr b/tests/ui/traits/const-traits/eval-bad-signature.stderr index 52de5283f7fdf..db5f434ee0e98 100644 --- a/tests/ui/traits/const-traits/eval-bad-signature.stderr +++ b/tests/ui/traits/const-traits/eval-bad-signature.stderr @@ -1,11 +1,11 @@ error[E0053]: method `value` has an incompatible type for trait - --> $DIR/eval-bad-signature.rs:17:19 + --> $DIR/eval-bad-signature.rs:16:19 | LL | fn value() -> i64 { | ^^^ expected `u32`, found `i64` | note: type in trait - --> $DIR/eval-bad-signature.rs:7:19 + --> $DIR/eval-bad-signature.rs:6:19 | LL | fn value() -> u32; | ^^^ diff --git a/tests/ui/traits/const-traits/feature-gate.rs b/tests/ui/traits/const-traits/feature-gate.rs index c2918f0249b9e..46f0e92021a14 100644 --- a/tests/ui/traits/const-traits/feature-gate.rs +++ b/tests/ui/traits/const-traits/feature-gate.rs @@ -5,15 +5,13 @@ #![cfg_attr(gated, feature(const_trait_impl))] struct S; -#[const_trait] //[stock]~ ERROR `const_trait` is a temporary placeholder -trait T {} +const trait T {} //[stock]~ ERROR const trait impls are experimental impl const T for S {} //[stock]~^ ERROR const trait impls are experimental const fn f() {} //[stock]~ ERROR const trait impls are experimental fn g() {} //[stock]~ ERROR const trait impls are experimental -const trait Trait {} //[stock]~ ERROR const trait impls are experimental #[cfg(false)] const trait Trait {} //[stock]~ ERROR const trait impls are experimental macro_rules! discard { ($ty:ty) => {} } diff --git a/tests/ui/traits/const-traits/feature-gate.stock.stderr b/tests/ui/traits/const-traits/feature-gate.stock.stderr index 551c7ced7c1f4..b5e031094600e 100644 --- a/tests/ui/traits/const-traits/feature-gate.stock.stderr +++ b/tests/ui/traits/const-traits/feature-gate.stock.stderr @@ -1,45 +1,45 @@ error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:10:6 + --> $DIR/feature-gate.rs:8:1 | -LL | impl const T for S {} - | ^^^^^ +LL | const trait T {} + | ^^^^^ | = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:13:15 + --> $DIR/feature-gate.rs:9:6 | -LL | const fn f() {} - | ^^^^^^^ +LL | impl const T for S {} + | ^^^^^ | = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:14:9 + --> $DIR/feature-gate.rs:12:15 | -LL | fn g() {} - | ^^^^^ +LL | const fn f() {} + | ^^^^^^^ | = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:16:1 + --> $DIR/feature-gate.rs:13:9 | -LL | const trait Trait {} - | ^^^^^ +LL | fn g() {} + | ^^^^^ | = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:17:15 + --> $DIR/feature-gate.rs:15:15 | LL | #[cfg(false)] const trait Trait {} | ^^^^^ @@ -49,7 +49,7 @@ LL | #[cfg(false)] const trait Trait {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:21:17 + --> $DIR/feature-gate.rs:19:17 | LL | discard! { impl [const] T } | ^^^^^^^ @@ -59,7 +59,7 @@ LL | discard! { impl [const] T } = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:22:17 + --> $DIR/feature-gate.rs:20:17 | LL | discard! { impl const T } | ^^^^^ @@ -68,16 +68,6 @@ LL | discard! { impl const T } = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future. - --> $DIR/feature-gate.rs:8:1 - | -LL | #[const_trait] - | ^^^^^^^^^^^^^^ - | - = note: see issue #143874 for more information - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 8 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/traits/const-traits/function-pointer-does-not-require-const.rs b/tests/ui/traits/const-traits/function-pointer-does-not-require-const.rs index 8acd195e546b2..faa4b51d66854 100644 --- a/tests/ui/traits/const-traits/function-pointer-does-not-require-const.rs +++ b/tests/ui/traits/const-traits/function-pointer-does-not-require-const.rs @@ -1,8 +1,7 @@ //@ check-pass #![feature(const_trait_impl)] -#[const_trait] -pub trait Test {} +pub const trait Test {} impl Test for () {} diff --git a/tests/ui/traits/const-traits/hir-const-check.rs b/tests/ui/traits/const-traits/hir-const-check.rs index 1b6fa1afab9fa..5473cdd040754 100644 --- a/tests/ui/traits/const-traits/hir-const-check.rs +++ b/tests/ui/traits/const-traits/hir-const-check.rs @@ -6,8 +6,7 @@ #![feature(const_trait_impl)] #![feature(const_try)] -#[const_trait] -pub trait MyTrait { +pub const trait MyTrait { fn method(&self) -> Option<()>; } diff --git a/tests/ui/traits/const-traits/ice-121536-const-method.rs b/tests/ui/traits/const-traits/ice-121536-const-method.rs index b89786bfd933f..a1dbd7551b7b5 100644 --- a/tests/ui/traits/const-traits/ice-121536-const-method.rs +++ b/tests/ui/traits/const-traits/ice-121536-const-method.rs @@ -2,8 +2,7 @@ pub struct Vec3; -#[const_trait] -pub trait Add { +pub const trait Add { fn add(self) -> Vec3; } diff --git a/tests/ui/traits/const-traits/ice-121536-const-method.stderr b/tests/ui/traits/const-traits/ice-121536-const-method.stderr index 408958abf6307..55f158b3ddecc 100644 --- a/tests/ui/traits/const-traits/ice-121536-const-method.stderr +++ b/tests/ui/traits/const-traits/ice-121536-const-method.stderr @@ -1,5 +1,5 @@ error[E0379]: functions in trait impls cannot be declared const - --> $DIR/ice-121536-const-method.rs:11:5 + --> $DIR/ice-121536-const-method.rs:10:5 | LL | const fn add(self) -> Vec3 { | ^^^^^ functions in trait impls cannot be const diff --git a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs index ea4db0515cd44..617c28cc34016 100644 --- a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs +++ b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs @@ -2,8 +2,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Foo {} +const trait Foo {} impl const Foo for i32 {} diff --git a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr index 5b417dcfe2cb2..082e7a1413584 100644 --- a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr +++ b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Foo` for type `i32` - --> $DIR/ice-124857-combine-effect-const-infer-vars.rs:10:1 + --> $DIR/ice-124857-combine-effect-const-infer-vars.rs:9:1 | LL | impl const Foo for i32 {} | ---------------------- first implementation here diff --git a/tests/ui/traits/const-traits/impl-with-default-fn-fail.rs b/tests/ui/traits/const-traits/impl-with-default-fn-fail.rs index 6df9696f2cbd7..7becb01027d75 100644 --- a/tests/ui/traits/const-traits/impl-with-default-fn-fail.rs +++ b/tests/ui/traits/const-traits/impl-with-default-fn-fail.rs @@ -1,7 +1,6 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Tr { +const trait Tr { fn req(&self); fn default() {} diff --git a/tests/ui/traits/const-traits/impl-with-default-fn-fail.stderr b/tests/ui/traits/const-traits/impl-with-default-fn-fail.stderr index 36c8163f1c567..61f989810bf3f 100644 --- a/tests/ui/traits/const-traits/impl-with-default-fn-fail.stderr +++ b/tests/ui/traits/const-traits/impl-with-default-fn-fail.stderr @@ -1,5 +1,5 @@ error[E0046]: not all trait items implemented, missing: `req` - --> $DIR/impl-with-default-fn-fail.rs:12:1 + --> $DIR/impl-with-default-fn-fail.rs:11:1 | LL | fn req(&self); | -------------- `req` from trait diff --git a/tests/ui/traits/const-traits/impl-with-default-fn-pass.rs b/tests/ui/traits/const-traits/impl-with-default-fn-pass.rs index c776a29716ff7..f6888f5e997b7 100644 --- a/tests/ui/traits/const-traits/impl-with-default-fn-pass.rs +++ b/tests/ui/traits/const-traits/impl-with-default-fn-pass.rs @@ -2,8 +2,7 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -trait Tr { +const trait Tr { fn req(&self); fn default() {} diff --git a/tests/ui/traits/const-traits/imply-always-const.rs b/tests/ui/traits/const-traits/imply-always-const.rs index f6cab0681ec2e..44391b2753ec0 100644 --- a/tests/ui/traits/const-traits/imply-always-const.rs +++ b/tests/ui/traits/const-traits/imply-always-const.rs @@ -2,13 +2,11 @@ #![feature(const_trait_impl)] -#[const_trait] -trait A where Self::Assoc: const B { +const trait A where Self::Assoc: const B { type Assoc; } -#[const_trait] -trait B {} +const trait B {} fn needs_b() {} diff --git a/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs b/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs index 941f054280375..67701461b3892 100644 --- a/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs +++ b/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs @@ -3,10 +3,8 @@ struct S; -#[const_trait] -trait A {} -#[const_trait] -trait B {} +const trait A {} +const trait B {} impl const A for S {} impl const B for S {} diff --git a/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.stderr b/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.stderr index ca73ae845550d..541a2000c2872 100644 --- a/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.stderr +++ b/tests/ui/traits/const-traits/inline-incorrect-early-bound-in-ctfe.stderr @@ -23,9 +23,8 @@ LL | fn foo(self); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Trait` const | -LL + #[const_trait] -LL | trait Trait { - | +LL | const trait Trait { + | +++++ error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/issue-100222.rs b/tests/ui/traits/const-traits/issue-100222.rs index 4c93272b224f8..aebcb625cfd7b 100644 --- a/tests/ui/traits/const-traits/issue-100222.rs +++ b/tests/ui/traits/const-traits/issue-100222.rs @@ -5,12 +5,20 @@ #![allow(incomplete_features)] #![feature(const_trait_impl, associated_type_defaults)] -#[cfg_attr(any(yn, yy), const_trait)] -pub trait Index { - type Output; +#[cfg(any(yn, yy))] pub const trait Index { type Output; } +#[cfg(not(any(yn, yy)))] pub trait Index { type Output; } + +#[cfg(any(ny, yy))] +pub const trait IndexMut +where + Self: Index, +{ + const C: ::Output; + type Assoc = ::Output; + fn foo(&mut self, x: ::Output) -> ::Output; } -#[cfg_attr(any(ny, yy), const_trait)] +#[cfg(not(any(ny, yy)))] pub trait IndexMut where Self: Index, diff --git a/tests/ui/traits/const-traits/issue-79450.rs b/tests/ui/traits/const-traits/issue-79450.rs index 5ba5036ce277a..e74da811fc805 100644 --- a/tests/ui/traits/const-traits/issue-79450.rs +++ b/tests/ui/traits/const-traits/issue-79450.rs @@ -1,8 +1,7 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -trait Tr { +const trait Tr { fn req(&self); fn prov(&self) { diff --git a/tests/ui/traits/const-traits/issue-79450.stderr b/tests/ui/traits/const-traits/issue-79450.stderr index d8a9e18980687..c10023e9f0efa 100644 --- a/tests/ui/traits/const-traits/issue-79450.stderr +++ b/tests/ui/traits/const-traits/issue-79450.stderr @@ -1,5 +1,5 @@ error[E0015]: cannot call non-const function `_print` in constant functions - --> $DIR/issue-79450.rs:9:9 + --> $DIR/issue-79450.rs:8:9 | LL | println!("lul"); | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/const-traits/issue-88155.stderr b/tests/ui/traits/const-traits/issue-88155.stderr index 4a912cc8274a7..514f1fed947ea 100644 --- a/tests/ui/traits/const-traits/issue-88155.stderr +++ b/tests/ui/traits/const-traits/issue-88155.stderr @@ -14,9 +14,8 @@ LL | fn assoc() -> bool; = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `A` const | -LL + #[const_trait] -LL | pub trait A { - | +LL | pub const trait A { + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs b/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs index 0eb7f54d596fb..0663e23f51700 100644 --- a/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs +++ b/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs @@ -5,10 +5,8 @@ #![feature(const_trait_impl)] -#[const_trait] -pub trait Super {} -#[const_trait] -pub trait Sub: Super {} +pub const trait Super {} +pub const trait Sub: Super {} impl const Super for &A where A: [const] Super {} impl const Sub for &A where A: [const] Sub {} diff --git a/tests/ui/traits/const-traits/item-bound-entailment-fails.rs b/tests/ui/traits/const-traits/item-bound-entailment-fails.rs index 029597ea1f032..047da4cc938da 100644 --- a/tests/ui/traits/const-traits/item-bound-entailment-fails.rs +++ b/tests/ui/traits/const-traits/item-bound-entailment-fails.rs @@ -1,13 +1,13 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] trait Foo { +const trait Foo { type Assoc: [const] Bar where T: [const] Bar; } -#[const_trait] trait Bar {} +const trait Bar {} struct N(T); impl Bar for N where T: Bar {} struct C(T); diff --git a/tests/ui/traits/const-traits/item-bound-entailment.rs b/tests/ui/traits/const-traits/item-bound-entailment.rs index 6e053adb3850d..facd222e5aafe 100644 --- a/tests/ui/traits/const-traits/item-bound-entailment.rs +++ b/tests/ui/traits/const-traits/item-bound-entailment.rs @@ -3,13 +3,13 @@ #![feature(const_trait_impl)] -#[const_trait] trait Foo { +const trait Foo { type Assoc: [const] Bar where T: [const] Bar; } -#[const_trait] trait Bar {} +const trait Bar {} struct N(T); impl Bar for N where T: Bar {} struct C(T); diff --git a/tests/ui/traits/const-traits/minicore-drop-fail.rs b/tests/ui/traits/const-traits/minicore-drop-fail.rs index f3e7c7df4d419..d01d259040c6e 100644 --- a/tests/ui/traits/const-traits/minicore-drop-fail.rs +++ b/tests/ui/traits/const-traits/minicore-drop-fail.rs @@ -15,7 +15,7 @@ impl Drop for NotDropImpl { fn drop(&mut self) {} } -#[const_trait] trait Foo {} +const trait Foo {} impl Foo for () {} struct Conditional(T); diff --git a/tests/ui/traits/const-traits/minicore-fn-fail.rs b/tests/ui/traits/const-traits/minicore-fn-fail.rs index d4cd41a51ca5c..e0ce235e72a23 100644 --- a/tests/ui/traits/const-traits/minicore-fn-fail.rs +++ b/tests/ui/traits/const-traits/minicore-fn-fail.rs @@ -10,8 +10,7 @@ use minicore::*; const fn call_indirect(t: &T) { t() } -#[const_trait] -trait Foo {} +const trait Foo {} impl Foo for () {} const fn foo() {} diff --git a/tests/ui/traits/const-traits/minicore-fn-fail.stderr b/tests/ui/traits/const-traits/minicore-fn-fail.stderr index eb840d421f488..0c260f7f33a77 100644 --- a/tests/ui/traits/const-traits/minicore-fn-fail.stderr +++ b/tests/ui/traits/const-traits/minicore-fn-fail.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `(): [const] Foo` is not satisfied - --> $DIR/minicore-fn-fail.rs:19:19 + --> $DIR/minicore-fn-fail.rs:18:19 | LL | call_indirect(&foo::<()>); | ------------- ^^^^^^^^^^ diff --git a/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.rs b/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.rs index 8d1d3a4c79070..7cb83ecfb0b6d 100644 --- a/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.rs +++ b/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.rs @@ -17,7 +17,6 @@ fn const_negative() {} //~^ ERROR `const` trait not allowed with `!` trait polarity modifier //~| ERROR negative bounds are not supported -#[const_trait] -trait Trait {} +const trait Trait {} fn main() {} diff --git a/tests/ui/traits/const-traits/no-explicit-const-params.rs b/tests/ui/traits/const-traits/no-explicit-const-params.rs index 76663292223b2..cf641db0a8ce6 100644 --- a/tests/ui/traits/const-traits/no-explicit-const-params.rs +++ b/tests/ui/traits/const-traits/no-explicit-const-params.rs @@ -2,8 +2,7 @@ const fn foo() {} -#[const_trait] -trait Bar { +const trait Bar { fn bar(); } diff --git a/tests/ui/traits/const-traits/no-explicit-const-params.stderr b/tests/ui/traits/const-traits/no-explicit-const-params.stderr index 47fa65b2479be..efd90482f7742 100644 --- a/tests/ui/traits/const-traits/no-explicit-const-params.stderr +++ b/tests/ui/traits/const-traits/no-explicit-const-params.stderr @@ -1,5 +1,5 @@ error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/no-explicit-const-params.rs:15:5 + --> $DIR/no-explicit-const-params.rs:14:5 | LL | foo::(); | ^^^-------- help: remove the unnecessary generics @@ -13,7 +13,7 @@ LL | const fn foo() {} | ^^^ error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/no-explicit-const-params.rs:17:12 + --> $DIR/no-explicit-const-params.rs:16:12 | LL | <() as Bar>::bar(); | ^^^------ help: remove the unnecessary generics @@ -21,13 +21,13 @@ LL | <() as Bar>::bar(); | expected 0 generic arguments | note: trait defined here, with 0 generic parameters - --> $DIR/no-explicit-const-params.rs:6:7 + --> $DIR/no-explicit-const-params.rs:5:13 | -LL | trait Bar { - | ^^^ +LL | const trait Bar { + | ^^^ error[E0107]: function takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/no-explicit-const-params.rs:22:5 + --> $DIR/no-explicit-const-params.rs:21:5 | LL | foo::(); | ^^^--------- help: remove the unnecessary generics @@ -41,7 +41,7 @@ LL | const fn foo() {} | ^^^ error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/no-explicit-const-params.rs:24:12 + --> $DIR/no-explicit-const-params.rs:23:12 | LL | <() as Bar>::bar(); | ^^^------- help: remove the unnecessary generics @@ -49,13 +49,13 @@ LL | <() as Bar>::bar(); | expected 0 generic arguments | note: trait defined here, with 0 generic parameters - --> $DIR/no-explicit-const-params.rs:6:7 + --> $DIR/no-explicit-const-params.rs:5:13 | -LL | trait Bar { - | ^^^ +LL | const trait Bar { + | ^^^ error[E0277]: the trait bound `(): const Bar` is not satisfied - --> $DIR/no-explicit-const-params.rs:24:6 + --> $DIR/no-explicit-const-params.rs:23:6 | LL | <() as Bar>::bar(); | ^^ diff --git a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs index 50c985096d127..c0051c62b6d65 100644 --- a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs +++ b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs @@ -2,8 +2,7 @@ //@ check-pass -#[const_trait] -trait Convert { +const trait Convert { fn to(self) -> T; } diff --git a/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr b/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr index ed671bee63ab5..a6bd8615d36d3 100644 --- a/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr +++ b/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Foo` for type `(_,)` - --> $DIR/overlap-const-with-nonconst.rs:23:1 + --> $DIR/overlap-const-with-nonconst.rs:21:1 | LL | / impl const Foo for T LL | | where diff --git a/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs b/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs index f45690b2f78b9..10dfb200c6436 100644 --- a/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs +++ b/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs @@ -5,12 +5,10 @@ //[spec]~^ WARN the feature `specialization` is incomplete #![cfg_attr(min_spec, feature(min_specialization))] -#[const_trait] -trait Bar {} +const trait Bar {} impl const Bar for T {} -#[const_trait] -trait Foo { +const trait Foo { fn method(&self); } impl const Foo for T diff --git a/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr b/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr index 35f4d9184cf5b..91628f65fdcdd 100644 --- a/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr +++ b/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr @@ -9,7 +9,7 @@ LL | #![cfg_attr(spec, feature(specialization))] = note: `#[warn(incomplete_features)]` on by default error[E0119]: conflicting implementations of trait `Foo` for type `(_,)` - --> $DIR/overlap-const-with-nonconst.rs:23:1 + --> $DIR/overlap-const-with-nonconst.rs:21:1 | LL | / impl const Foo for T LL | | where diff --git a/tests/ui/traits/const-traits/predicate-entailment-fails.rs b/tests/ui/traits/const-traits/predicate-entailment-fails.rs index 0e6c277fd8220..d1a8c35442cf2 100644 --- a/tests/ui/traits/const-traits/predicate-entailment-fails.rs +++ b/tests/ui/traits/const-traits/predicate-entailment-fails.rs @@ -1,11 +1,11 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] trait Bar {} +const trait Bar {} impl const Bar for () {} -#[const_trait] trait TildeConst { +const trait TildeConst { type Bar where T: [const] Bar; fn foo() where T: [const] Bar; @@ -19,7 +19,7 @@ impl TildeConst for () { } -#[const_trait] trait NeverConst { +const trait NeverConst { type Bar where T: Bar; fn foo() where T: Bar; diff --git a/tests/ui/traits/const-traits/predicate-entailment-passes.rs b/tests/ui/traits/const-traits/predicate-entailment-passes.rs index fe8714831866a..c2bac51024f39 100644 --- a/tests/ui/traits/const-traits/predicate-entailment-passes.rs +++ b/tests/ui/traits/const-traits/predicate-entailment-passes.rs @@ -3,10 +3,10 @@ #![feature(const_trait_impl)] -#[const_trait] trait Bar {} +const trait Bar {} impl const Bar for () {} -#[const_trait] trait TildeConst { +const trait TildeConst { fn foo() where T: [const] Bar; } impl TildeConst for () { @@ -14,7 +14,7 @@ impl TildeConst for () { } -#[const_trait] trait AlwaysConst { +const trait AlwaysConst { fn foo() where T: const Bar; } impl AlwaysConst for i32 { diff --git a/tests/ui/traits/const-traits/project.rs b/tests/ui/traits/const-traits/project.rs index 139299753e5c7..4750591b2babe 100644 --- a/tests/ui/traits/const-traits/project.rs +++ b/tests/ui/traits/const-traits/project.rs @@ -2,11 +2,9 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -pub trait Owo::T> {} +pub const trait Owo::T> {} -#[const_trait] -pub trait Uwu: Owo { +pub const trait Uwu: Owo { type T; } diff --git a/tests/ui/traits/const-traits/spec-effectvar-ice.stderr b/tests/ui/traits/const-traits/spec-effectvar-ice.stderr index ef5e58e1c3dfa..8dbbd302c655c 100644 --- a/tests/ui/traits/const-traits/spec-effectvar-ice.stderr +++ b/tests/ui/traits/const-traits/spec-effectvar-ice.stderr @@ -8,8 +8,8 @@ LL | impl const Foo for T {} = note: adding a non-const method body in the future would be a breaking change help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo {} - | ++++++++++++++ +LL | const trait Foo {} + | +++++ error: const `impl` for trait `Foo` which is not `const` --> $DIR/spec-effectvar-ice.rs:13:15 @@ -21,8 +21,8 @@ LL | impl const Foo for T where T: const Specialize {} = note: adding a non-const method body in the future would be a breaking change help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo {} - | ++++++++++++++ +LL | const trait Foo {} + | +++++ error: `const` can only be applied to `const` traits --> $DIR/spec-effectvar-ice.rs:13:34 @@ -32,8 +32,8 @@ LL | impl const Foo for T where T: const Specialize {} | help: mark `Specialize` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Specialize {} - | ++++++++++++++ +LL | const trait Specialize {} + | +++++ error: specialization impl does not specialize any associated items --> $DIR/spec-effectvar-ice.rs:13:1 diff --git a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs index 212d869d94d39..5125d2580238f 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs +++ b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs @@ -10,11 +10,9 @@ #[rustc_specialization_trait] trait Specialize {} -#[const_trait] -trait Foo {} +const trait Foo {} -#[const_trait] -trait Bar { +const trait Bar { fn bar(); } @@ -33,8 +31,7 @@ where fn bar() {} } -#[const_trait] -trait Baz { +const trait Baz { fn baz(); } diff --git a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr index 074e6237cc20d..85e9fda5c2a31 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr +++ b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Bar` - --> $DIR/const-default-bound-non-const-specialized-bound.rs:28:1 + --> $DIR/const-default-bound-non-const-specialized-bound.rs:26:1 | LL | / impl const Bar for T LL | | where @@ -13,7 +13,7 @@ LL | | T: Specialize, | |__________________^ conflicting implementation error[E0119]: conflicting implementations of trait `Baz` - --> $DIR/const-default-bound-non-const-specialized-bound.rs:48:1 + --> $DIR/const-default-bound-non-const-specialized-bound.rs:45:1 | LL | / impl const Baz for T LL | | where diff --git a/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs b/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs index 6991b7deda317..3be2ff4ee6117 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs +++ b/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs @@ -6,8 +6,7 @@ #![feature(const_trait_impl)] #![feature(min_specialization)] -#[const_trait] -trait Value { +const trait Value { fn value() -> u32; } diff --git a/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.min_spec.stderr b/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.min_spec.stderr index 38fc5ddfbef52..520a6833f5a58 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.min_spec.stderr +++ b/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.min_spec.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Value` for type `FortyTwo` - --> $DIR/const-default-impl-non-const-specialized-impl.rs:22:1 + --> $DIR/const-default-impl-non-const-specialized-impl.rs:21:1 | LL | impl const Value for T { | ------------------------- first implementation here diff --git a/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.rs b/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.rs index acf0a967a884d..f7cd4599561cb 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.rs +++ b/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.rs @@ -6,8 +6,7 @@ //[spec]~^ WARN the feature `specialization` is incomplete #![cfg_attr(min_spec, feature(min_specialization))] -#[const_trait] -trait Value { +const trait Value { fn value() -> u32; } diff --git a/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.spec.stderr b/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.spec.stderr index b59c42f518936..397d678559451 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.spec.stderr +++ b/tests/ui/traits/const-traits/specialization/const-default-impl-non-const-specialized-impl.spec.stderr @@ -9,7 +9,7 @@ LL | #![cfg_attr(spec, feature(specialization))] = note: `#[warn(incomplete_features)]` on by default error[E0119]: conflicting implementations of trait `Value` for type `FortyTwo` - --> $DIR/const-default-impl-non-const-specialized-impl.rs:22:1 + --> $DIR/const-default-impl-non-const-specialized-impl.rs:21:1 | LL | impl const Value for T { | ------------------------- first implementation here diff --git a/tests/ui/traits/const-traits/specialization/default-keyword.rs b/tests/ui/traits/const-traits/specialization/default-keyword.rs index bc45a70777ca5..5b074015d1998 100644 --- a/tests/ui/traits/const-traits/specialization/default-keyword.rs +++ b/tests/ui/traits/const-traits/specialization/default-keyword.rs @@ -3,8 +3,7 @@ #![feature(const_trait_impl)] #![feature(min_specialization)] -#[const_trait] -trait Foo { +const trait Foo { fn foo(); } diff --git a/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs b/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs index 754f1c6d09d5d..dbdbf5918556f 100644 --- a/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs +++ b/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs @@ -11,11 +11,9 @@ #[rustc_specialization_trait] trait Specialize {} -#[const_trait] -trait Foo {} +const trait Foo {} -#[const_trait] -trait Bar { +const trait Bar { fn bar(); } @@ -34,8 +32,7 @@ where fn bar() {} } -#[const_trait] -trait Baz { +const trait Baz { fn baz(); } diff --git a/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs b/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs index b1a1b4a239955..c68f80dfc7286 100644 --- a/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs +++ b/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs @@ -6,8 +6,7 @@ #![feature(const_trait_impl)] #![feature(min_specialization)] -#[const_trait] -trait Value { +const trait Value { fn value() -> u32; } diff --git a/tests/ui/traits/const-traits/specialization/specialize-on-conditionally-const.rs b/tests/ui/traits/const-traits/specialization/specialize-on-conditionally-const.rs index 0106bb13875ac..a0630d1a80629 100644 --- a/tests/ui/traits/const-traits/specialization/specialize-on-conditionally-const.rs +++ b/tests/ui/traits/const-traits/specialization/specialize-on-conditionally-const.rs @@ -7,12 +7,10 @@ #![feature(rustc_attrs)] #![feature(min_specialization)] -#[const_trait] #[rustc_specialization_trait] -trait Specialize {} +const trait Specialize {} -#[const_trait] -trait Foo { +const trait Foo { fn foo(); } @@ -27,8 +25,7 @@ where fn foo() {} } -#[const_trait] -trait Bar { +const trait Bar { fn bar() {} } diff --git a/tests/ui/traits/const-traits/specializing-constness-2.rs b/tests/ui/traits/const-traits/specializing-constness-2.rs index 86c2cee9fedbc..455dd111603da 100644 --- a/tests/ui/traits/const-traits/specializing-constness-2.rs +++ b/tests/ui/traits/const-traits/specializing-constness-2.rs @@ -1,13 +1,11 @@ #![feature(const_trait_impl, min_specialization, rustc_attrs)] //@ known-bug: #110395 #[rustc_specialization_trait] -#[const_trait] -pub trait Sup {} +pub const trait Sup {} impl const Sup for () {} -#[const_trait] -pub trait A { +pub const trait A { fn a() -> u32; } diff --git a/tests/ui/traits/const-traits/specializing-constness-2.stderr b/tests/ui/traits/const-traits/specializing-constness-2.stderr index 2a34cd1c4f82d..bd6ffa544d0ec 100644 --- a/tests/ui/traits/const-traits/specializing-constness-2.stderr +++ b/tests/ui/traits/const-traits/specializing-constness-2.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `T: [const] A` is not satisfied - --> $DIR/specializing-constness-2.rs:27:6 + --> $DIR/specializing-constness-2.rs:25:6 | LL | ::a(); | ^ diff --git a/tests/ui/traits/const-traits/specializing-constness.rs b/tests/ui/traits/const-traits/specializing-constness.rs index b64d8b21b24be..6e9931e8a740a 100644 --- a/tests/ui/traits/const-traits/specializing-constness.rs +++ b/tests/ui/traits/const-traits/specializing-constness.rs @@ -1,18 +1,15 @@ #![feature(const_trait_impl, min_specialization, rustc_attrs)] #[rustc_specialization_trait] -#[const_trait] -pub trait Sup {} +pub const trait Sup {} impl const Sup for () {} -#[const_trait] -pub trait A { +pub const trait A { fn a() -> u32; } -#[const_trait] -pub trait Spec {} +pub const trait Spec {} impl const A for T { default fn a() -> u32 { diff --git a/tests/ui/traits/const-traits/specializing-constness.stderr b/tests/ui/traits/const-traits/specializing-constness.stderr index f411ebcdfcac5..e55b24f6f4fd1 100644 --- a/tests/ui/traits/const-traits/specializing-constness.stderr +++ b/tests/ui/traits/const-traits/specializing-constness.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `A` - --> $DIR/specializing-constness.rs:23:1 + --> $DIR/specializing-constness.rs:20:1 | LL | impl const A for T { | ----------------------------------- first implementation here diff --git a/tests/ui/traits/const-traits/staged-api.rs b/tests/ui/traits/const-traits/staged-api.rs index d24b26be569ca..6d0a84797ea24 100644 --- a/tests/ui/traits/const-traits/staged-api.rs +++ b/tests/ui/traits/const-traits/staged-api.rs @@ -86,13 +86,11 @@ const fn implicitly_stable_const_context() { } // check that const stability of impls and traits must match -#[const_trait] #[rustc_const_unstable(feature = "beef", issue = "none")] -trait U {} +const trait U {} -#[const_trait] #[rustc_const_stable(since = "0.0.0", feature = "beef2")] -trait S {} +const trait S {} // implied stable impl const U for u8 {} diff --git a/tests/ui/traits/const-traits/staged-api.stderr b/tests/ui/traits/const-traits/staged-api.stderr index 3e85834eb94ae..15328ae3b4553 100644 --- a/tests/ui/traits/const-traits/staged-api.stderr +++ b/tests/ui/traits/const-traits/staged-api.stderr @@ -1,22 +1,22 @@ error: const stability on the impl does not match the const stability on the trait - --> $DIR/staged-api.rs:98:1 + --> $DIR/staged-api.rs:96:1 | LL | impl const U for u8 {} | ^^^^^^^^^^^^^^^^^^^^^^ | note: this impl is (implicitly) stable... - --> $DIR/staged-api.rs:98:1 + --> $DIR/staged-api.rs:96:1 | LL | impl const U for u8 {} | ^^^^^^^^^^^^^^^^^^^^^^ note: ...but the trait is unstable - --> $DIR/staged-api.rs:91:7 + --> $DIR/staged-api.rs:90:13 | -LL | trait U {} - | ^ +LL | const trait U {} + | ^ error: trait implementations cannot be const stable yet - --> $DIR/staged-api.rs:102:1 + --> $DIR/staged-api.rs:100:1 | LL | impl const U for u16 {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,24 +24,24 @@ LL | impl const U for u16 {} = note: see issue #143874 for more information error: const stability on the impl does not match the const stability on the trait - --> $DIR/staged-api.rs:102:1 + --> $DIR/staged-api.rs:100:1 | LL | impl const U for u16 {} | ^^^^^^^^^^^^^^^^^^^^^^^ | note: this impl is (implicitly) stable... - --> $DIR/staged-api.rs:102:1 + --> $DIR/staged-api.rs:100:1 | LL | impl const U for u16 {} | ^^^^^^^^^^^^^^^^^^^^^^^ note: ...but the trait is unstable - --> $DIR/staged-api.rs:91:7 + --> $DIR/staged-api.rs:90:13 | -LL | trait U {} - | ^ +LL | const trait U {} + | ^ error: trait implementations cannot be const stable yet - --> $DIR/staged-api.rs:113:1 + --> $DIR/staged-api.rs:111:1 | LL | impl const S for u16 {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,21 +49,21 @@ LL | impl const S for u16 {} = note: see issue #143874 for more information error: const stability on the impl does not match the const stability on the trait - --> $DIR/staged-api.rs:117:1 + --> $DIR/staged-api.rs:115:1 | LL | impl const S for u32 {} | ^^^^^^^^^^^^^^^^^^^^^^^ | note: this impl is unstable... - --> $DIR/staged-api.rs:117:1 + --> $DIR/staged-api.rs:115:1 | LL | impl const S for u32 {} | ^^^^^^^^^^^^^^^^^^^^^^^ note: ...but the trait is stable - --> $DIR/staged-api.rs:95:7 + --> $DIR/staged-api.rs:93:13 | -LL | trait S {} - | ^ +LL | const trait S {} + | ^ error: const function that might be (indirectly) exposed to stable cannot use `#[feature(const_trait_impl)]` --> $DIR/staged-api.rs:38:5 diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr index c9dc239bef334..39fea4cbbf1c5 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr @@ -1,69 +1,68 @@ error: `[const]` is not allowed here - --> $DIR/super-traits-fail-2.rs:11:12 + --> $DIR/super-traits-fail-2.rs:14:32 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ +LL | #[cfg(any(yn, nn))] trait Bar: [const] Foo {} + | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/super-traits-fail-2.rs:11:1 + --> $DIR/super-traits-fail-2.rs:14:21 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[cfg(any(yn, nn))] trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-2.rs:11:12 + --> $DIR/super-traits-fail-2.rs:14:32 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yn, nn))] trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(ny, nn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-2.rs:11:12 + --> $DIR/super-traits-fail-2.rs:14:32 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yn, nn))] trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(ny, nn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-2.rs:11:12 + --> $DIR/super-traits-fail-2.rs:14:32 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yn, nn))] trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(ny, nn))] const trait Foo { fn a(&self); } + | +++++ error[E0015]: cannot call non-const method `::a` in constant functions - --> $DIR/super-traits-fail-2.rs:20:7 + --> $DIR/super-traits-fail-2.rs:21:7 | LL | x.a(); | ^^^ | note: method `a` is not const because trait `Foo` is not const - --> $DIR/super-traits-fail-2.rs:6:1 + --> $DIR/super-traits-fail-2.rs:6:21 | -LL | trait Foo { - | ^^^^^^^^^ this trait is not const -LL | fn a(&self); - | ------------ this method is not const +LL | #[cfg(any(ny, nn))] trait Foo { fn a(&self); } + | ^^^^^^^^^ ------------ this method is not const + | | + | this trait is not const = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | -LL + #[const_trait] -LL | trait Foo { - | +LL | #[cfg(any(ny, nn))] const trait Foo { fn a(&self); } + | +++++ error: aborting due to 5 previous errors diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr index bfbf6980ab833..652bcb66e8d56 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr @@ -1,81 +1,80 @@ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-2.rs:11:12 + --> $DIR/super-traits-fail-2.rs:8:38 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yy, ny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(ny, nn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-2.rs:11:12 + --> $DIR/super-traits-fail-2.rs:8:38 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yy, ny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(ny, nn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-2.rs:11:12 + --> $DIR/super-traits-fail-2.rs:8:38 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yy, ny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(ny, nn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-2.rs:11:12 + --> $DIR/super-traits-fail-2.rs:8:38 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yy, ny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(ny, nn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-2.rs:11:12 + --> $DIR/super-traits-fail-2.rs:8:38 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yy, ny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(ny, nn))] const trait Foo { fn a(&self); } + | +++++ error[E0015]: cannot call non-const method `::a` in constant functions - --> $DIR/super-traits-fail-2.rs:20:7 + --> $DIR/super-traits-fail-2.rs:21:7 | LL | x.a(); | ^^^ | note: method `a` is not const because trait `Foo` is not const - --> $DIR/super-traits-fail-2.rs:6:1 + --> $DIR/super-traits-fail-2.rs:6:21 | -LL | trait Foo { - | ^^^^^^^^^ this trait is not const -LL | fn a(&self); - | ------------ this method is not const +LL | #[cfg(any(ny, nn))] trait Foo { fn a(&self); } + | ^^^^^^^^^ ------------ this method is not const + | | + | this trait is not const = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | -LL + #[const_trait] -LL | trait Foo { - | +LL | #[cfg(any(ny, nn))] const trait Foo { fn a(&self); } + | +++++ error: aborting due to 6 previous errors diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.rs b/tests/ui/traits/const-traits/super-traits-fail-2.rs index 36e7c1c4e4acc..7dd888b87b0c1 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.rs +++ b/tests/ui/traits/const-traits/super-traits-fail-2.rs @@ -2,19 +2,20 @@ #![feature(const_trait_impl)] //@ revisions: yy yn ny nn -#[cfg_attr(any(yy, yn), const_trait)] -trait Foo { - fn a(&self); -} +#[cfg(any(yy, yn))] const trait Foo { fn a(&self); } +#[cfg(any(ny, nn))] trait Foo { fn a(&self); } -#[cfg_attr(any(yy, ny), const_trait)] -trait Bar: [const] Foo {} -//[ny,nn]~^ ERROR: `[const]` can only be applied to `const` traits -//[ny,nn]~| ERROR: `[const]` can only be applied to `const` traits -//[ny,nn]~| ERROR: `[const]` can only be applied to `const` traits +#[cfg(any(yy, ny))] const trait Bar: [const] Foo {} +//[ny]~^ ERROR: `[const]` can only be applied to `const` traits +//[ny]~| ERROR: `[const]` can only be applied to `const` traits +//[ny]~| ERROR: `[const]` can only be applied to `const` traits //[ny]~| ERROR: `[const]` can only be applied to `const` traits //[ny]~| ERROR: `[const]` can only be applied to `const` traits -//[yn,nn]~^^^^^^ ERROR: `[const]` is not allowed here +#[cfg(any(yn, nn))] trait Bar: [const] Foo {} +//[yn,nn]~^ ERROR: `[const]` is not allowed here +//[nn]~^^ ERROR: `[const]` can only be applied to `const` traits +//[nn]~| ERROR: `[const]` can only be applied to `const` traits +//[nn]~| ERROR: `[const]` can only be applied to `const` traits const fn foo(x: &T) { x.a(); diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr index 657e8ee82e322..65c6f833ccea1 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr @@ -1,17 +1,17 @@ error: `[const]` is not allowed here - --> $DIR/super-traits-fail-2.rs:11:12 + --> $DIR/super-traits-fail-2.rs:14:32 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ +LL | #[cfg(any(yn, nn))] trait Bar: [const] Foo {} + | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/super-traits-fail-2.rs:11:1 + --> $DIR/super-traits-fail-2.rs:14:21 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[cfg(any(yn, nn))] trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `T: [const] Foo` is not satisfied - --> $DIR/super-traits-fail-2.rs:20:7 + --> $DIR/super-traits-fail-2.rs:21:7 | LL | x.a(); | ^ diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.yy.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.yy.stderr index 4ae4bbde99bb2..c17a67132116e 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.yy.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.yy.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `T: [const] Foo` is not satisfied - --> $DIR/super-traits-fail-2.rs:20:7 + --> $DIR/super-traits-fail-2.rs:21:7 | LL | x.a(); | ^ diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr index ea487cbd563f2..b31d7eab53eaa 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr @@ -1,27 +1,57 @@ error: `[const]` is not allowed here - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:27:44 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/super-traits-fail-3.rs:23:1 + --> $DIR/super-traits-fail-3.rs:27:33 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:15:33 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ +LL | #[cfg(any(yyy, yyn, nyy, nyn))] const trait Foo { fn a(&self); } + | ^^^^^ | = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:19:33 + | +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^ + | + = note: see issue #143874 for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: const trait impls are experimental + --> $DIR/super-traits-fail-3.rs:19:50 + | +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^^^ + | + = note: see issue #143874 for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: const trait impls are experimental + --> $DIR/super-traits-fail-3.rs:27:44 + | +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^ + | + = note: see issue #143874 for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: const trait impls are experimental + --> $DIR/super-traits-fail-3.rs:34:17 | LL | const fn foo(x: &T) { | ^^^^^^^ @@ -31,53 +61,53 @@ LL | const fn foo(x: &T) { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:27:44 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:27:44 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:27:44 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:34:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: [const] Foo {} - | ++++++++++++++ +LL | #[cfg(any(yyn, ynn, nyn, nnn))] const trait Bar: [const] Foo {} + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:34:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` @@ -85,31 +115,30 @@ LL | const fn foo(x: &T) { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: [const] Foo {} - | ++++++++++++++ +LL | #[cfg(any(yyn, ynn, nyn, nnn))] const trait Bar: [const] Foo {} + | +++++ error[E0015]: cannot call non-const method `::a` in constant functions - --> $DIR/super-traits-fail-3.rs:36:7 + --> $DIR/super-traits-fail-3.rs:38:7 | LL | x.a(); | ^^^ | note: method `a` is not const because trait `Foo` is not const - --> $DIR/super-traits-fail-3.rs:17:1 + --> $DIR/super-traits-fail-3.rs:17:33 | -LL | trait Foo { - | ^^^^^^^^^ this trait is not const -LL | fn a(&self); - | ------------ this method is not const - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` +LL | #[cfg(any(yny, ynn, nny, nnn))] trait Foo { fn a(&self); } + | ^^^^^^^^^ ------------ this method is not const + | | + | this trait is not const + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable const traits = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | -LL + #[const_trait] -LL | trait Foo { - | +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ -error: aborting due to 9 previous errors +error: aborting due to 12 previous errors Some errors have detailed explanations: E0015, E0658. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr index ea487cbd563f2..ee43dd9d5fc52 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr @@ -1,27 +1,45 @@ -error: `[const]` is not allowed here - --> $DIR/super-traits-fail-3.rs:23:12 +error[E0658]: const trait impls are experimental + --> $DIR/super-traits-fail-3.rs:15:33 + | +LL | #[cfg(any(yyy, yyn, nyy, nyn))] const trait Foo { fn a(&self); } + | ^^^^^ | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ + = note: see issue #143874 for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: const trait impls are experimental + --> $DIR/super-traits-fail-3.rs:19:33 | -note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/super-traits-fail-3.rs:23:1 +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^ | -LL | trait Bar: [const] Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see issue #143874 for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:19:50 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^^^ | = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:27:44 + | +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^ + | + = note: see issue #143874 for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: const trait impls are experimental + --> $DIR/super-traits-fail-3.rs:34:17 | LL | const fn foo(x: &T) { | ^^^^^^^ @@ -31,85 +49,85 @@ LL | const fn foo(x: &T) { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:19:50 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:19:50 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:19:50 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:19:50 | -LL | const fn foo(x: &T) { - | ^^^^^^^ can't be applied to `Bar` +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | -help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: [const] Foo {} - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:19:50 | -LL | const fn foo(x: &T) { - | ^^^^^^^ can't be applied to `Bar` +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations +help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: [const] Foo {} - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error[E0015]: cannot call non-const method `::a` in constant functions - --> $DIR/super-traits-fail-3.rs:36:7 + --> $DIR/super-traits-fail-3.rs:38:7 | LL | x.a(); | ^^^ | note: method `a` is not const because trait `Foo` is not const - --> $DIR/super-traits-fail-3.rs:17:1 + --> $DIR/super-traits-fail-3.rs:17:33 | -LL | trait Foo { - | ^^^^^^^^^ this trait is not const -LL | fn a(&self); - | ------------ this method is not const - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable `#[const_trait]` +LL | #[cfg(any(yny, ynn, nny, nnn))] trait Foo { fn a(&self); } + | ^^^^^^^^^ ------------ this method is not const + | | + | this trait is not const + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable const traits = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | -LL + #[const_trait] -LL | trait Foo { - | +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ -error: aborting due to 9 previous errors +error: aborting due to 11 previous errors Some errors have detailed explanations: E0015, E0658. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr index b00ad706a5fa1..1c56aa1297944 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr @@ -1,54 +1,97 @@ +error: `[const]` is not allowed here + --> $DIR/super-traits-fail-3.rs:27:44 + | +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^ + | +note: this trait is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/super-traits-fail-3.rs:27:33 + | +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:15:33 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ +LL | #[cfg(any(yyy, yyn, nyy, nyn))] const trait Foo { fn a(&self); } + | ^^^^^ | = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:19:33 | -LL | const fn foo(x: &T) { - | ^^^^^^^ +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^ | = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future. - --> $DIR/super-traits-fail-3.rs:15:37 +error[E0658]: const trait impls are experimental + --> $DIR/super-traits-fail-3.rs:19:50 | -LL | #[cfg_attr(any(yyy, yyn, nyy, nyn), const_trait)] - | ^^^^^^^^^^^ +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^^^ | = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future. - --> $DIR/super-traits-fail-3.rs:21:37 +error[E0658]: const trait impls are experimental + --> $DIR/super-traits-fail-3.rs:27:44 | -LL | #[cfg_attr(any(yyy, yny, nyy, nyn), const_trait)] - | ^^^^^^^^^^^ +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^ | = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: cannot call conditionally-const method `::a` in constant functions - --> $DIR/super-traits-fail-3.rs:36:7 +error[E0658]: const trait impls are experimental + --> $DIR/super-traits-fail-3.rs:34:17 | -LL | x.a(); - | ^^^ +LL | const fn foo(x: &T) { + | ^^^^^^^ | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 5 previous errors +error: `[const]` can only be applied to `const` traits + --> $DIR/super-traits-fail-3.rs:34:17 + | +LL | const fn foo(x: &T) { + | ^^^^^^^ can't be applied to `Bar` + | +help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations + | +LL | #[cfg(any(yyn, ynn, nyn, nnn))] const trait Bar: [const] Foo {} + | +++++ + +error: `[const]` can only be applied to `const` traits + --> $DIR/super-traits-fail-3.rs:34:17 + | +LL | const fn foo(x: &T) { + | ^^^^^^^ can't be applied to `Bar` + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `const` to allow it to have `const` implementations + | +LL | #[cfg(any(yyn, ynn, nyn, nnn))] const trait Bar: [const] Foo {} + | +++++ + +error[E0015]: cannot call non-const method `::a` in constant functions + --> $DIR/super-traits-fail-3.rs:38:7 + | +LL | x.a(); + | ^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error: aborting due to 9 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors have detailed explanations: E0015, E0658. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr index b00ad706a5fa1..692e84176a78b 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr @@ -1,45 +1,55 @@ error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:15:33 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ +LL | #[cfg(any(yyy, yyn, nyy, nyn))] const trait Foo { fn a(&self); } + | ^^^^^ | = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:19:33 | -LL | const fn foo(x: &T) { - | ^^^^^^^ +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^ | = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future. - --> $DIR/super-traits-fail-3.rs:15:37 +error[E0658]: const trait impls are experimental + --> $DIR/super-traits-fail-3.rs:19:50 | -LL | #[cfg_attr(any(yyy, yyn, nyy, nyn), const_trait)] - | ^^^^^^^^^^^ +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^^^ | = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future. - --> $DIR/super-traits-fail-3.rs:21:37 +error[E0658]: const trait impls are experimental + --> $DIR/super-traits-fail-3.rs:27:44 | -LL | #[cfg_attr(any(yyy, yny, nyy, nyn), const_trait)] - | ^^^^^^^^^^^ +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^ + | + = note: see issue #143874 for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: const trait impls are experimental + --> $DIR/super-traits-fail-3.rs:34:17 + | +LL | const fn foo(x: &T) { + | ^^^^^^^ | = note: see issue #143874 for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: cannot call conditionally-const method `::a` in constant functions - --> $DIR/super-traits-fail-3.rs:36:7 + --> $DIR/super-traits-fail-3.rs:38:7 | LL | x.a(); | ^^^ @@ -49,6 +59,6 @@ LL | x.a(); = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.rs b/tests/ui/traits/const-traits/super-traits-fail-3.rs index d74bd34678407..7dd434c528d09 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.rs +++ b/tests/ui/traits/const-traits/super-traits-fail-3.rs @@ -12,31 +12,33 @@ /// nny: feature not enabled, Foo is not const, Bar is const /// nnn: feature not enabled, Foo is not const, Bar is not const -#[cfg_attr(any(yyy, yyn, nyy, nyn), const_trait)] -//[nyy,nyn]~^ ERROR: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future -trait Foo { - fn a(&self); -} +#[cfg(any(yyy, yyn, nyy, nyn))] const trait Foo { fn a(&self); } +//[nyy,nyn,nny,nnn]~^ ERROR: const trait impls are experimental +#[cfg(any(yny, ynn, nny, nnn))] trait Foo { fn a(&self); } -#[cfg_attr(any(yyy, yny, nyy, nyn), const_trait)] -//[nyy,nyn]~^ ERROR: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future -trait Bar: [const] Foo {} -//[yny,ynn,nny,nnn]~^ ERROR: `[const]` can only be applied to `const` traits -//[yny,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `const` traits -//[yny,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `const` traits -//[yny]~^^^^ ERROR: `[const]` can only be applied to `const` traits -//[yny]~| ERROR: `[const]` can only be applied to `const` traits -//[yyn,ynn,nny,nnn]~^^^^^^ ERROR: `[const]` is not allowed here -//[nyy,nyn,nny,nnn]~^^^^^^^ ERROR: const trait impls are experimental +#[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} +//[nyy,nyn,nny,nnn]~^ ERROR: const trait impls are experimental +//[nyy,nyn,nny,nnn]~| ERROR: const trait impls are experimental +//[yny,nny]~^^^ ERROR: `[const]` can only be applied to `const` traits +//[yny,nny]~| ERROR: `[const]` can only be applied to `const` traits +//[yny,nny]~| ERROR: `[const]` can only be applied to `const` traits +//[yny,nny]~| ERROR: `[const]` can only be applied to `const` traits +//[yny,nny]~| ERROR: `[const]` can only be applied to `const` traits +#[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} +//[yyn,ynn,nyn,nnn]~^ ERROR: `[const]` is not allowed here +//[nyy,nyn,nny,nnn]~^^ ERROR: const trait impls are experimental +//[ynn,nnn]~^^^ ERROR: `[const]` can only be applied to `const` traits +//[ynn,nnn]~| ERROR: `[const]` can only be applied to `const` traits +//[ynn,nnn]~| ERROR: `[const]` can only be applied to `const` traits const fn foo(x: &T) { - //[yyn,ynn,nny,nnn]~^ ERROR: `[const]` can only be applied to `const` traits - //[yyn,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `const` traits + //[yyn,ynn,nyn,nnn]~^ ERROR: `[const]` can only be applied to `const` traits + //[yyn,ynn,nyn,nnn]~| ERROR: `[const]` can only be applied to `const` traits //[nyy,nyn,nny,nnn]~^^^ ERROR: const trait impls are experimental x.a(); //[yyn]~^ ERROR: the trait bound `T: [const] Foo` is not satisfied - //[ynn,yny,nny,nnn]~^^ ERROR: cannot call non-const method `::a` in constant functions - //[nyy,nyn]~^^^ ERROR: cannot call conditionally-const method `::a` in constant functions + //[ynn,yny,nny,nnn,nyn]~^^ ERROR: cannot call non-const method `::a` in constant functions + //[nyy]~^^^ ERROR: cannot call conditionally-const method `::a` in constant functions } fn main() {} diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr index 5951caebe7335..4b02310d75fa5 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr @@ -1,63 +1,63 @@ error: `[const]` is not allowed here - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:27:44 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/super-traits-fail-3.rs:23:1 + --> $DIR/super-traits-fail-3.rs:27:33 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:27:44 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:27:44 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:27:44 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:34:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` | help: mark `Bar` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: [const] Foo {} - | ++++++++++++++ +LL | #[cfg(any(yyn, ynn, nyn, nnn))] const trait Bar: [const] Foo {} + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:34:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` @@ -65,28 +65,27 @@ LL | const fn foo(x: &T) { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Bar` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: [const] Foo {} - | ++++++++++++++ +LL | #[cfg(any(yyn, ynn, nyn, nnn))] const trait Bar: [const] Foo {} + | +++++ error[E0015]: cannot call non-const method `::a` in constant functions - --> $DIR/super-traits-fail-3.rs:36:7 + --> $DIR/super-traits-fail-3.rs:38:7 | LL | x.a(); | ^^^ | note: method `a` is not const because trait `Foo` is not const - --> $DIR/super-traits-fail-3.rs:17:1 + --> $DIR/super-traits-fail-3.rs:17:33 | -LL | trait Foo { - | ^^^^^^^^^ this trait is not const -LL | fn a(&self); - | ------------ this method is not const +LL | #[cfg(any(yny, ynn, nny, nnn))] trait Foo { fn a(&self); } + | ^^^^^^^^^ ------------ this method is not const + | | + | this trait is not const = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | -LL + #[const_trait] -LL | trait Foo { - | +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: aborting due to 7 previous errors diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr index 563495204ad7b..cf86cbbd0e251 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr @@ -1,81 +1,80 @@ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:19:50 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:19:50 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:19:50 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:19:50 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:19:50 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ can't be applied to `Foo` +LL | #[cfg(any(yyy, yny, nyy, nny))] const trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Foo { - | ++++++++++++++ +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error[E0015]: cannot call non-const method `::a` in constant functions - --> $DIR/super-traits-fail-3.rs:36:7 + --> $DIR/super-traits-fail-3.rs:38:7 | LL | x.a(); | ^^^ | note: method `a` is not const because trait `Foo` is not const - --> $DIR/super-traits-fail-3.rs:17:1 + --> $DIR/super-traits-fail-3.rs:17:33 | -LL | trait Foo { - | ^^^^^^^^^ this trait is not const -LL | fn a(&self); - | ------------ this method is not const +LL | #[cfg(any(yny, ynn, nny, nnn))] trait Foo { fn a(&self); } + | ^^^^^^^^^ ------------ this method is not const + | | + | this trait is not const = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants help: consider making trait `Foo` const | -LL + #[const_trait] -LL | trait Foo { - | +LL | #[cfg(any(yny, ynn, nny, nnn))] const trait Foo { fn a(&self); } + | +++++ error: aborting due to 6 previous errors diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr index de3664dae841f..7b5a1f7a6a230 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr @@ -1,28 +1,28 @@ error: `[const]` is not allowed here - --> $DIR/super-traits-fail-3.rs:23:12 + --> $DIR/super-traits-fail-3.rs:27:44 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^ +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^ | note: this trait is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/super-traits-fail-3.rs:23:1 + --> $DIR/super-traits-fail-3.rs:27:33 | -LL | trait Bar: [const] Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[cfg(any(yyn, ynn, nyn, nnn))] trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:34:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` | help: mark `Bar` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: [const] Foo {} - | ++++++++++++++ +LL | #[cfg(any(yyn, ynn, nyn, nnn))] const trait Bar: [const] Foo {} + | +++++ error: `[const]` can only be applied to `const` traits - --> $DIR/super-traits-fail-3.rs:32:17 + --> $DIR/super-traits-fail-3.rs:34:17 | LL | const fn foo(x: &T) { | ^^^^^^^ can't be applied to `Bar` @@ -30,11 +30,11 @@ LL | const fn foo(x: &T) { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Bar` as `const` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: [const] Foo {} - | ++++++++++++++ +LL | #[cfg(any(yyn, ynn, nyn, nnn))] const trait Bar: [const] Foo {} + | +++++ error[E0277]: the trait bound `T: [const] Foo` is not satisfied - --> $DIR/super-traits-fail-3.rs:36:7 + --> $DIR/super-traits-fail-3.rs:38:7 | LL | x.a(); | ^ diff --git a/tests/ui/traits/const-traits/super-traits-fail.rs b/tests/ui/traits/const-traits/super-traits-fail.rs index 15e05be4d8628..4f835fd4191ca 100644 --- a/tests/ui/traits/const-traits/super-traits-fail.rs +++ b/tests/ui/traits/const-traits/super-traits-fail.rs @@ -2,12 +2,10 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Foo { +const trait Foo { fn a(&self); } -#[const_trait] -trait Bar: [const] Foo {} +const trait Bar: [const] Foo {} struct S; impl Foo for S { diff --git a/tests/ui/traits/const-traits/super-traits-fail.stderr b/tests/ui/traits/const-traits/super-traits-fail.stderr index 3010a5df0c31f..37ce0586deb4e 100644 --- a/tests/ui/traits/const-traits/super-traits-fail.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `S: [const] Foo` is not satisfied - --> $DIR/super-traits-fail.rs:17:20 + --> $DIR/super-traits-fail.rs:15:20 | LL | impl const Bar for S {} | ^ diff --git a/tests/ui/traits/const-traits/super-traits.rs b/tests/ui/traits/const-traits/super-traits.rs index b5fd985ae439e..169627149a300 100644 --- a/tests/ui/traits/const-traits/super-traits.rs +++ b/tests/ui/traits/const-traits/super-traits.rs @@ -2,13 +2,11 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -trait Foo { +const trait Foo { fn a(&self); } -#[const_trait] -trait Bar: [const] Foo {} +const trait Bar: [const] Foo {} struct S; impl const Foo for S { diff --git a/tests/ui/traits/const-traits/syntactical-unstable.rs b/tests/ui/traits/const-traits/syntactical-unstable.rs index 5c542d327f151..6518dd0ac4bb3 100644 --- a/tests/ui/traits/const-traits/syntactical-unstable.rs +++ b/tests/ui/traits/const-traits/syntactical-unstable.rs @@ -9,8 +9,7 @@ use std::ops::Deref; extern crate staged_api; use staged_api::MyTrait; -#[const_trait] -trait Foo: [const] MyTrait { +const trait Foo: [const] MyTrait { //~^ ERROR use of unstable const library feature `unstable` type Item: [const] MyTrait; //~^ ERROR use of unstable const library feature `unstable` diff --git a/tests/ui/traits/const-traits/syntactical-unstable.stderr b/tests/ui/traits/const-traits/syntactical-unstable.stderr index b8cc8e69f75b3..e2a65c724438b 100644 --- a/tests/ui/traits/const-traits/syntactical-unstable.stderr +++ b/tests/ui/traits/const-traits/syntactical-unstable.stderr @@ -1,16 +1,16 @@ error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:13:20 + --> $DIR/syntactical-unstable.rs:12:26 | -LL | trait Foo: [const] MyTrait { - | ------- ^^^^^^^ - | | - | trait is not stable as const yet +LL | const trait Foo: [const] MyTrait { + | ------- ^^^^^^^ + | | + | trait is not stable as const yet | = help: add `#![feature(unstable)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:19:45 + --> $DIR/syntactical-unstable.rs:18:45 | LL | const fn where_clause() where T: [const] MyTrait {} | ------- ^^^^^^^ @@ -21,7 +21,7 @@ LL | const fn where_clause() where T: [const] MyTrait {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:22:53 + --> $DIR/syntactical-unstable.rs:21:53 | LL | const fn nested() where T: Deref {} | ------- ^^^^^^^ @@ -32,7 +32,7 @@ LL | const fn nested() where T: Deref {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:25:33 + --> $DIR/syntactical-unstable.rs:24:33 | LL | const fn rpit() -> impl [const] MyTrait { Local } | ------- ^^^^^^^ @@ -43,7 +43,7 @@ LL | const fn rpit() -> impl [const] MyTrait { Local } = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:29:12 + --> $DIR/syntactical-unstable.rs:28:12 | LL | impl const MyTrait for Local { | ^^^^^^^ trait is not stable as const yet @@ -52,7 +52,7 @@ LL | impl const MyTrait for Local { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:15:24 + --> $DIR/syntactical-unstable.rs:14:24 | LL | type Item: [const] MyTrait; | ------- ^^^^^^^ diff --git a/tests/ui/traits/const-traits/trait-default-body-stability.rs b/tests/ui/traits/const-traits/trait-default-body-stability.rs index a8157d37ce3f9..1053f54aa6fce 100644 --- a/tests/ui/traits/const-traits/trait-default-body-stability.rs +++ b/tests/ui/traits/const-traits/trait-default-body-stability.rs @@ -39,8 +39,7 @@ impl const FromResidual for T { #[stable(feature = "foo", since = "1.0")] #[rustc_const_unstable(feature = "const_tr", issue = "none")] -#[const_trait] -pub trait Tr { +pub const trait Tr { #[stable(feature = "foo", since = "1.0")] fn bar() -> T { T? diff --git a/tests/ui/traits/const-traits/trait-fn-const.rs b/tests/ui/traits/const-traits/trait-fn-const.rs index 07eac032a82a6..b8ad7b867a5a3 100644 --- a/tests/ui/traits/const-traits/trait-fn-const.rs +++ b/tests/ui/traits/const-traits/trait-fn-const.rs @@ -1,8 +1,7 @@ // Regression test for issue #113378. #![feature(const_trait_impl)] -#[const_trait] -trait Trait { +const trait Trait { const fn fun(); //~ ERROR functions in traits cannot be declared const } diff --git a/tests/ui/traits/const-traits/trait-fn-const.stderr b/tests/ui/traits/const-traits/trait-fn-const.stderr index 4d0b03046d27d..6e1ad29a3c2c1 100644 --- a/tests/ui/traits/const-traits/trait-fn-const.stderr +++ b/tests/ui/traits/const-traits/trait-fn-const.stderr @@ -1,9 +1,8 @@ error[E0379]: functions in traits cannot be declared const - --> $DIR/trait-fn-const.rs:6:5 + --> $DIR/trait-fn-const.rs:5:5 | -LL | #[const_trait] - | -------------- this declares all associated functions implicitly const -LL | trait Trait { +LL | const trait Trait { + | ----- this declares all associated functions implicitly const LL | const fn fun(); | ^^^^^- | | @@ -11,7 +10,7 @@ LL | const fn fun(); | help: remove the `const` error[E0379]: functions in trait impls cannot be declared const - --> $DIR/trait-fn-const.rs:10:5 + --> $DIR/trait-fn-const.rs:9:5 | LL | impl const Trait for () { | ----- this declares all associated functions implicitly const @@ -22,7 +21,7 @@ LL | const fn fun() {} | help: remove the `const` error[E0379]: functions in trait impls cannot be declared const - --> $DIR/trait-fn-const.rs:14:5 + --> $DIR/trait-fn-const.rs:13:5 | LL | const fn fun() {} | ^^^^^ functions in trait impls cannot be const @@ -38,7 +37,7 @@ LL | impl const Trait for u32 { | +++++ error[E0379]: functions in traits cannot be declared const - --> $DIR/trait-fn-const.rs:18:5 + --> $DIR/trait-fn-const.rs:17:5 | LL | const fn fun(); | ^^^^^ functions in traits cannot be const @@ -48,11 +47,10 @@ help: remove the `const` ... LL - const fn fun(); LL + fn fun(); | -help: ... and declare the trait to be a `#[const_trait]` instead - | -LL + #[const_trait] -LL | trait NonConst { +help: ... and declare the trait to be const instead | +LL | const trait NonConst { + | +++++ error: aborting due to 4 previous errors diff --git a/tests/ui/traits/const-traits/trait-where-clause-const.rs b/tests/ui/traits/const-traits/trait-where-clause-const.rs index ccb514086cc87..548c5529945dc 100644 --- a/tests/ui/traits/const-traits/trait-where-clause-const.rs +++ b/tests/ui/traits/const-traits/trait-where-clause-const.rs @@ -6,11 +6,9 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Bar {} +const trait Bar {} -#[const_trait] -trait Foo { +const trait Foo { fn a(); fn b() where Self: [const] Bar; fn c(); diff --git a/tests/ui/traits/const-traits/trait-where-clause-const.stderr b/tests/ui/traits/const-traits/trait-where-clause-const.stderr index 71f9bdff8786e..20dd395b820bf 100644 --- a/tests/ui/traits/const-traits/trait-where-clause-const.stderr +++ b/tests/ui/traits/const-traits/trait-where-clause-const.stderr @@ -1,23 +1,23 @@ error[E0277]: the trait bound `T: [const] Bar` is not satisfied - --> $DIR/trait-where-clause-const.rs:21:5 + --> $DIR/trait-where-clause-const.rs:19:5 | LL | T::b(); | ^ | note: required by a bound in `Foo::b` - --> $DIR/trait-where-clause-const.rs:15:24 + --> $DIR/trait-where-clause-const.rs:13:24 | LL | fn b() where Self: [const] Bar; | ^^^^^^^^^^^ required by this bound in `Foo::b` error[E0277]: the trait bound `T: [const] Bar` is not satisfied - --> $DIR/trait-where-clause-const.rs:23:12 + --> $DIR/trait-where-clause-const.rs:21:12 | LL | T::c::(); | ^ | note: required by a bound in `Foo::c` - --> $DIR/trait-where-clause-const.rs:16:13 + --> $DIR/trait-where-clause-const.rs:14:13 | LL | fn c(); | ^^^^^^^^^^^ required by this bound in `Foo::c` diff --git a/tests/ui/traits/const-traits/trait-where-clause-run.rs b/tests/ui/traits/const-traits/trait-where-clause-run.rs index c40f071f45728..d24a2abb17833 100644 --- a/tests/ui/traits/const-traits/trait-where-clause-run.rs +++ b/tests/ui/traits/const-traits/trait-where-clause-run.rs @@ -3,13 +3,11 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Bar { +const trait Bar { fn bar() -> u8; } -#[const_trait] -trait Foo { +const trait Foo { fn foo() -> u8 where Self: [const] Bar { ::bar() * 6 } diff --git a/tests/ui/traits/const-traits/trait-where-clause-self-referential.rs b/tests/ui/traits/const-traits/trait-where-clause-self-referential.rs index 3a5350cd4ea3d..39829adbaf4b5 100644 --- a/tests/ui/traits/const-traits/trait-where-clause-self-referential.rs +++ b/tests/ui/traits/const-traits/trait-where-clause-self-referential.rs @@ -2,8 +2,7 @@ //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -#[const_trait] -trait Foo { +const trait Foo { fn bar() where Self: [const] Foo; } diff --git a/tests/ui/traits/const-traits/trait-where-clause.rs b/tests/ui/traits/const-traits/trait-where-clause.rs index 6aebab79090a9..3ff53f590f812 100644 --- a/tests/ui/traits/const-traits/trait-where-clause.rs +++ b/tests/ui/traits/const-traits/trait-where-clause.rs @@ -1,7 +1,6 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Bar {} +const trait Bar {} trait Foo { fn a(); diff --git a/tests/ui/traits/const-traits/trait-where-clause.stderr b/tests/ui/traits/const-traits/trait-where-clause.stderr index dda91e6bca1ed..57d87f74565e2 100644 --- a/tests/ui/traits/const-traits/trait-where-clause.stderr +++ b/tests/ui/traits/const-traits/trait-where-clause.stderr @@ -1,35 +1,35 @@ error: `[const]` is not allowed here - --> $DIR/trait-where-clause.rs:8:24 + --> $DIR/trait-where-clause.rs:7:24 | LL | fn b() where Self: [const] Bar; | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/trait-where-clause.rs:8:8 + --> $DIR/trait-where-clause.rs:7:8 | LL | fn b() where Self: [const] Bar; | ^ error: `[const]` is not allowed here - --> $DIR/trait-where-clause.rs:10:13 + --> $DIR/trait-where-clause.rs:9:13 | LL | fn c(); | ^^^^^^^ | note: this function is not `const`, so it cannot have `[const]` trait bounds - --> $DIR/trait-where-clause.rs:10:8 + --> $DIR/trait-where-clause.rs:9:8 | LL | fn c(); | ^ error[E0277]: the trait bound `T: Bar` is not satisfied - --> $DIR/trait-where-clause.rs:16:5 + --> $DIR/trait-where-clause.rs:15:5 | LL | T::b(); | ^ the trait `Bar` is not implemented for `T` | note: required by a bound in `Foo::b` - --> $DIR/trait-where-clause.rs:8:24 + --> $DIR/trait-where-clause.rs:7:24 | LL | fn b() where Self: [const] Bar; | ^^^^^^^^^^^ required by this bound in `Foo::b` @@ -39,13 +39,13 @@ LL | fn test1() { | +++++ error[E0277]: the trait bound `T: Bar` is not satisfied - --> $DIR/trait-where-clause.rs:18:12 + --> $DIR/trait-where-clause.rs:17:12 | LL | T::c::(); | ^ the trait `Bar` is not implemented for `T` | note: required by a bound in `Foo::c` - --> $DIR/trait-where-clause.rs:10:13 + --> $DIR/trait-where-clause.rs:9:13 | LL | fn c(); | ^^^^^^^^^^^ required by this bound in `Foo::c` diff --git a/tests/ui/traits/const-traits/unconstrained-var-specialization.rs b/tests/ui/traits/const-traits/unconstrained-var-specialization.rs index 43a3311445012..4330e0aead1ac 100644 --- a/tests/ui/traits/const-traits/unconstrained-var-specialization.rs +++ b/tests/ui/traits/const-traits/unconstrained-var-specialization.rs @@ -7,8 +7,7 @@ // In the default impl below, `A` is constrained by the projection predicate, and if the host effect // predicate for `const Foo` doesn't resolve vars, then specialization will fail. -#[const_trait] -trait Foo {} +const trait Foo {} pub trait Iterator { type Item; diff --git a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs index c82b442750097..57641423643e8 100644 --- a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs +++ b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs @@ -7,8 +7,7 @@ fn require() {} -#[const_trait] -trait Trait { +const trait Trait { fn make() -> u32; } diff --git a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr index 9750d806ce97a..1a2bc6c2c5f59 100644 --- a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr +++ b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr @@ -7,88 +7,88 @@ LL | #![feature(const_trait_impl, generic_const_exprs)] = help: remove one of these features error[E0391]: cycle detected when evaluating type-level constant - --> $DIR/unsatisfied-const-trait-bound.rs:29:35 + --> $DIR/unsatisfied-const-trait-bound.rs:28:35 | LL | fn accept0(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ | note: ...which requires const-evaluating + checking `accept0::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:29:35 + --> $DIR/unsatisfied-const-trait-bound.rs:28:35 | LL | fn accept0(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ note: ...which requires checking if `accept0::{constant#0}` is a trivial const... - --> $DIR/unsatisfied-const-trait-bound.rs:29:35 + --> $DIR/unsatisfied-const-trait-bound.rs:28:35 | LL | fn accept0(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ note: ...which requires building MIR for `accept0::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:29:35 + --> $DIR/unsatisfied-const-trait-bound.rs:28:35 | LL | fn accept0(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ note: ...which requires building an abstract representation for `accept0::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:29:35 + --> $DIR/unsatisfied-const-trait-bound.rs:28:35 | LL | fn accept0(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ note: ...which requires building THIR for `accept0::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:29:35 + --> $DIR/unsatisfied-const-trait-bound.rs:28:35 | LL | fn accept0(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ note: ...which requires type-checking `accept0::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:29:35 + --> $DIR/unsatisfied-const-trait-bound.rs:28:35 | LL | fn accept0(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ = note: ...which again requires evaluating type-level constant, completing the cycle note: cycle used when checking that `accept0` is well-formed - --> $DIR/unsatisfied-const-trait-bound.rs:29:35 + --> $DIR/unsatisfied-const-trait-bound.rs:28:35 | LL | fn accept0(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when checking if `accept1::{constant#0}` is a trivial const - --> $DIR/unsatisfied-const-trait-bound.rs:33:49 + --> $DIR/unsatisfied-const-trait-bound.rs:32:49 | LL | const fn accept1(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ | note: ...which requires building MIR for `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:49 + --> $DIR/unsatisfied-const-trait-bound.rs:32:49 | LL | const fn accept1(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ note: ...which requires building an abstract representation for `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:49 + --> $DIR/unsatisfied-const-trait-bound.rs:32:49 | LL | const fn accept1(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ note: ...which requires building THIR for `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:49 + --> $DIR/unsatisfied-const-trait-bound.rs:32:49 | LL | const fn accept1(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ note: ...which requires type-checking `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:49 + --> $DIR/unsatisfied-const-trait-bound.rs:32:49 | LL | const fn accept1(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ note: ...which requires evaluating type-level constant... - --> $DIR/unsatisfied-const-trait-bound.rs:33:49 + --> $DIR/unsatisfied-const-trait-bound.rs:32:49 | LL | const fn accept1(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ note: ...which requires const-evaluating + checking `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:49 + --> $DIR/unsatisfied-const-trait-bound.rs:32:49 | LL | const fn accept1(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ = note: ...which again requires checking if `accept1::{constant#0}` is a trivial const, completing the cycle note: cycle used when const-evaluating + checking `accept1::{constant#0}` - --> $DIR/unsatisfied-const-trait-bound.rs:33:49 + --> $DIR/unsatisfied-const-trait-bound.rs:32:49 | LL | const fn accept1(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ diff --git a/tests/ui/traits/const-traits/variance.rs b/tests/ui/traits/const-traits/variance.rs index 90b5c50161d51..73014703adc03 100644 --- a/tests/ui/traits/const-traits/variance.rs +++ b/tests/ui/traits/const-traits/variance.rs @@ -2,8 +2,7 @@ #![allow(internal_features)] #![rustc_variance_of_opaques] -#[const_trait] -trait Foo {} +const trait Foo {} impl const Foo for () {} diff --git a/tests/ui/traits/const-traits/variance.stderr b/tests/ui/traits/const-traits/variance.stderr index f55069311848a..1367ec6929a52 100644 --- a/tests/ui/traits/const-traits/variance.stderr +++ b/tests/ui/traits/const-traits/variance.stderr @@ -1,5 +1,5 @@ error: ['a: *] - --> $DIR/variance.rs:10:21 + --> $DIR/variance.rs:9:21 | LL | fn foo<'a: 'a>() -> impl const Foo {} | ^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/next-solver/canonical/effect-var.rs b/tests/ui/traits/next-solver/canonical/effect-var.rs index 82dbde0413c49..872a70417f485 100644 --- a/tests/ui/traits/next-solver/canonical/effect-var.rs +++ b/tests/ui/traits/next-solver/canonical/effect-var.rs @@ -3,8 +3,7 @@ #![feature(const_trait_impl)] -#[const_trait] -trait Foo { +const trait Foo { fn foo(); }