Remove #[const_trait]

This commit is contained in:
León Orell Valerian Liehr 2025-11-07 22:42:31 +01:00
parent 8aedbf12f6
commit c262920059
No known key found for this signature in database
GPG key ID: D17A07215F68E713
198 changed files with 945 additions and 1073 deletions

View file

@ -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

View file

@ -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);
});
}

View file

@ -56,7 +56,7 @@ pub(crate) struct TraitFnConst {
pub make_impl_const_sugg: Option<Span>,
#[suggestion(
ast_passes_make_trait_const_sugg,
code = "#[const_trait]\n",
code = "const ",
applicability = "maybe-incorrect"
)]
pub make_trait_const_sugg: Option<Span>,

View file

@ -101,17 +101,6 @@ impl<S: Stage> NoArgsAttributeParser<S> for DoNotImplementViaObjectParser {
const CREATE: fn(Span) -> AttributeKind = AttributeKind::DoNotImplementViaObject;
}
// FIXME(const_trait_impl): remove this
// Const traits
pub(crate) struct ConstTraitParser;
impl<S: Stage> NoArgsAttributeParser<S> for ConstTraitParser {
const PATH: &[Symbol] = &[sym::const_trait];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Trait)]);
const CREATE: fn(Span) -> AttributeKind = AttributeKind::ConstTrait;
}
// Specialization
pub(crate) struct SpecializationTraitParser;

View file

@ -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<WithoutArgs<ColdParser>>,
Single<WithoutArgs<ConstContinueParser>>,
Single<WithoutArgs<ConstStabilityIndirectParser>>,
Single<WithoutArgs<ConstTraitParser>>,
Single<WithoutArgs<CoroutineParser>>,
Single<WithoutArgs<DenyExplicitImplParser>>,
Single<WithoutArgs<DoNotImplementViaObjectParser>>,

View file

@ -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() {

View file

@ -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,

View file

@ -489,9 +489,6 @@ pub enum AttributeKind {
/// Represents `#[rustc_const_stable_indirect]`.
ConstStabilityIndirect,
/// Represents `#[const_trait]`.
ConstTrait(Span),
/// Represents `#[coroutine]`.
Coroutine(Span),

View file

@ -32,7 +32,6 @@ impl AttributeKind {
ConstContinue(..) => No,
ConstStability { .. } => Yes,
ConstStabilityIndirect => No,
ConstTrait(..) => No,
Coroutine(..) => No,
Coverage(..) => No,
CrateName { .. } => No,

View file

@ -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: (),

View file

@ -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<Span>,
#[suggestion(applicability = "machine-applicable", code = "const ", style = "verbose")]
pub suggestion: Option<Span>,
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<Span>,
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<Span>,
pub suggestion_pre: &'static str,
pub trait_name: String,
}

View file

@ -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 {

View file

@ -235,7 +235,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| AttributeKind::Marker(..)
| AttributeKind::SkipDuringMethodDispatch { .. }
| AttributeKind::Coinductive(..)
| AttributeKind::ConstTrait(..)
| AttributeKind::DenyExplicitImpl(..)
| AttributeKind::DoNotImplementViaObject(..)
| AttributeKind::SpecializationTrait(..)

View file

@ -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,

View file

@ -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<T: [const] Bar>(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 `<T as Foo>::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

View file

@ -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<T: [const] Bar>(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 `<T as Foo>::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

View file

@ -3,8 +3,7 @@
#![crate_name = "foo"]
#![feature(const_trait_impl)]
#[const_trait]
pub trait Tr {
pub const trait Tr {
fn f();
}

View file

@ -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() {}
}

View file

@ -19,8 +19,7 @@ pub struct S<T>(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<T> {
pub const trait Tr<T> {
//@ !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]'

View file

@ -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<R: [const] Resource>() -> i32 {
0

View file

@ -3,8 +3,7 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Func<T> {
const trait Func<T> {
type Output;
fn call_once(self, arg: T) -> Self::Output;

View file

@ -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];
}

View file

@ -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<T: ?Sized + ConstName> 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<T: ?Sized + ConstName> const ConstName for &T
| ^^
error[E0275]: overflow evaluating the requirement `[(); name_len::<T>()] well-formed`
--> $DIR/issue-88119.rs:21:5
--> $DIR/issue-88119.rs:20:5
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^
|
note: required by a bound in `<&T as ConstName>`
--> $DIR/issue-88119.rs:21:5
--> $DIR/issue-88119.rs:20:5
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&T as ConstName>`
error[E0275]: overflow evaluating the requirement `[(); name_len::<T>()] well-formed`
--> $DIR/issue-88119.rs:21:10
--> $DIR/issue-88119.rs:20:10
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^
|
note: required by a bound in `<&T as ConstName>`
--> $DIR/issue-88119.rs:21:5
--> $DIR/issue-88119.rs:20:5
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^ 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<T: ?Sized + ConstName> 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<T: ?Sized + ConstName> const ConstName for &mut T
| ^^^^^^
error[E0275]: overflow evaluating the requirement `[(); name_len::<T>()] well-formed`
--> $DIR/issue-88119.rs:28:5
--> $DIR/issue-88119.rs:27:5
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^
|
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::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&mut T as ConstName>`
error[E0275]: overflow evaluating the requirement `[(); name_len::<T>()] well-formed`
--> $DIR/issue-88119.rs:28:10
--> $DIR/issue-88119.rs:27:10
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^
|
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::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^ 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;
| ^^^^^^^^

View file

@ -1,7 +1,6 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Trait {
const trait Trait {
const N: usize;
}

View file

@ -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

View file

@ -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;
}

View file

@ -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<T: [const] Tr>() -> [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()]
| ^

View file

@ -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

View file

@ -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

View file

@ -48,8 +48,7 @@ mod recursive {
}
mod effects {
#[const_trait]
trait Trait {
const trait Trait {
fn foo();
}

View file

@ -11,8 +11,7 @@ const CREATE<T: const Create>: T = T::create();
pub const K0: i32 = CREATE::<i32>;
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: const Create>: T;
}

View file

@ -4,8 +4,7 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Trait {
const trait Trait {
fn required();
}

View file

@ -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 `<Dim3 as Dim>::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

View file

@ -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;
}

View file

@ -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<T: [const] Debug> 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<T: [const] Debug + [const] Sup> 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<T: [const] Debug + [const] Sub> 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<T: [const] Debug + [const] Sup> 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<T: [const] Debug> 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<T: [const] Debug + [const] Sub> const A for T {
| ^^^^^^^ can't be applied to `Debug`

View file

@ -27,7 +27,7 @@ pub enum Bar {
}
}
#[const_trait] pub trait ConstDefault {
pub const trait ConstDefault {
fn value() -> Self;
}

View file

@ -4,8 +4,7 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Trait {
const trait Trait {
type Assoc: [const] Trait;
fn func() -> i32;
}

View file

@ -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;
}

View file

@ -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::<U>::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 | <T as Trait>::Assoc::<U>::func();
| ^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -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::<U>::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 | <T as Trait>::Assoc::<U>::func();
| ^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -8,8 +8,7 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Trait {
const trait Trait {
type Assoc<U>: [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: [const] Trait, U: Other>() {
T::Assoc::<U>::func();

View file

@ -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 | <T as Trait>::Assoc::func();
| ^^^^^^^^^^^^^^^^^^^

View file

@ -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 | <T as Trait>::Assoc::func();
| ^^^^^^^^^^^^^^^^^^^

View file

@ -7,8 +7,7 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Trait {
const trait Trait {
type Assoc: [const] Trait;
fn func();
}

View file

@ -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`

View file

@ -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`

View file

@ -3,8 +3,7 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Add<Rhs = Self> {
const trait Add<Rhs = Self> {
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;
}

View file

@ -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() {}

View file

@ -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

View file

@ -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);
}

View file

@ -35,8 +35,7 @@ impl Copy for u8 {}
impl<T: PointeeSized> Copy for &T {}
#[lang = "add"]
#[const_trait]
pub trait Add<Rhs = Self> {
pub const trait Add<Rhs = Self> {
type Output;
fn add(self, rhs: Rhs) -> Self::Output;
@ -58,8 +57,7 @@ const fn bar() {
}
#[lang = "Try"]
#[const_trait]
pub trait Try: FromResidual<Self::Residual> {
pub const trait Try: FromResidual<Self::Residual> {
type Output;
type Residual;
@ -70,8 +68,7 @@ pub trait Try: FromResidual<Self::Residual> {
fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
}
#[const_trait]
pub trait FromResidual<R = <Self as Try>::Residual> {
pub const trait FromResidual<R = <Self as Try>::Residual> {
#[lang = "from_residual"]
fn from_residual(residual: R) -> Self;
}
@ -83,24 +80,21 @@ enum ControlFlow<B, C = ()> {
Break(B),
}
#[const_trait]
#[lang = "fn"]
#[rustc_paren_sugar]
pub trait Fn<Args: Tuple>: [const] FnMut<Args> {
pub const trait Fn<Args: Tuple>: [const] FnMut<Args> {
extern "rust-call" fn call(&self, args: Args) -> Self::Output;
}
#[const_trait]
#[lang = "fn_mut"]
#[rustc_paren_sugar]
pub trait FnMut<Args: Tuple>: [const] FnOnce<Args> {
pub const trait FnMut<Args: Tuple>: [const] FnOnce<Args> {
extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
}
#[const_trait]
#[lang = "fn_once"]
#[rustc_paren_sugar]
pub trait FnOnce<Args: Tuple> {
pub const trait FnOnce<Args: Tuple> {
#[lang = "fn_once_output"]
type Output;
@ -128,20 +122,17 @@ impl<T: Deref + MetaSized> 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<O> {
pub const trait Residual<O> {
type TryType: [const] Try<Output = O, Residual = Self> + Try<Output = O, Residual = Self>;
}
@ -168,15 +159,13 @@ const fn panic_display() {
fn panic_fmt() {}
#[lang = "index"]
#[const_trait]
pub trait Index<Idx: PointeeSized> {
pub const trait Index<Idx: PointeeSized> {
type Output: MetaSized;
fn index(&self, index: Idx) -> &Self::Output;
}
#[const_trait]
pub unsafe trait SliceIndex<T: PointeeSized> {
pub const unsafe trait SliceIndex<T: PointeeSized> {
type Output: MetaSized;
fn index(self, slice: &T) -> &Self::Output;
}
@ -214,8 +203,7 @@ pub trait CoerceUnsized<T: PointeeSized> {}
impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, 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<T>: Sized {
pub const trait Into<T>: Sized {
fn into(self) -> T;
}
#[const_trait]
pub trait From<T>: Sized {
pub const trait From<T>: Sized {
fn from(value: T) -> Self;
}
@ -313,8 +299,7 @@ fn from_str(s: &str) -> Result<bool, ()> {
}
#[lang = "eq"]
#[const_trait]
pub trait PartialEq<Rhs: PointeeSized = Self>: PointeeSized {
pub const trait PartialEq<Rhs: PointeeSized = Self>: 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<T: MetaSized> 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

View file

@ -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();
}

View file

@ -4,8 +4,7 @@
#![feature(const_trait_impl, const_closures)]
#![allow(incomplete_features)]
#[const_trait]
trait Bar {
const trait Bar {
fn foo(&self);
}

View file

@ -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())();
| ^^^

View file

@ -1,7 +1,7 @@
//@ compile-flags: -Znext-solver
#![feature(const_trait_impl)]
#[const_trait] trait Foo {
const trait Foo {
fn foo();
}

View file

@ -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;
}

View file

@ -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)
| ^

View file

@ -20,8 +20,7 @@ impl const PartialEq for Int {
}
}
#[const_trait]
pub trait Plus {
pub const trait Plus {
fn plus(self, rhs: Self) -> Self;
}

View file

@ -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;
}

View file

@ -3,8 +3,7 @@
struct S;
#[const_trait]
trait Foo {
const trait Foo {
fn eq(&self, _: &Self) -> bool;
}

View file

@ -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: [const] Foo>(t: &T) -> bool {
| ^^^^^^^^^^^ required by this bound in `equals_self`

View file

@ -12,8 +12,7 @@ impl<const N: usize> Foo<N> {
}
}
#[const_trait]
trait Add42 {
const trait Add42 {
fn add(a: usize) -> usize;
}

View file

@ -11,19 +11,19 @@ LL | fn add<A: [const] Add42>(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<A: [const] Add42, const N: usize>(_: Foo<N>) -> 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<A: [const] Add42, const N: usize>(_: Foo<N>) -> 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<A: [const] Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> {
| ^

View file

@ -3,8 +3,7 @@
//@ compile-flags: -Znext-solver
#![feature(const_trait_impl)]
#[const_trait]
trait Main {
const trait Main {
fn compute<T: [const] Aux>() -> u32;
}
@ -14,8 +13,7 @@ impl const Main for () {
}
}
#[const_trait]
trait Aux {
const trait Aux {
fn generate() -> u32;
}

View file

@ -1,8 +1,7 @@
#![feature(const_trait_impl, impl_trait_in_bindings)]
struct S;
#[const_trait]
trait Trait<const N: u32> {}
const trait Trait<const N: u32> {}
impl const Trait<0> for () {}

View file

@ -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: [const] Trait<0>>(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: [const] Trait<0>>(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<U: [const] Trait<0>>() {}

View file

@ -2,8 +2,7 @@
//@ compile-flags: -Znext-solver
#![feature(const_trait_impl)]
#[const_trait]
trait Foo {
const trait Foo {
fn foo(&self) {}
}

View file

@ -1,7 +1,6 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Trait {}
const trait Trait {}
// Regression test for issue #90052.
fn non_const_function<T: [const] Trait>() {} //~ ERROR `[const]` is not allowed

View file

@ -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<T: [const] Trait>() {}
| ^^^^^^^
|
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<T: [const] Trait>() {}
| ^^^^^^^^^^^^^^^^^^
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<T: [const] Trait> { 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<T: [const] Trait> { 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: [const] Trait>(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: [const] Trait>(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<T: [const] Trait>;
| ^^^^^^^
|
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<T: [const] Trait>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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<T: [const] Trait> { 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<T: [const] Trait> { 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<T: [const] Trait> { 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<T: [const] Trait> { 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: [const] Trait> = T;
| ^^^^^^^
@ -79,7 +79,7 @@ LL | type Type<T: [const] Trait> = 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<T: [const] Trait>: () = ();
| ^^^^^^^
@ -87,43 +87,43 @@ LL | const CONSTANT<T: [const] Trait>: () = ();
= 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<T: [const] Trait>: [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<T: [const] Trait>: [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<T: [const] Trait>: [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<T: [const] Trait>: [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<T: [const] Trait>();
| ^^^^^^^
|
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<T: [const] Trait>();
| ^^^^^^^^^^^^^^^^^^
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<T: [const] Trait>: ();
| ^^^^^^^
@ -131,31 +131,31 @@ LL | const CONSTANT<T: [const] Trait>: ();
= 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<T: [const] Trait> = ();
| ^^^^^^^
|
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<T: [const] Trait> = ();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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<T: [const] Trait>() {}
| ^^^^^^^
|
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<T: [const] Trait>() {}
| ^^^^^^^^^^^^^^^^^^
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<T: [const] Trait>: () = ();
| ^^^^^^^
@ -163,31 +163,31 @@ LL | const CONSTANT<T: [const] Trait>: () = ();
= 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<T: [const] Trait> = ();
| ^^^^^^^
|
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<T: [const] Trait> = ();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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<T: [const] Trait>() {}
| ^^^^^^^
|
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<T: [const] Trait>() {}
| ^^^^^^^^^^^^^^^^^^
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<T: [const] Trait>: () = ();
| ^^^^^^^
@ -195,55 +195,55 @@ LL | const CONSTANT<T: [const] Trait>: () = ();
= 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<T: [const] Trait> 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<T: [const] Trait> 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<T: [const] Trait> Struct<T> {}
| ^^^^^^^
|
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<T: [const] Trait> Struct<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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<T: [const] Trait>: () = ();
| ^^^^^^^^^^^^^^^^^^
@ -253,7 +253,7 @@ LL | const CONSTANT<T: [const] Trait>: () = ();
= 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<T: [const] Trait>: ();
| ^^^^^^^^^^^^^^^^^^
@ -263,7 +263,7 @@ LL | const CONSTANT<T: [const] Trait>: ();
= 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<T: [const] Trait>: () = ();
| ^^^^^^^^^^^^^^^^^^
@ -273,7 +273,7 @@ LL | const CONSTANT<T: [const] Trait>: () = ();
= 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<T: [const] Trait>: () = ();
| ^^^^^^^^^^^^^^^^^^
@ -283,7 +283,7 @@ LL | const CONSTANT<T: [const] Trait>: () = ();
= 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<T: [const] Trait>;
| ^ unused type parameter
@ -291,7 +291,7 @@ LL | struct UnitStruct<T: [const] Trait>;
= 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<T: [const] Trait> { field: T }
| ^^^^^^^^
@ -303,19 +303,19 @@ LL | union Union<T: [const] Trait> { field: std::mem::ManuallyDrop<T> }
| +++++++++++++++++++++++ +
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<T: [const] Trait> = ();
| ^^
|
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<T: [const] Trait>: [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<T: [const] Trait> = ();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -2,8 +2,7 @@
//@ compile-flags: -Znext-solver
#![feature(const_trait_impl)]
#[const_trait]
trait Trait {
const trait Trait {
type Assoc<T: [const] Bound>;
}
@ -11,7 +10,6 @@ impl const Trait for () {
type Assoc<T: [const] Bound> = T;
}
#[const_trait]
trait Bound {}
const trait Bound {}
fn main() {}

View file

@ -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;
}

View file

@ -3,7 +3,7 @@
#![feature(const_trait_impl)]
#[const_trait] trait Foo {
const trait Foo {
fn foo();
}

View file

@ -2,8 +2,7 @@
#![feature(const_trait_impl)]
#[const_trait]
trait MyTrait {
const trait MyTrait {
fn do_something(&self);
}

View file

@ -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 {
| ^^^

View file

@ -6,8 +6,8 @@ LL | const fn perform<T: [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-bounds-non-const-trait.rs:6:21
@ -18,8 +18,8 @@ LL | const fn perform<T: [const] NonConst>() {}
= 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<T: 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 3 previous errors

View file

@ -3,8 +3,7 @@
#![feature(const_trait_impl)]
struct S;
#[const_trait]
trait T {
const trait T {
fn foo();
}

View file

@ -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() {}
| ^^^^^^^^^^^^^^

View file

@ -2,8 +2,7 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Tr {
const trait Tr {
fn a(self) -> i32;
}

View file

@ -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);
| ^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -3,8 +3,7 @@
//@[next] compile-flags: -Znext-solver
#![feature(const_trait_impl)]
#[const_trait]
trait Tr {
const trait Tr {
fn a(self) -> i32;
}

View file

@ -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>(T);
impl<T> const Foo for A<T> where A<T>: [const] Bar {

View file

@ -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) {

View file

@ -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();
| ^

View file

@ -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::<ConstDropImplWithBounds<NonTrivialDrop>>(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: required for `ConstDropImplWithBounds<NonTrivialDrop>` to implement `const Drop`
--> $DIR/const-drop-fail-2.rs:25:26
--> $DIR/const-drop-fail-2.rs:24:26
|
LL | impl<T: [const] A> const Drop for ConstDropImplWithBounds<T> {
| --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| 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: [const] Destruct>(_: T) {}
| ^^^^^^^^^^^^^^^^ required by this bound in `check`

View file

@ -13,8 +13,7 @@ impl Drop for NonTrivialDrop {
}
}
#[const_trait]
trait A { fn a() { } }
const trait A { fn a() { } }
impl A for NonTrivialDrop {}

View file

@ -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::<ConstDropImplWithBounds<NonTrivialDrop>>(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: required for `ConstDropImplWithBounds<NonTrivialDrop>` to implement `const Drop`
--> $DIR/const-drop-fail-2.rs:25:26
--> $DIR/const-drop-fail-2.rs:24:26
|
LL | impl<T: [const] A> const Drop for ConstDropImplWithBounds<T> {
| --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| 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: [const] Destruct>(_: T) {}
| ^^^^^^^^^^^^^^^^ required by this bound in `check`

View file

@ -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 () {

View file

@ -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<T: Foo> Bar for T {} //~ ERROR: expected identifier, found keyword

View file

@ -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<T: Foo> Bar for T {}
| ^^^^ expected identifier, found keyword

View file

@ -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

View file

@ -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 {}

View file

@ -3,8 +3,7 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Trait {
const trait Trait {
fn method();
}

View file

@ -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: [const] Foo>(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();
| ^^^^^^

View file

@ -4,8 +4,7 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Foo {
const trait Foo {
fn method(&self);
}

View file

@ -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

View file

@ -10,8 +10,7 @@
#![feature(const_trait_impl, effects)]
//~^ ERROR feature has been removed
#[const_trait]
trait Main {
const trait Main {
fn compute<T: [const] Aux>() -> u32;
}
@ -22,8 +21,7 @@ impl const Main for () {
}
}
#[const_trait]
trait Aux {}
const trait Aux {}
impl const Aux for () {}

View file

@ -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<T: [const] Aux>() -> u32;
| - expected 1 type parameter

View file

@ -5,8 +5,7 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Bar {}
const trait Bar {}
trait Baz: const Bar {}

View file

@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,13 +1,11 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Tr {}
const trait Tr {}
impl Tr for () {}
const fn foo<T>() 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

Some files were not shown because too many files have changed in this diff Show more