Deny more ~const
trait bounds
This commit is contained in:
parent
9ab0749ce3
commit
8ce5d784a6
25 changed files with 444 additions and 134 deletions
|
@ -214,9 +214,12 @@ ast_passes_static_without_body =
|
||||||
.suggestion = provide a definition for the static
|
.suggestion = provide a definition for the static
|
||||||
|
|
||||||
ast_passes_tilde_const_disallowed = `~const` is not allowed here
|
ast_passes_tilde_const_disallowed = `~const` is not allowed here
|
||||||
.trait = trait objects cannot have `~const` trait bounds
|
|
||||||
.closure = closures cannot have `~const` trait bounds
|
.closure = closures cannot have `~const` trait bounds
|
||||||
.function = this function is not `const`, so it cannot have `~const` trait bounds
|
.function = this function is not `const`, so it cannot have `~const` trait bounds
|
||||||
|
.trait = this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
|
||||||
|
.impl = this impl is not `const`, so it cannot have `~const` trait bounds
|
||||||
|
.object = trait objects cannot have `~const` trait bounds
|
||||||
|
.item = this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
ast_passes_trait_fn_const =
|
ast_passes_trait_fn_const =
|
||||||
functions in traits cannot be declared const
|
functions in traits cannot be declared const
|
||||||
|
|
|
@ -40,6 +40,9 @@ enum SelfSemantic {
|
||||||
enum DisallowTildeConstContext<'a> {
|
enum DisallowTildeConstContext<'a> {
|
||||||
TraitObject,
|
TraitObject,
|
||||||
Fn(FnKind<'a>),
|
Fn(FnKind<'a>),
|
||||||
|
Trait(Span),
|
||||||
|
Impl(Span),
|
||||||
|
Item,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AstValidator<'a> {
|
struct AstValidator<'a> {
|
||||||
|
@ -110,18 +113,6 @@ impl<'a> AstValidator<'a> {
|
||||||
self.disallow_tilde_const = old;
|
self.disallow_tilde_const = old;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_tilde_const_allowed(&mut self, f: impl FnOnce(&mut Self)) {
|
|
||||||
self.with_tilde_const(None, f)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn with_banned_tilde_const(
|
|
||||||
&mut self,
|
|
||||||
ctx: DisallowTildeConstContext<'a>,
|
|
||||||
f: impl FnOnce(&mut Self),
|
|
||||||
) {
|
|
||||||
self.with_tilde_const(Some(ctx), f)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_type_alias_where_clause_location(
|
fn check_type_alias_where_clause_location(
|
||||||
&mut self,
|
&mut self,
|
||||||
ty_alias: &TyAlias,
|
ty_alias: &TyAlias,
|
||||||
|
@ -173,7 +164,7 @@ impl<'a> AstValidator<'a> {
|
||||||
self.with_impl_trait(Some(t.span), |this| visit::walk_ty(this, t))
|
self.with_impl_trait(Some(t.span), |this| visit::walk_ty(this, t))
|
||||||
}
|
}
|
||||||
TyKind::TraitObject(..) => self
|
TyKind::TraitObject(..) => self
|
||||||
.with_banned_tilde_const(DisallowTildeConstContext::TraitObject, |this| {
|
.with_tilde_const(Some(DisallowTildeConstContext::TraitObject), |this| {
|
||||||
visit::walk_ty(this, t)
|
visit::walk_ty(this, t)
|
||||||
}),
|
}),
|
||||||
TyKind::Path(qself, path) => {
|
TyKind::Path(qself, path) => {
|
||||||
|
@ -822,11 +813,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
|
|
||||||
this.visit_vis(&item.vis);
|
this.visit_vis(&item.vis);
|
||||||
this.visit_ident(item.ident);
|
this.visit_ident(item.ident);
|
||||||
if let Const::Yes(_) = constness {
|
let disallowed = matches!(constness, Const::No)
|
||||||
this.with_tilde_const_allowed(|this| this.visit_generics(generics));
|
.then(|| DisallowTildeConstContext::Impl(item.span));
|
||||||
} else {
|
this.with_tilde_const(disallowed, |this| this.visit_generics(generics));
|
||||||
this.visit_generics(generics);
|
|
||||||
}
|
|
||||||
this.visit_trait_ref(t);
|
this.visit_trait_ref(t);
|
||||||
this.visit_ty(self_ty);
|
this.visit_ty(self_ty);
|
||||||
|
|
||||||
|
@ -840,10 +829,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
polarity,
|
polarity,
|
||||||
defaultness,
|
defaultness,
|
||||||
constness,
|
constness,
|
||||||
generics: _,
|
generics,
|
||||||
of_trait: None,
|
of_trait: None,
|
||||||
self_ty,
|
self_ty,
|
||||||
items: _,
|
items,
|
||||||
}) => {
|
}) => {
|
||||||
let error =
|
let error =
|
||||||
|annotation_span, annotation, only_trait: bool| errors::InherentImplCannot {
|
|annotation_span, annotation, only_trait: bool| errors::InherentImplCannot {
|
||||||
|
@ -875,6 +864,14 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
if let &Const::Yes(span) = constness {
|
if let &Const::Yes(span) = constness {
|
||||||
self.err_handler().emit_err(error(span, "`const`", true));
|
self.err_handler().emit_err(error(span, "`const`", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.visit_vis(&item.vis);
|
||||||
|
self.visit_ident(item.ident);
|
||||||
|
self.with_tilde_const(None, |this| this.visit_generics(generics));
|
||||||
|
self.visit_ty(self_ty);
|
||||||
|
walk_list!(self, visit_assoc_item, items, AssocCtxt::Impl);
|
||||||
|
walk_list!(self, visit_attribute, &item.attrs);
|
||||||
|
return; // Avoid visiting again.
|
||||||
}
|
}
|
||||||
ItemKind::Fn(box Fn { defaultness, sig, generics, body }) => {
|
ItemKind::Fn(box Fn { defaultness, sig, generics, body }) => {
|
||||||
self.check_defaultness(item.span, *defaultness);
|
self.check_defaultness(item.span, *defaultness);
|
||||||
|
@ -955,8 +952,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
// context for the supertraits.
|
// context for the supertraits.
|
||||||
this.visit_vis(&item.vis);
|
this.visit_vis(&item.vis);
|
||||||
this.visit_ident(item.ident);
|
this.visit_ident(item.ident);
|
||||||
|
let disallowed =
|
||||||
|
(!is_const_trait).then(|| DisallowTildeConstContext::Trait(item.span));
|
||||||
|
this.with_tilde_const(disallowed, |this| {
|
||||||
this.visit_generics(generics);
|
this.visit_generics(generics);
|
||||||
this.with_tilde_const_allowed(|this| {
|
|
||||||
walk_list!(this, visit_param_bound, bounds, BoundKind::SuperTraits)
|
walk_list!(this, visit_param_bound, bounds, BoundKind::SuperTraits)
|
||||||
});
|
});
|
||||||
walk_list!(this, visit_assoc_item, items, AssocCtxt::Trait);
|
walk_list!(this, visit_assoc_item, items, AssocCtxt::Trait);
|
||||||
|
@ -976,16 +975,11 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ItemKind::Struct(vdata, generics) => match vdata {
|
ItemKind::Struct(vdata, generics) => match vdata {
|
||||||
// Duplicating the `Visitor` logic allows catching all cases
|
|
||||||
// of `Anonymous(Struct, Union)` outside of a field struct or union.
|
|
||||||
//
|
|
||||||
// Inside `visit_ty` the validator catches every `Anonymous(Struct, Union)` it
|
|
||||||
// encounters, and only on `ItemKind::Struct` and `ItemKind::Union`
|
|
||||||
// it uses `visit_ty_common`, which doesn't contain that specific check.
|
|
||||||
VariantData::Struct(fields, ..) => {
|
VariantData::Struct(fields, ..) => {
|
||||||
self.visit_vis(&item.vis);
|
self.visit_vis(&item.vis);
|
||||||
self.visit_ident(item.ident);
|
self.visit_ident(item.ident);
|
||||||
self.visit_generics(generics);
|
self.visit_generics(generics);
|
||||||
|
// Permit `Anon{Struct,Union}` as field type.
|
||||||
walk_list!(self, visit_struct_field_def, fields);
|
walk_list!(self, visit_struct_field_def, fields);
|
||||||
walk_list!(self, visit_attribute, &item.attrs);
|
walk_list!(self, visit_attribute, &item.attrs);
|
||||||
return;
|
return;
|
||||||
|
@ -1001,6 +995,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
self.visit_vis(&item.vis);
|
self.visit_vis(&item.vis);
|
||||||
self.visit_ident(item.ident);
|
self.visit_ident(item.ident);
|
||||||
self.visit_generics(generics);
|
self.visit_generics(generics);
|
||||||
|
// Permit `Anon{Struct,Union}` as field type.
|
||||||
walk_list!(self, visit_struct_field_def, fields);
|
walk_list!(self, visit_struct_field_def, fields);
|
||||||
walk_list!(self, visit_attribute, &item.attrs);
|
walk_list!(self, visit_attribute, &item.attrs);
|
||||||
return;
|
return;
|
||||||
|
@ -1189,15 +1184,18 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
if let Some(reason) = &self.disallow_tilde_const =>
|
if let Some(reason) = &self.disallow_tilde_const =>
|
||||||
{
|
{
|
||||||
let reason = match reason {
|
let reason = match reason {
|
||||||
DisallowTildeConstContext::TraitObject => {
|
|
||||||
errors::TildeConstReason::TraitObject
|
|
||||||
}
|
|
||||||
DisallowTildeConstContext::Fn(FnKind::Closure(..)) => {
|
DisallowTildeConstContext::Fn(FnKind::Closure(..)) => {
|
||||||
errors::TildeConstReason::Closure
|
errors::TildeConstReason::Closure
|
||||||
}
|
}
|
||||||
DisallowTildeConstContext::Fn(FnKind::Fn(_, ident, ..)) => {
|
DisallowTildeConstContext::Fn(FnKind::Fn(_, ident, ..)) => {
|
||||||
errors::TildeConstReason::Function { ident: ident.span }
|
errors::TildeConstReason::Function { ident: ident.span }
|
||||||
}
|
}
|
||||||
|
&DisallowTildeConstContext::Trait(span) => errors::TildeConstReason::Trait { span },
|
||||||
|
&DisallowTildeConstContext::Impl(span) => errors::TildeConstReason::Impl { span },
|
||||||
|
DisallowTildeConstContext::TraitObject => {
|
||||||
|
errors::TildeConstReason::TraitObject
|
||||||
|
}
|
||||||
|
DisallowTildeConstContext::Item => errors::TildeConstReason::Item,
|
||||||
};
|
};
|
||||||
self.err_handler()
|
self.err_handler()
|
||||||
.emit_err(errors::TildeConstDisallowed { span: bound.span(), reason });
|
.emit_err(errors::TildeConstDisallowed { span: bound.span(), reason });
|
||||||
|
@ -1305,7 +1303,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
|| matches!(fk.ctxt(), Some(FnCtxt::Assoc(_)) if self.in_const_trait_or_impl);
|
|| matches!(fk.ctxt(), Some(FnCtxt::Assoc(_)) if self.in_const_trait_or_impl);
|
||||||
|
|
||||||
let disallowed = (!tilde_const_allowed).then(|| DisallowTildeConstContext::Fn(fk));
|
let disallowed = (!tilde_const_allowed).then(|| DisallowTildeConstContext::Fn(fk));
|
||||||
|
|
||||||
self.with_tilde_const(disallowed, |this| visit::walk_fn(this, fk));
|
self.with_tilde_const(disallowed, |this| visit::walk_fn(this, fk));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1374,18 +1371,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
match &item.kind {
|
match &item.kind {
|
||||||
AssocItemKind::Type(box TyAlias { generics, bounds, ty, .. })
|
|
||||||
if ctxt == AssocCtxt::Trait =>
|
|
||||||
{
|
|
||||||
self.visit_vis(&item.vis);
|
|
||||||
self.visit_ident(item.ident);
|
|
||||||
walk_list!(self, visit_attribute, &item.attrs);
|
|
||||||
self.with_tilde_const_allowed(|this| {
|
|
||||||
this.visit_generics(generics);
|
|
||||||
walk_list!(this, visit_param_bound, bounds, BoundKind::Bound);
|
|
||||||
});
|
|
||||||
walk_list!(self, visit_ty, ty);
|
|
||||||
}
|
|
||||||
AssocItemKind::Fn(box Fn { sig, generics, body, .. })
|
AssocItemKind::Fn(box Fn { sig, generics, body, .. })
|
||||||
if self.in_const_trait_or_impl
|
if self.in_const_trait_or_impl
|
||||||
|| ctxt == AssocCtxt::Trait
|
|| ctxt == AssocCtxt::Trait
|
||||||
|
@ -1537,7 +1522,7 @@ pub fn check_crate(
|
||||||
in_const_trait_or_impl: false,
|
in_const_trait_or_impl: false,
|
||||||
has_proc_macro_decls: false,
|
has_proc_macro_decls: false,
|
||||||
outer_impl_trait: None,
|
outer_impl_trait: None,
|
||||||
disallow_tilde_const: None,
|
disallow_tilde_const: Some(DisallowTildeConstContext::Item),
|
||||||
is_impl_trait_banned: false,
|
is_impl_trait_banned: false,
|
||||||
lint_buffer: lints,
|
lint_buffer: lints,
|
||||||
};
|
};
|
||||||
|
|
|
@ -551,8 +551,6 @@ pub struct TildeConstDisallowed {
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
pub enum TildeConstReason {
|
pub enum TildeConstReason {
|
||||||
#[note(ast_passes_trait)]
|
|
||||||
TraitObject,
|
|
||||||
#[note(ast_passes_closure)]
|
#[note(ast_passes_closure)]
|
||||||
Closure,
|
Closure,
|
||||||
#[note(ast_passes_function)]
|
#[note(ast_passes_function)]
|
||||||
|
@ -560,6 +558,20 @@ pub enum TildeConstReason {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
ident: Span,
|
ident: Span,
|
||||||
},
|
},
|
||||||
|
#[note(ast_passes_trait)]
|
||||||
|
Trait {
|
||||||
|
#[primary_span]
|
||||||
|
span: Span,
|
||||||
|
},
|
||||||
|
#[note(ast_passes_impl)]
|
||||||
|
Impl {
|
||||||
|
#[primary_span]
|
||||||
|
span: Span,
|
||||||
|
},
|
||||||
|
#[note(ast_passes_object)]
|
||||||
|
TraitObject,
|
||||||
|
#[note(ast_passes_item)]
|
||||||
|
Item,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
// FIXME(generic_const_items): Interpret `~const` as always-const.
|
// FIXME(generic_const_items, effects): Introduce `const` bounds to make this work.
|
||||||
const CREATE<T: ~const Create>: T = T::create();
|
const CREATE<T: Create>: T = T::create();
|
||||||
|
|
||||||
pub const K0: i32 = CREATE::<i32>;
|
pub const K0: i32 = CREATE::<i32>;
|
||||||
pub const K1: i32 = CREATE; // arg inferred
|
pub const K1: i32 = CREATE; // arg inferred
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
error[E0015]: cannot call non-const fn `<T as Create>::create` in constants
|
error[E0015]: cannot call non-const fn `<T as Create>::create` in constants
|
||||||
--> $DIR/const-trait-impl.rs:11:37
|
--> $DIR/const-trait-impl.rs:11:30
|
||||||
|
|
|
|
||||||
LL | const CREATE<T: ~const Create>: T = T::create();
|
LL | const CREATE<T: Create>: T = T::create();
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/assoc-type-const-bound-usage.rs:7:17
|
||||||
|
|
|
||||||
|
LL | type Assoc: ~const Foo;
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/assoc-type-const-bound-usage.rs:12:5
|
--> $DIR/assoc-type-const-bound-usage.rs:12:5
|
||||||
|
|
|
|
||||||
|
@ -7,6 +15,6 @@ LL | <T as Foo>::Assoc::foo();
|
||||||
= note: expected constant `host`
|
= note: expected constant `host`
|
||||||
found constant `true`
|
found constant `true`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0308`.
|
For more information about this error, try `rustc --explain E0308`.
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/assoc-type.rs:17:15
|
||||||
|
|
|
||||||
|
LL | type Bar: ~const std::ops::Add;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
error: ~const can only be applied to `#[const_trait]` traits
|
error: ~const can only be applied to `#[const_trait]` traits
|
||||||
--> $DIR/assoc-type.rs:17:22
|
--> $DIR/assoc-type.rs:17:22
|
||||||
|
|
|
|
||||||
LL | type Bar: ~const std::ops::Add;
|
LL | type Bar: ~const std::ops::Add;
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#![feature(const_trait_impl, effects)]
|
#![feature(const_trait_impl)]
|
||||||
|
|
||||||
#[const_trait]
|
#[const_trait]
|
||||||
trait MyTrait {
|
trait MyTrait {
|
|
@ -1,19 +1,10 @@
|
||||||
error[E0493]: destructor of `T` cannot be evaluated at compile-time
|
error: `~const` is not allowed here
|
||||||
--> $DIR/const-drop.rs:19:32
|
--> $DIR/const-drop.rs:67:38
|
||||||
|
|
|
|
||||||
LL | const fn a<T: ~const Destruct>(_: T) {}
|
LL | pub struct ConstDropWithBound<T: ~const SomeTrait>(pub core::marker::PhantomData<T>);
|
||||||
| ^ - value is dropped here
|
| ^^^^^^^^^^^^^^^^
|
||||||
| |
|
|
||||||
| the destructor for this type cannot be evaluated in constant functions
|
|
||||||
|
|
||||||
error[E0493]: destructor of `S<'_>` cannot be evaluated at compile-time
|
|
||||||
--> $DIR/const-drop.rs:24:13
|
|
||||||
|
|
|
|
||||||
LL | let _ = S(&mut c);
|
= note: this item cannot have `~const` trait bounds
|
||||||
| ^^^^^^^^^- value is dropped here
|
|
||||||
| |
|
|
||||||
| the destructor for this type cannot be evaluated in constant functions
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0493`.
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ mod t {
|
||||||
fn foo() {}
|
fn foo() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME(effects): This should be a `const` bound instead of a `~const` one.
|
||||||
pub struct ConstDropWithBound<T: ~const SomeTrait>(pub core::marker::PhantomData<T>);
|
pub struct ConstDropWithBound<T: ~const SomeTrait>(pub core::marker::PhantomData<T>);
|
||||||
|
|
||||||
impl<T: ~const SomeTrait> const Drop for ConstDropWithBound<T> {
|
impl<T: ~const SomeTrait> const Drop for ConstDropWithBound<T> {
|
||||||
|
|
|
@ -1,19 +1,10 @@
|
||||||
error[E0493]: destructor of `T` cannot be evaluated at compile-time
|
error: `~const` is not allowed here
|
||||||
--> $DIR/const-drop.rs:19:32
|
--> $DIR/const-drop.rs:67:38
|
||||||
|
|
|
|
||||||
LL | const fn a<T: ~const Destruct>(_: T) {}
|
LL | pub struct ConstDropWithBound<T: ~const SomeTrait>(pub core::marker::PhantomData<T>);
|
||||||
| ^ - value is dropped here
|
| ^^^^^^^^^^^^^^^^
|
||||||
| |
|
|
||||||
| the destructor for this type cannot be evaluated in constant functions
|
|
||||||
|
|
||||||
error[E0493]: destructor of `S<'_>` cannot be evaluated at compile-time
|
|
||||||
--> $DIR/const-drop.rs:24:13
|
|
||||||
|
|
|
|
||||||
LL | let _ = S(&mut c);
|
= note: this item cannot have `~const` trait bounds
|
||||||
| ^^^^^^^^^- value is dropped here
|
|
||||||
| |
|
|
||||||
| the destructor for this type cannot be evaluated in constant functions
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0493`.
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
#![feature(const_trait_impl)]
|
|
||||||
|
|
||||||
#[const_trait]
|
|
||||||
trait Bar {}
|
|
||||||
|
|
||||||
fn foo<T>() where T: ~const Bar {}
|
|
||||||
//~^ ERROR `~const` is not allowed
|
|
||||||
|
|
||||||
fn main() {}
|
|
|
@ -1,14 +0,0 @@
|
||||||
error: `~const` is not allowed here
|
|
||||||
--> $DIR/issue-90052.rs:6:22
|
|
||||||
|
|
|
||||||
LL | fn foo<T>() where T: ~const Bar {}
|
|
||||||
| ^^^^^^^^^^
|
|
||||||
|
|
|
||||||
note: this function is not `const`, so it cannot have `~const` trait bounds
|
|
||||||
--> $DIR/issue-90052.rs:6:4
|
|
||||||
|
|
|
||||||
LL | fn foo<T>() where T: ~const Bar {}
|
|
||||||
| ^^^
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
|
@ -18,11 +18,7 @@ trait Bar {
|
||||||
fn bar();
|
fn bar();
|
||||||
}
|
}
|
||||||
|
|
||||||
// bgr360: I was only able to exercise the code path that raises the
|
impl<T> const Bar for T
|
||||||
// "missing ~const qualifier" error by making this base impl non-const, even
|
|
||||||
// though that doesn't really make sense to do. As seen below, if the base impl
|
|
||||||
// is made const, rustc fails earlier with an overlapping impl failure.
|
|
||||||
impl<T> Bar for T
|
|
||||||
where
|
where
|
||||||
T: ~const Foo,
|
T: ~const Foo,
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/super-traits-fail-2.rs:11:12
|
||||||
|
|
|
||||||
|
LL | trait Bar: ~const Foo {}
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
|
||||||
|
--> $DIR/super-traits-fail-2.rs:11:1
|
||||||
|
|
|
||||||
|
LL | trait Bar: ~const Foo {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: ~const can only be applied to `#[const_trait]` traits
|
error: ~const can only be applied to `#[const_trait]` traits
|
||||||
--> $DIR/super-traits-fail-2.rs:11:19
|
--> $DIR/super-traits-fail-2.rs:11:19
|
||||||
|
|
|
|
||||||
|
@ -12,5 +24,5 @@ LL | trait Bar: ~const Foo {}
|
||||||
|
|
|
|
||||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions
|
error: `~const` is not allowed here
|
||||||
--> $DIR/super-traits-fail-2.rs:16:7
|
--> $DIR/super-traits-fail-2.rs:11:12
|
||||||
|
|
|
|
||||||
LL | x.a();
|
LL | trait Bar: ~const Foo {}
|
||||||
| ^^^
|
| ^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
|
||||||
|
--> $DIR/super-traits-fail-2.rs:11:1
|
||||||
|
|
|
||||||
|
LL | trait Bar: ~const Foo {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0015`.
|
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/super-traits-fail-3.rs:13:12
|
||||||
|
|
|
||||||
|
LL | trait Bar: ~const Foo {}
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
|
||||||
|
--> $DIR/super-traits-fail-3.rs:13:1
|
||||||
|
|
|
||||||
|
LL | trait Bar: ~const Foo {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: ~const can only be applied to `#[const_trait]` traits
|
error: ~const can only be applied to `#[const_trait]` traits
|
||||||
--> $DIR/super-traits-fail-3.rs:13:19
|
--> $DIR/super-traits-fail-3.rs:13:19
|
||||||
|
|
|
|
||||||
|
@ -13,10 +25,10 @@ LL | trait Bar: ~const Foo {}
|
||||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||||
|
|
||||||
error: ~const can only be applied to `#[const_trait]` traits
|
error: ~const can only be applied to `#[const_trait]` traits
|
||||||
--> $DIR/super-traits-fail-3.rs:17:24
|
--> $DIR/super-traits-fail-3.rs:18:24
|
||||||
|
|
|
|
||||||
LL | const fn foo<T: ~const Bar>(x: &T) {
|
LL | const fn foo<T: ~const Bar>(x: &T) {
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ trait Foo {
|
||||||
trait Bar: ~const Foo {}
|
trait Bar: ~const Foo {}
|
||||||
//[ny,nn]~^ ERROR: ~const can only be applied to `#[const_trait]`
|
//[ny,nn]~^ ERROR: ~const can only be applied to `#[const_trait]`
|
||||||
//[ny,nn]~| ERROR: ~const can only be applied to `#[const_trait]`
|
//[ny,nn]~| ERROR: ~const can only be applied to `#[const_trait]`
|
||||||
|
//[yn,nn]~^^^ ERROR: `~const` is not allowed here
|
||||||
|
|
||||||
const fn foo<T: ~const Bar>(x: &T) {
|
const fn foo<T: ~const Bar>(x: &T) {
|
||||||
//[yn,nn]~^ ERROR: ~const can only be applied to `#[const_trait]`
|
//[yn,nn]~^ ERROR: ~const can only be applied to `#[const_trait]`
|
||||||
|
|
|
@ -1,8 +1,20 @@
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/super-traits-fail-3.rs:13:12
|
||||||
|
|
|
||||||
|
LL | trait Bar: ~const Foo {}
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
|
||||||
|
--> $DIR/super-traits-fail-3.rs:13:1
|
||||||
|
|
|
||||||
|
LL | trait Bar: ~const Foo {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: ~const can only be applied to `#[const_trait]` traits
|
error: ~const can only be applied to `#[const_trait]` traits
|
||||||
--> $DIR/super-traits-fail-3.rs:17:24
|
--> $DIR/super-traits-fail-3.rs:18:24
|
||||||
|
|
|
|
||||||
LL | const fn foo<T: ~const Bar>(x: &T) {
|
LL | const fn foo<T: ~const Bar>(x: &T) {
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions
|
error[E0015]: cannot call non-const fn `<T as Foo>::a` in constant functions
|
||||||
--> $DIR/super-traits-fail-3.rs:19:7
|
--> $DIR/super-traits-fail-3.rs:20:7
|
||||||
|
|
|
|
||||||
LL | x.a();
|
LL | x.a();
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
|
@ -1,7 +1,55 @@
|
||||||
#![feature(const_trait_impl)]
|
#![feature(const_trait_impl)]
|
||||||
#![feature(associated_type_bounds)]
|
|
||||||
|
|
||||||
struct TildeQuestion<T: ~const ?Sized>(std::marker::PhantomData<T>);
|
#[const_trait]
|
||||||
//~^ ERROR `~const` and `?` are mutually exclusive
|
trait Trait {}
|
||||||
|
|
||||||
|
// Regression test for issue #90052.
|
||||||
|
fn non_const_function<T: ~const Trait>() {} //~ ERROR `~const` is not allowed
|
||||||
|
|
||||||
|
struct Struct<T: ~const Trait> { field: T } //~ ERROR `~const` is not allowed here
|
||||||
|
struct TupleStruct<T: ~const Trait>(T); //~ ERROR `~const` is not allowed here
|
||||||
|
struct UnitStruct<T: ~const Trait>; //~ ERROR `~const` is not allowed here
|
||||||
|
|
||||||
|
enum Enum<T: ~const Trait> { Variant(T) } //~ ERROR `~const` is not allowed here
|
||||||
|
|
||||||
|
union Union<T: ~const Trait> { field: T } //~ ERROR `~const` is not allowed here
|
||||||
|
|
||||||
|
type Type<T: ~const Trait> = T; //~ ERROR `~const` is not allowed here
|
||||||
|
|
||||||
|
const CONSTANT<T: ~const Trait>: () = (); //~ ERROR `~const` is not allowed here
|
||||||
|
//~^ ERROR generic const items are experimental
|
||||||
|
|
||||||
|
trait NonConstTrait {
|
||||||
|
type Type<T: ~const Trait>: ~const Trait;
|
||||||
|
//~^ ERROR `~const` is not allowed
|
||||||
|
//~| ERROR `~const` is not allowed
|
||||||
|
fn non_const_function<T: ~const Trait>(); //~ ERROR `~const` is not allowed
|
||||||
|
const CONSTANT<T: ~const Trait>: (); //~ ERROR `~const` is not allowed
|
||||||
|
//~^ ERROR generic const items are experimental
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NonConstTrait for () {
|
||||||
|
type Type<T: ~const Trait> = (); //~ ERROR `~const` is not allowed
|
||||||
|
fn non_const_function<T: ~const Trait>() {} //~ ERROR `~const` is not allowed
|
||||||
|
const CONSTANT<T: ~const Trait>: () = (); //~ ERROR `~const` is not allowed
|
||||||
|
//~^ ERROR generic const items are experimental
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Implementor;
|
||||||
|
|
||||||
|
impl Implementor {
|
||||||
|
type Type<T: ~const Trait> = (); //~ ERROR `~const` is not allowed
|
||||||
|
//~^ ERROR inherent associated types are unstable
|
||||||
|
fn non_const_function<T: ~const Trait>() {} //~ ERROR `~const` is not allowed
|
||||||
|
const CONSTANT<T: ~const Trait>: () = (); //~ ERROR `~const` is not allowed
|
||||||
|
//~^ ERROR generic const items are experimental
|
||||||
|
}
|
||||||
|
|
||||||
|
// non-const traits
|
||||||
|
trait Child0: ~const Trait {} //~ ERROR `~const` is not allowed
|
||||||
|
trait Child1 where Self: ~const Trait {} //~ ERROR `~const` is not allowed
|
||||||
|
|
||||||
|
// non-const impl
|
||||||
|
impl<T: ~const Trait> Trait for T {} //~ ERROR `~const` is not allowed
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,8 +1,244 @@
|
||||||
error: `~const` and `?` are mutually exclusive
|
error: `~const` is not allowed here
|
||||||
--> $DIR/tilde-const-invalid-places.rs:4:25
|
--> $DIR/tilde-const-invalid-places.rs:7:26
|
||||||
|
|
|
|
||||||
LL | struct TildeQuestion<T: ~const ?Sized>(std::marker::PhantomData<T>);
|
LL | fn non_const_function<T: ~const Trait>() {}
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: this function is not `const`, so it cannot have `~const` trait bounds
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:7:4
|
||||||
|
|
|
||||||
|
LL | fn non_const_function<T: ~const Trait>() {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:9:18
|
||||||
|
|
|
||||||
|
LL | struct Struct<T: ~const Trait> { field: T }
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:10:23
|
||||||
|
|
|
||||||
|
LL | struct TupleStruct<T: ~const Trait>(T);
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:11:22
|
||||||
|
|
|
||||||
|
LL | struct UnitStruct<T: ~const Trait>;
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:13:14
|
||||||
|
|
|
||||||
|
LL | enum Enum<T: ~const Trait> { Variant(T) }
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:15:16
|
||||||
|
|
|
||||||
|
LL | union Union<T: ~const Trait> { field: T }
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:17:14
|
||||||
|
|
|
||||||
|
LL | type Type<T: ~const Trait> = T;
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:19:19
|
||||||
|
|
|
||||||
|
LL | const CONSTANT<T: ~const Trait>: () = ();
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:23:18
|
||||||
|
|
|
||||||
|
LL | type Type<T: ~const Trait>: ~const Trait;
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:23:33
|
||||||
|
|
|
||||||
|
LL | type Type<T: ~const Trait>: ~const Trait;
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:26:30
|
||||||
|
|
|
||||||
|
LL | fn non_const_function<T: ~const Trait>();
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: this function is not `const`, so it cannot have `~const` trait bounds
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:26:8
|
||||||
|
|
|
||||||
|
LL | fn non_const_function<T: ~const Trait>();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:27:23
|
||||||
|
|
|
||||||
|
LL | const CONSTANT<T: ~const Trait>: ();
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:32:18
|
||||||
|
|
|
||||||
|
LL | type Type<T: ~const Trait> = ();
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:33:30
|
||||||
|
|
|
||||||
|
LL | fn non_const_function<T: ~const Trait>() {}
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: this function is not `const`, so it cannot have `~const` trait bounds
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:33:8
|
||||||
|
|
|
||||||
|
LL | fn non_const_function<T: ~const Trait>() {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:34:23
|
||||||
|
|
|
||||||
|
LL | const CONSTANT<T: ~const Trait>: () = ();
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:41:18
|
||||||
|
|
|
||||||
|
LL | type Type<T: ~const Trait> = ();
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:43:30
|
||||||
|
|
|
||||||
|
LL | fn non_const_function<T: ~const Trait>() {}
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: this function is not `const`, so it cannot have `~const` trait bounds
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:43:8
|
||||||
|
|
|
||||||
|
LL | fn non_const_function<T: ~const Trait>() {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:44:23
|
||||||
|
|
|
||||||
|
LL | const CONSTANT<T: ~const Trait>: () = ();
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this item cannot have `~const` trait bounds
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:49:15
|
||||||
|
|
|
||||||
|
LL | trait Child0: ~const Trait {}
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:49:1
|
||||||
|
|
|
||||||
|
LL | trait Child0: ~const Trait {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:50:26
|
||||||
|
|
|
||||||
|
LL | trait Child1 where Self: ~const Trait {}
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:50:1
|
||||||
|
|
|
||||||
|
LL | trait Child1 where Self: ~const Trait {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:53:9
|
||||||
|
|
|
||||||
|
LL | impl<T: ~const Trait> Trait for T {}
|
||||||
|
| ^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: this impl is not `const`, so it cannot have `~const` trait bounds
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:53:1
|
||||||
|
|
|
||||||
|
LL | impl<T: ~const Trait> Trait for T {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0658]: generic const items are experimental
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:19:15
|
||||||
|
|
|
||||||
|
LL | const CONSTANT<T: ~const Trait>: () = ();
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information
|
||||||
|
= help: add `#![feature(generic_const_items)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: generic const items are experimental
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:27:19
|
||||||
|
|
|
||||||
|
LL | const CONSTANT<T: ~const Trait>: ();
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information
|
||||||
|
= help: add `#![feature(generic_const_items)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: generic const items are experimental
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:34:19
|
||||||
|
|
|
||||||
|
LL | const CONSTANT<T: ~const Trait>: () = ();
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information
|
||||||
|
= help: add `#![feature(generic_const_items)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: generic const items are experimental
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:44:19
|
||||||
|
|
|
||||||
|
LL | const CONSTANT<T: ~const Trait>: () = ();
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information
|
||||||
|
= help: add `#![feature(generic_const_items)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: inherent associated types are unstable
|
||||||
|
--> $DIR/tilde-const-invalid-places.rs:41:5
|
||||||
|
|
|
||||||
|
LL | type Type<T: ~const Trait> = ();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information
|
||||||
|
= help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error: aborting due to 26 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0658`.
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#![feature(const_trait_impl)]
|
||||||
|
|
||||||
|
const fn tilde_question<T: ~const ?Sized>() {}
|
||||||
|
//~^ ERROR `~const` and `?` are mutually exclusive
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,8 @@
|
||||||
|
error: `~const` and `?` are mutually exclusive
|
||||||
|
--> $DIR/tilde-const-maybe-trait.rs:3:28
|
||||||
|
|
|
||||||
|
LL | const fn tilde_question<T: ~const ?Sized>() {}
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue