Auto merge of #152324 - Keith-Cancel:mgca4, r=BoxyUwU
Update mgca to use `type const` syntax instead of the `#[type_const]` attribute. This PR changes the `#[type_const]` attribute to the `type const` syntax for https://github.com/rust-lang/rust/issues/132980. This will fixes https://github.com/rust-lang/rust/issues/151273 and similar issues, since we need to check `type const` of items before expansion. The move to add a syntax was mentioned here: https://github.com/rust-lang/rust/pull/151289#issuecomment-3765241397 The first part of this PR adds support by allowing `type const <IDENT>: <TYPE> { = <EXPR> };` syntax in `rustc_parse/src/parser/item.rs`. The next part since the AST item does not contain enough information to determine if we have a `type const` was rework `ConstItemRhs` into `ConstItemRhsKind` to store the information since we no longer have the attribute acting as a source of extra data/metadata. The hir node `ConstItemRhsKind` current shape mostly works, except in the case of `TraitItemKind` where it is an option. I initially went about giving `hir::ConstItemRhsKind` a similar form the AST, but it touches a lot more lines of code and files so because of that, the less invasive option was to add a simple boolean flag to `TraitItemKind`. The forth part of this PR includes adding a query I called `is_rhs_type_const` so that we can handle both local and foreign def_ids. The fifth aspect of the PR is adding a `mgca_type_const_syntax` feature gate that is checked before expansion. The standard mgca feature gate is ran after expansion. This feature gate allows for conditional compilation (e.g #[cfg(..)]) of the `type const` syntax in nightly without `min_generic_const_args` being enabled. The last bit is updating all the the tests that used the `#[type_const]` attribute to use the new syntax that failed because of the changes. This is the bulk of touched/edited files in the PR. r? @BoxyUwU @rustbot label +F-associated_const_equality +F-min_generic_const_args
This commit is contained in:
commit
381e9ef09e
204 changed files with 1014 additions and 906 deletions
|
|
@ -5,8 +5,7 @@ struct Qux<'a> {
|
|||
x: &'a (),
|
||||
}
|
||||
impl<'a> Qux<'a> {
|
||||
#[type_const]
|
||||
const LEN: usize = 4;
|
||||
type const LEN: usize = 4;
|
||||
fn foo(_: [u8; Qux::LEN]) {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,12 +14,10 @@
|
|||
#![expect(unused_variables, incomplete_features)]
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const N: usize;
|
||||
type const N: usize;
|
||||
}
|
||||
impl Trait for () {
|
||||
#[type_const]
|
||||
const N: usize = 101;
|
||||
type const N: usize = 101;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ pub enum ParseMode {
|
|||
Raw,
|
||||
}
|
||||
pub trait Parse {
|
||||
#[type_const]
|
||||
const PARSE_MODE: ParseMode;
|
||||
type const PARSE_MODE: ParseMode;
|
||||
}
|
||||
pub trait RenderRaw {}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,5 @@
|
|||
pub fn accept(_: impl Trait<K = 0>) {}
|
||||
|
||||
pub trait Trait {
|
||||
#[type_const]
|
||||
const K: i32;
|
||||
type const K: i32;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ trait T {
|
|||
}
|
||||
|
||||
trait S {
|
||||
#[type_const]
|
||||
const C: i32;
|
||||
type const C: i32;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#![allow(incomplete_features)]
|
||||
|
||||
pub trait Trait {
|
||||
#[type_const]
|
||||
const ASSOC: usize;
|
||||
type const ASSOC: usize;
|
||||
}
|
||||
|
||||
pub fn foo<
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
struct OnDiskDirEntry<'a>(&'a ());
|
||||
|
||||
impl<'a> OnDiskDirEntry<'a> {
|
||||
#[type_const]
|
||||
const LFN_FRAGMENT_LEN: i64 = 2;
|
||||
type const LFN_FRAGMENT_LEN: i64 = 2;
|
||||
|
||||
fn lfn_contents() -> [char; Self::LFN_FRAGMENT_LEN] {
|
||||
//~^ ERROR the constant `2` is not of type `usize`
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ LL | #![feature(inherent_associated_types)]
|
|||
= note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information
|
||||
|
||||
error: the constant `2` is not of type `usize`
|
||||
--> $DIR/type-const-in-array-len-wrong-type.rs:14:26
|
||||
--> $DIR/type-const-in-array-len-wrong-type.rs:13:26
|
||||
|
|
||||
LL | fn lfn_contents() -> [char; Self::LFN_FRAGMENT_LEN] {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `i64`
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
// Test case from #138226: generic impl with multiple type parameters
|
||||
struct Foo<A, B>(A, B);
|
||||
impl<A, B> Foo<A, B> {
|
||||
#[type_const]
|
||||
const LEN: usize = 4;
|
||||
type const LEN: usize = 4;
|
||||
|
||||
fn foo() {
|
||||
let _ = [5; Self::LEN];
|
||||
|
|
@ -19,8 +18,7 @@ impl<A, B> Foo<A, B> {
|
|||
// Test case from #138226: generic impl with const parameter
|
||||
struct Bar<const N: usize>;
|
||||
impl<const N: usize> Bar<N> {
|
||||
#[type_const]
|
||||
const LEN: usize = 4;
|
||||
type const LEN: usize = 4;
|
||||
|
||||
fn bar() {
|
||||
let _ = [0; Self::LEN];
|
||||
|
|
@ -30,8 +28,7 @@ impl<const N: usize> Bar<N> {
|
|||
// Test case from #150960: non-generic impl with const block
|
||||
struct Baz;
|
||||
impl Baz {
|
||||
#[type_const]
|
||||
const LEN: usize = 4;
|
||||
type const LEN: usize = 4;
|
||||
|
||||
fn baz() {
|
||||
let _ = [0; { Self::LEN }];
|
||||
|
|
|
|||
|
|
@ -50,8 +50,7 @@ fn mismatch_2() -> impl Iterator<Item: Copy, Item: Send> {
|
|||
trait Trait {
|
||||
type Gat<T>;
|
||||
|
||||
#[type_const]
|
||||
const ASSOC: i32;
|
||||
type const ASSOC: i32;
|
||||
|
||||
fn foo() -> impl Sized;
|
||||
}
|
||||
|
|
@ -59,8 +58,7 @@ trait Trait {
|
|||
impl Trait for () {
|
||||
type Gat<T> = ();
|
||||
|
||||
#[type_const]
|
||||
const ASSOC: i32 = 3;
|
||||
type const ASSOC: i32 = 3;
|
||||
|
||||
fn foo() {}
|
||||
}
|
||||
|
|
@ -68,8 +66,7 @@ impl Trait for () {
|
|||
impl Trait for u32 {
|
||||
type Gat<T> = ();
|
||||
|
||||
#[type_const]
|
||||
const ASSOC: i32 = 4;
|
||||
type const ASSOC: i32 = 4;
|
||||
|
||||
fn foo() -> u32 {
|
||||
42
|
||||
|
|
@ -89,8 +86,7 @@ type MustFail = dyn Iterator<Item = i32, Item = u32>;
|
|||
//~| ERROR conflicting associated type bindings
|
||||
|
||||
trait Trait2 {
|
||||
#[type_const]
|
||||
const ASSOC: u32;
|
||||
type const ASSOC: u32;
|
||||
}
|
||||
|
||||
type MustFail2 = dyn Trait2<ASSOC = 3u32, ASSOC = 4u32>;
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ LL | iter::empty::<String>()
|
|||
| ----------------------- return type was inferred to be `std::iter::Empty<String>` here
|
||||
|
||||
error[E0271]: expected `IntoIter<u32, 1>` to be an iterator that yields `i32`, but it yields `u32`
|
||||
--> $DIR/duplicate-bound-err.rs:111:17
|
||||
--> $DIR/duplicate-bound-err.rs:107:17
|
||||
|
|
||||
LL | fn foo() -> impl Iterator<Item = i32, Item = u32> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
|
||||
|
|
@ -109,19 +109,19 @@ LL | [2u32].into_iter()
|
|||
| ------------------ return type was inferred to be `std::array::IntoIter<u32, 1>` here
|
||||
|
||||
error[E0271]: expected `impl Iterator<Item = u32>` to be an iterator that yields `i32`, but it yields `u32`
|
||||
--> $DIR/duplicate-bound-err.rs:111:17
|
||||
--> $DIR/duplicate-bound-err.rs:107:17
|
||||
|
|
||||
LL | fn foo() -> impl Iterator<Item = i32, Item = u32> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
|
||||
|
|
||||
note: required by a bound in `Trait3::foo::{anon_assoc#0}`
|
||||
--> $DIR/duplicate-bound-err.rs:107:31
|
||||
--> $DIR/duplicate-bound-err.rs:103:31
|
||||
|
|
||||
LL | fn foo() -> impl Iterator<Item = i32, Item = u32>;
|
||||
| ^^^^^^^^^^ required by this bound in `Trait3::foo::{anon_assoc#0}`
|
||||
|
||||
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
|
||||
--> $DIR/duplicate-bound-err.rs:87:42
|
||||
--> $DIR/duplicate-bound-err.rs:84:42
|
||||
|
|
||||
LL | type MustFail = dyn Iterator<Item = i32, Item = u32>;
|
||||
| ---------- ^^^^^^^^^^ re-bound here
|
||||
|
|
@ -129,7 +129,7 @@ LL | type MustFail = dyn Iterator<Item = i32, Item = u32>;
|
|||
| `Item` bound here first
|
||||
|
||||
error: conflicting associated type bindings for `Item`
|
||||
--> $DIR/duplicate-bound-err.rs:87:17
|
||||
--> $DIR/duplicate-bound-err.rs:84:17
|
||||
|
|
||||
LL | type MustFail = dyn Iterator<Item = i32, Item = u32>;
|
||||
| ^^^^^^^^^^^^^----------^^----------^
|
||||
|
|
@ -138,7 +138,7 @@ LL | type MustFail = dyn Iterator<Item = i32, Item = u32>;
|
|||
| `Item` is specified to be `i32` here
|
||||
|
||||
error[E0719]: the value of the associated type `ASSOC` in trait `Trait2` is already specified
|
||||
--> $DIR/duplicate-bound-err.rs:96:43
|
||||
--> $DIR/duplicate-bound-err.rs:92:43
|
||||
|
|
||||
LL | type MustFail2 = dyn Trait2<ASSOC = 3u32, ASSOC = 4u32>;
|
||||
| ------------ ^^^^^^^^^^^^ re-bound here
|
||||
|
|
@ -146,7 +146,7 @@ LL | type MustFail2 = dyn Trait2<ASSOC = 3u32, ASSOC = 4u32>;
|
|||
| `ASSOC` bound here first
|
||||
|
||||
error: conflicting associated constant bindings for `ASSOC`
|
||||
--> $DIR/duplicate-bound-err.rs:96:18
|
||||
--> $DIR/duplicate-bound-err.rs:92:18
|
||||
|
|
||||
LL | type MustFail2 = dyn Trait2<ASSOC = 3u32, ASSOC = 4u32>;
|
||||
| ^^^^^^^^^^^------------^^------------^
|
||||
|
|
@ -155,7 +155,7 @@ LL | type MustFail2 = dyn Trait2<ASSOC = 3u32, ASSOC = 4u32>;
|
|||
| `ASSOC` is specified to be `3` here
|
||||
|
||||
error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified
|
||||
--> $DIR/duplicate-bound-err.rs:100:43
|
||||
--> $DIR/duplicate-bound-err.rs:96:43
|
||||
|
|
||||
LL | type MustFail3 = dyn Iterator<Item = i32, Item = i32>;
|
||||
| ---------- ^^^^^^^^^^ re-bound here
|
||||
|
|
@ -163,7 +163,7 @@ LL | type MustFail3 = dyn Iterator<Item = i32, Item = i32>;
|
|||
| `Item` bound here first
|
||||
|
||||
error[E0719]: the value of the associated type `ASSOC` in trait `Trait2` is already specified
|
||||
--> $DIR/duplicate-bound-err.rs:103:43
|
||||
--> $DIR/duplicate-bound-err.rs:99:43
|
||||
|
|
||||
LL | type MustFail4 = dyn Trait2<ASSOC = 3u32, ASSOC = 3u32>;
|
||||
| ------------ ^^^^^^^^^^^^ re-bound here
|
||||
|
|
@ -171,7 +171,7 @@ LL | type MustFail4 = dyn Trait2<ASSOC = 3u32, ASSOC = 3u32>;
|
|||
| `ASSOC` bound here first
|
||||
|
||||
error[E0271]: expected `Empty<u32>` to be an iterator that yields `i32`, but it yields `u32`
|
||||
--> $DIR/duplicate-bound-err.rs:119:16
|
||||
--> $DIR/duplicate-bound-err.rs:115:16
|
||||
|
|
||||
LL | uncallable(iter::empty::<u32>());
|
||||
| ---------- ^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32`
|
||||
|
|
@ -179,13 +179,13 @@ LL | uncallable(iter::empty::<u32>());
|
|||
| required by a bound introduced by this call
|
||||
|
|
||||
note: required by a bound in `uncallable`
|
||||
--> $DIR/duplicate-bound-err.rs:79:32
|
||||
--> $DIR/duplicate-bound-err.rs:76:32
|
||||
|
|
||||
LL | fn uncallable(_: impl Iterator<Item = i32, Item = u32>) {}
|
||||
| ^^^^^^^^^^ required by this bound in `uncallable`
|
||||
|
||||
error[E0271]: expected `Empty<i32>` to be an iterator that yields `u32`, but it yields `i32`
|
||||
--> $DIR/duplicate-bound-err.rs:120:16
|
||||
--> $DIR/duplicate-bound-err.rs:116:16
|
||||
|
|
||||
LL | uncallable(iter::empty::<i32>());
|
||||
| ---------- ^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `i32`
|
||||
|
|
@ -193,13 +193,13 @@ LL | uncallable(iter::empty::<i32>());
|
|||
| required by a bound introduced by this call
|
||||
|
|
||||
note: required by a bound in `uncallable`
|
||||
--> $DIR/duplicate-bound-err.rs:79:44
|
||||
--> $DIR/duplicate-bound-err.rs:76:44
|
||||
|
|
||||
LL | fn uncallable(_: impl Iterator<Item = i32, Item = u32>) {}
|
||||
| ^^^^^^^^^^ required by this bound in `uncallable`
|
||||
|
||||
error[E0271]: type mismatch resolving `<() as Trait>::ASSOC == 4`
|
||||
--> $DIR/duplicate-bound-err.rs:121:22
|
||||
--> $DIR/duplicate-bound-err.rs:117:22
|
||||
|
|
||||
LL | uncallable_const(());
|
||||
| ---------------- ^^ expected `4`, found `3`
|
||||
|
|
@ -209,13 +209,13 @@ LL | uncallable_const(());
|
|||
= note: expected constant `4`
|
||||
found constant `3`
|
||||
note: required by a bound in `uncallable_const`
|
||||
--> $DIR/duplicate-bound-err.rs:81:46
|
||||
--> $DIR/duplicate-bound-err.rs:78:46
|
||||
|
|
||||
LL | fn uncallable_const(_: impl Trait<ASSOC = 3, ASSOC = 4>) {}
|
||||
| ^^^^^^^^^ required by this bound in `uncallable_const`
|
||||
|
||||
error[E0271]: type mismatch resolving `<u32 as Trait>::ASSOC == 3`
|
||||
--> $DIR/duplicate-bound-err.rs:122:22
|
||||
--> $DIR/duplicate-bound-err.rs:118:22
|
||||
|
|
||||
LL | uncallable_const(4u32);
|
||||
| ---------------- ^^^^ expected `3`, found `4`
|
||||
|
|
@ -225,13 +225,13 @@ LL | uncallable_const(4u32);
|
|||
= note: expected constant `3`
|
||||
found constant `4`
|
||||
note: required by a bound in `uncallable_const`
|
||||
--> $DIR/duplicate-bound-err.rs:81:35
|
||||
--> $DIR/duplicate-bound-err.rs:78:35
|
||||
|
|
||||
LL | fn uncallable_const(_: impl Trait<ASSOC = 3, ASSOC = 4>) {}
|
||||
| ^^^^^^^^^ required by this bound in `uncallable_const`
|
||||
|
||||
error[E0271]: type mismatch resolving `<() as Trait>::ASSOC == 4`
|
||||
--> $DIR/duplicate-bound-err.rs:123:20
|
||||
--> $DIR/duplicate-bound-err.rs:119:20
|
||||
|
|
||||
LL | uncallable_rtn(());
|
||||
| -------------- ^^ expected `4`, found `3`
|
||||
|
|
@ -241,7 +241,7 @@ LL | uncallable_rtn(());
|
|||
= note: expected constant `4`
|
||||
found constant `3`
|
||||
note: required by a bound in `uncallable_rtn`
|
||||
--> $DIR/duplicate-bound-err.rs:84:61
|
||||
--> $DIR/duplicate-bound-err.rs:81:61
|
||||
|
|
||||
LL | fn uncallable_rtn(
|
||||
| -------------- required by a bound in this function
|
||||
|
|
@ -249,7 +249,7 @@ LL | _: impl Trait<foo(..): Trait<ASSOC = 3>, foo(..): Trait<ASSOC = 4>>
|
|||
| ^^^^^^^^^ required by this bound in `uncallable_rtn`
|
||||
|
||||
error[E0271]: type mismatch resolving `<u32 as Trait>::ASSOC == 3`
|
||||
--> $DIR/duplicate-bound-err.rs:124:20
|
||||
--> $DIR/duplicate-bound-err.rs:120:20
|
||||
|
|
||||
LL | uncallable_rtn(17u32);
|
||||
| -------------- ^^^^^ expected `3`, found `4`
|
||||
|
|
@ -259,7 +259,7 @@ LL | uncallable_rtn(17u32);
|
|||
= note: expected constant `3`
|
||||
found constant `4`
|
||||
note: required by a bound in `uncallable_rtn`
|
||||
--> $DIR/duplicate-bound-err.rs:84:34
|
||||
--> $DIR/duplicate-bound-err.rs:81:34
|
||||
|
|
||||
LL | fn uncallable_rtn(
|
||||
| -------------- required by a bound in this function
|
||||
|
|
|
|||
|
|
@ -189,8 +189,7 @@ trait Tra3 {
|
|||
trait Trait {
|
||||
type Gat<T>;
|
||||
|
||||
#[type_const]
|
||||
const ASSOC: i32;
|
||||
type const ASSOC: i32;
|
||||
|
||||
fn foo() -> impl Sized;
|
||||
}
|
||||
|
|
@ -198,8 +197,7 @@ trait Trait {
|
|||
impl Trait for () {
|
||||
type Gat<T> = ();
|
||||
|
||||
#[type_const]
|
||||
const ASSOC: i32 = 3;
|
||||
type const ASSOC: i32 = 3;
|
||||
|
||||
fn foo() {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
struct S<const N: usize>;
|
||||
impl<const N: usize> S<N> {
|
||||
#[type_const]
|
||||
//~^ ERROR: the `#[type_const]` attribute is an experimental feature
|
||||
const LEN: usize = 1;
|
||||
type const LEN: usize = 1;
|
||||
//~^ ERROR: associated `type const` are unstable [E0658]
|
||||
//~| ERROR: `type const` syntax is experimental [E0658]
|
||||
fn arr() {
|
||||
[8; Self::LEN]
|
||||
//~^ WARN: cannot use constants which depend on generic parameters in types
|
||||
|
|
|
|||
|
|
@ -1,8 +1,18 @@
|
|||
error[E0658]: the `#[type_const]` attribute is an experimental feature
|
||||
error[E0658]: `type const` syntax is experimental
|
||||
--> $DIR/type-const-inherent-impl-normalize.rs:3:5
|
||||
|
|
||||
LL | #[type_const]
|
||||
| ^^^^^^^^^^^^^
|
||||
LL | type const LEN: usize = 1;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
|
||||
= help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: associated `type const` are unstable
|
||||
--> $DIR/type-const-inherent-impl-normalize.rs:3:5
|
||||
|
|
||||
LL | type const LEN: usize = 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
|
||||
= help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable
|
||||
|
|
@ -36,7 +46,7 @@ LL | fn arr() {
|
|||
LL | [8; Self::LEN]
|
||||
| ^^^^^^^^^^^^^^ expected `()`, found `[{integer}; 1]`
|
||||
|
||||
error: aborting due to 2 previous errors; 2 warnings emitted
|
||||
error: aborting due to 3 previous errors; 2 warnings emitted
|
||||
|
||||
Some errors have detailed explanations: E0308, E0658.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
||||
|
|
|
|||
|
|
@ -145,8 +145,6 @@ struct Test;
|
|||
#[diagnostic::on_unimplemented = 1]
|
||||
//~^ WARN malformed
|
||||
trait Hey {
|
||||
#[type_const = 1]
|
||||
//~^ ERROR malformed
|
||||
const HEY: usize = 5;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ LL | #[cfg_attr]
|
|||
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
|
||||
|
||||
error[E0463]: can't find crate for `wloop`
|
||||
--> $DIR/malformed-attrs.rs:217:1
|
||||
--> $DIR/malformed-attrs.rs:215:1
|
||||
|
|
||||
LL | extern crate wloop;
|
||||
| ^^^^^^^^^^^^^^^^^^^ can't find crate
|
||||
|
||||
error: malformed `allow` attribute input
|
||||
--> $DIR/malformed-attrs.rs:183:1
|
||||
--> $DIR/malformed-attrs.rs:181:1
|
||||
|
|
||||
LL | #[allow]
|
||||
| ^^^^^^^^
|
||||
|
|
@ -43,7 +43,7 @@ LL | #[allow(lint1, lint2, lint3, reason = "...")]
|
|||
| +++++++++++++++++++++++++++++++++++++
|
||||
|
||||
error: malformed `expect` attribute input
|
||||
--> $DIR/malformed-attrs.rs:185:1
|
||||
--> $DIR/malformed-attrs.rs:183:1
|
||||
|
|
||||
LL | #[expect]
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -59,7 +59,7 @@ LL | #[expect(lint1, lint2, lint3, reason = "...")]
|
|||
| +++++++++++++++++++++++++++++++++++++
|
||||
|
||||
error: malformed `warn` attribute input
|
||||
--> $DIR/malformed-attrs.rs:187:1
|
||||
--> $DIR/malformed-attrs.rs:185:1
|
||||
|
|
||||
LL | #[warn]
|
||||
| ^^^^^^^
|
||||
|
|
@ -75,7 +75,7 @@ LL | #[warn(lint1, lint2, lint3, reason = "...")]
|
|||
| +++++++++++++++++++++++++++++++++++++
|
||||
|
||||
error: malformed `deny` attribute input
|
||||
--> $DIR/malformed-attrs.rs:189:1
|
||||
--> $DIR/malformed-attrs.rs:187:1
|
||||
|
|
||||
LL | #[deny]
|
||||
| ^^^^^^^
|
||||
|
|
@ -91,7 +91,7 @@ LL | #[deny(lint1, lint2, lint3, reason = "...")]
|
|||
| +++++++++++++++++++++++++++++++++++++
|
||||
|
||||
error: malformed `forbid` attribute input
|
||||
--> $DIR/malformed-attrs.rs:191:1
|
||||
--> $DIR/malformed-attrs.rs:189:1
|
||||
|
|
||||
LL | #[forbid]
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -125,7 +125,7 @@ LL | #[proc_macro_derive]
|
|||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0658]: allow_internal_unsafe side-steps the unsafe_code lint
|
||||
--> $DIR/malformed-attrs.rs:222:1
|
||||
--> $DIR/malformed-attrs.rs:220:1
|
||||
|
|
||||
LL | #[allow_internal_unsafe = 1]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -541,7 +541,7 @@ LL | #[cfi_encoding = ""]
|
|||
| help: must be of the form: `#[cfi_encoding = "encoding"]`
|
||||
|
||||
error[E0565]: malformed `marker` attribute input
|
||||
--> $DIR/malformed-attrs.rs:160:1
|
||||
--> $DIR/malformed-attrs.rs:158:1
|
||||
|
|
||||
LL | #[marker = 3]
|
||||
| ^^^^^^^^^---^
|
||||
|
|
@ -550,7 +550,7 @@ LL | #[marker = 3]
|
|||
| help: must be of the form: `#[marker]`
|
||||
|
||||
error[E0565]: malformed `fundamental` attribute input
|
||||
--> $DIR/malformed-attrs.rs:162:1
|
||||
--> $DIR/malformed-attrs.rs:160:1
|
||||
|
|
||||
LL | #[fundamental()]
|
||||
| ^^^^^^^^^^^^^--^
|
||||
|
|
@ -559,7 +559,7 @@ LL | #[fundamental()]
|
|||
| help: must be of the form: `#[fundamental]`
|
||||
|
||||
error[E0565]: malformed `ffi_pure` attribute input
|
||||
--> $DIR/malformed-attrs.rs:170:5
|
||||
--> $DIR/malformed-attrs.rs:168:5
|
||||
|
|
||||
LL | #[unsafe(ffi_pure = 1)]
|
||||
| ^^^^^^^^^^^^^^^^^^---^^
|
||||
|
|
@ -568,7 +568,7 @@ LL | #[unsafe(ffi_pure = 1)]
|
|||
| help: must be of the form: `#[ffi_pure]`
|
||||
|
||||
error[E0539]: malformed `link_ordinal` attribute input
|
||||
--> $DIR/malformed-attrs.rs:172:5
|
||||
--> $DIR/malformed-attrs.rs:170:5
|
||||
|
|
||||
LL | #[link_ordinal]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
@ -579,7 +579,7 @@ LL | #[link_ordinal]
|
|||
= note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_ordinal-attribute>
|
||||
|
||||
error[E0565]: malformed `ffi_const` attribute input
|
||||
--> $DIR/malformed-attrs.rs:176:5
|
||||
--> $DIR/malformed-attrs.rs:174:5
|
||||
|
|
||||
LL | #[unsafe(ffi_const = 1)]
|
||||
| ^^^^^^^^^^^^^^^^^^^---^^
|
||||
|
|
@ -588,13 +588,13 @@ LL | #[unsafe(ffi_const = 1)]
|
|||
| help: must be of the form: `#[ffi_const]`
|
||||
|
||||
error[E0539]: malformed `linkage` attribute input
|
||||
--> $DIR/malformed-attrs.rs:178:5
|
||||
--> $DIR/malformed-attrs.rs:176:5
|
||||
|
|
||||
LL | #[linkage]
|
||||
| ^^^^^^^^^^ expected this to be of the form `linkage = "..."`
|
||||
|
||||
error[E0539]: malformed `debugger_visualizer` attribute input
|
||||
--> $DIR/malformed-attrs.rs:193:1
|
||||
--> $DIR/malformed-attrs.rs:191:1
|
||||
|
|
||||
LL | #[debugger_visualizer]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -605,7 +605,7 @@ LL | #[debugger_visualizer]
|
|||
= note: for more information, visit <https://doc.rust-lang.org/reference/attributes/debugger.html#the-debugger_visualizer-attribute>
|
||||
|
||||
error[E0565]: malformed `automatically_derived` attribute input
|
||||
--> $DIR/malformed-attrs.rs:195:1
|
||||
--> $DIR/malformed-attrs.rs:193:1
|
||||
|
|
||||
LL | #[automatically_derived = 18]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^----^
|
||||
|
|
@ -614,7 +614,7 @@ LL | #[automatically_derived = 18]
|
|||
| help: must be of the form: `#[automatically_derived]`
|
||||
|
||||
error[E0565]: malformed `non_exhaustive` attribute input
|
||||
--> $DIR/malformed-attrs.rs:203:1
|
||||
--> $DIR/malformed-attrs.rs:201:1
|
||||
|
|
||||
LL | #[non_exhaustive = 1]
|
||||
| ^^^^^^^^^^^^^^^^^---^
|
||||
|
|
@ -623,7 +623,7 @@ LL | #[non_exhaustive = 1]
|
|||
| help: must be of the form: `#[non_exhaustive]`
|
||||
|
||||
error[E0565]: malformed `thread_local` attribute input
|
||||
--> $DIR/malformed-attrs.rs:209:1
|
||||
--> $DIR/malformed-attrs.rs:207:1
|
||||
|
|
||||
LL | #[thread_local()]
|
||||
| ^^^^^^^^^^^^^^--^
|
||||
|
|
@ -632,7 +632,7 @@ LL | #[thread_local()]
|
|||
| help: must be of the form: `#[thread_local]`
|
||||
|
||||
error[E0565]: malformed `no_link` attribute input
|
||||
--> $DIR/malformed-attrs.rs:213:1
|
||||
--> $DIR/malformed-attrs.rs:211:1
|
||||
|
|
||||
LL | #[no_link()]
|
||||
| ^^^^^^^^^--^
|
||||
|
|
@ -641,7 +641,7 @@ LL | #[no_link()]
|
|||
| help: must be of the form: `#[no_link]`
|
||||
|
||||
error[E0539]: malformed `macro_use` attribute input
|
||||
--> $DIR/malformed-attrs.rs:215:1
|
||||
--> $DIR/malformed-attrs.rs:213:1
|
||||
|
|
||||
LL | #[macro_use = 1]
|
||||
| ^^^^^^^^^^^^---^
|
||||
|
|
@ -659,7 +659,7 @@ LL + #[macro_use]
|
|||
|
|
||||
|
||||
error[E0539]: malformed `macro_export` attribute input
|
||||
--> $DIR/malformed-attrs.rs:220:1
|
||||
--> $DIR/malformed-attrs.rs:218:1
|
||||
|
|
||||
LL | #[macro_export = 18]
|
||||
| ^^^^^^^^^^^^^^^----^
|
||||
|
|
@ -676,7 +676,7 @@ LL + #[macro_export]
|
|||
|
|
||||
|
||||
error[E0565]: malformed `allow_internal_unsafe` attribute input
|
||||
--> $DIR/malformed-attrs.rs:222:1
|
||||
--> $DIR/malformed-attrs.rs:220:1
|
||||
|
|
||||
LL | #[allow_internal_unsafe = 1]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^---^
|
||||
|
|
@ -684,15 +684,6 @@ LL | #[allow_internal_unsafe = 1]
|
|||
| | didn't expect any arguments here
|
||||
| help: must be of the form: `#[allow_internal_unsafe]`
|
||||
|
||||
error[E0565]: malformed `type_const` attribute input
|
||||
--> $DIR/malformed-attrs.rs:148:5
|
||||
|
|
||||
LL | #[type_const = 1]
|
||||
| ^^^^^^^^^^^^^---^
|
||||
| | |
|
||||
| | didn't expect any arguments here
|
||||
| help: must be of the form: `#[type_const]`
|
||||
|
||||
error: attribute should be applied to `const fn`
|
||||
--> $DIR/malformed-attrs.rs:32:1
|
||||
|
|
||||
|
|
@ -820,13 +811,13 @@ LL | #[no_implicit_prelude = 23]
|
|||
= help: `#[no_implicit_prelude]` can be applied to crates and modules
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
|
||||
--> $DIR/malformed-attrs.rs:154:1
|
||||
--> $DIR/malformed-attrs.rs:152:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend()]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[automatically_derived]` attribute cannot be used on modules
|
||||
--> $DIR/malformed-attrs.rs:195:1
|
||||
--> $DIR/malformed-attrs.rs:193:1
|
||||
|
|
||||
LL | #[automatically_derived = 18]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -835,7 +826,7 @@ LL | #[automatically_derived = 18]
|
|||
= help: `#[automatically_derived]` can only be applied to trait impl blocks
|
||||
|
||||
error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]`
|
||||
--> $DIR/malformed-attrs.rs:229:1
|
||||
--> $DIR/malformed-attrs.rs:227:1
|
||||
|
|
||||
LL | #[ignore = 1]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
@ -854,7 +845,7 @@ LL | #[coroutine = 63] || {}
|
|||
= note: expected unit type `()`
|
||||
found coroutine `{coroutine@$DIR/malformed-attrs.rs:116:23: 116:25}`
|
||||
|
||||
error: aborting due to 76 previous errors; 8 warnings emitted
|
||||
error: aborting due to 75 previous errors; 8 warnings emitted
|
||||
|
||||
Some errors have detailed explanations: E0308, E0463, E0539, E0565, E0658, E0805.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
||||
|
|
@ -882,7 +873,7 @@ LL | #[ignore()]
|
|||
|
||||
Future breakage diagnostic:
|
||||
error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]`
|
||||
--> $DIR/malformed-attrs.rs:229:1
|
||||
--> $DIR/malformed-attrs.rs:227:1
|
||||
|
|
||||
LL | #[ignore = 1]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
trait Trait0: Parent0<i32> + Parent0<u32> {}
|
||||
trait Parent0<T> {
|
||||
#[type_const]
|
||||
const K: ();
|
||||
type const K: ();
|
||||
}
|
||||
|
||||
fn take0(_: impl Trait0<K = const { }>) {}
|
||||
|
|
@ -15,12 +14,10 @@ fn take0(_: impl Trait0<K = const { }>) {}
|
|||
|
||||
trait Trait1: Parent1 + Parent2 {}
|
||||
trait Parent1 {
|
||||
#[type_const]
|
||||
const C: i32;
|
||||
type const C: i32;
|
||||
}
|
||||
trait Parent2 {
|
||||
#[type_const]
|
||||
const C: &'static str;
|
||||
type const C: &'static str;
|
||||
}
|
||||
|
||||
fn take1(_: impl Trait1<C = "?">) {}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0222]: ambiguous associated constant `K` in bounds of `Trait0`
|
||||
--> $DIR/ambiguity.rs:13:25
|
||||
--> $DIR/ambiguity.rs:12:25
|
||||
|
|
||||
LL | const K: ();
|
||||
| -----------
|
||||
LL | type const K: ();
|
||||
| ----------------
|
||||
| |
|
||||
| ambiguous `K` from `Parent0<u32>`
|
||||
| ambiguous `K` from `Parent0<i32>`
|
||||
|
|
@ -17,13 +17,13 @@ LL | fn take0(_: impl Trait0<K = const { }>) {}
|
|||
T: Parent0<i32>::K = const { }
|
||||
|
||||
error[E0222]: ambiguous associated constant `C` in bounds of `Trait1`
|
||||
--> $DIR/ambiguity.rs:26:25
|
||||
--> $DIR/ambiguity.rs:23:25
|
||||
|
|
||||
LL | const C: i32;
|
||||
| ------------ ambiguous `C` from `Parent1`
|
||||
LL | type const C: i32;
|
||||
| ----------------- ambiguous `C` from `Parent1`
|
||||
...
|
||||
LL | const C: &'static str;
|
||||
| --------------------- ambiguous `C` from `Parent2`
|
||||
LL | type const C: &'static str;
|
||||
| -------------------------- ambiguous `C` from `Parent2`
|
||||
...
|
||||
LL | fn take1(_: impl Trait1<C = "?">) {}
|
||||
| ^^^^^^^ ambiguous associated constant `C`
|
||||
|
|
|
|||
|
|
@ -3,15 +3,13 @@
|
|||
#![allow(unused, incomplete_features)]
|
||||
|
||||
pub trait Foo {
|
||||
#[type_const]
|
||||
const N: usize;
|
||||
type const N: usize;
|
||||
}
|
||||
|
||||
pub struct Bar;
|
||||
|
||||
impl Foo for Bar {
|
||||
#[type_const]
|
||||
const N: usize = 3;
|
||||
type const N: usize = 3;
|
||||
}
|
||||
|
||||
const TEST: usize = 3;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@
|
|||
use std::marker::ConstParamTy_;
|
||||
|
||||
trait Trait<T: ConstParamTy_> {
|
||||
#[type_const]
|
||||
const K: T;
|
||||
type const K: T;
|
||||
}
|
||||
|
||||
fn take(
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error: higher-ranked subtype error
|
||||
--> $DIR/bound-var-in-ty-not-wf.rs:21:13
|
||||
--> $DIR/bound-var-in-ty-not-wf.rs:20:13
|
||||
|
|
||||
LL | K = const { () }
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: higher-ranked subtype error
|
||||
--> $DIR/bound-var-in-ty-not-wf.rs:21:13
|
||||
--> $DIR/bound-var-in-ty-not-wf.rs:20:13
|
||||
|
|
||||
LL | K = const { () }
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -14,8 +14,7 @@
|
|||
use std::marker::ConstParamTy_;
|
||||
|
||||
trait Trait<T: ConstParamTy_> {
|
||||
#[type_const]
|
||||
const K: T;
|
||||
type const K: T;
|
||||
}
|
||||
|
||||
fn take(
|
||||
|
|
|
|||
|
|
@ -12,13 +12,11 @@ trait Trait: SuperTrait {
|
|||
type N;
|
||||
type Q;
|
||||
|
||||
#[type_const]
|
||||
const N: usize;
|
||||
type const N: usize;
|
||||
}
|
||||
|
||||
trait SuperTrait {
|
||||
#[type_const]
|
||||
const Q: &'static str;
|
||||
type const Q: &'static str;
|
||||
}
|
||||
|
||||
fn take0(_: impl Trait<N = 0, N = ()>) {}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,10 @@
|
|||
#![expect(incomplete_features)]
|
||||
|
||||
pub trait IsVoid {
|
||||
#[type_const]
|
||||
const IS_VOID: bool;
|
||||
type const IS_VOID: bool;
|
||||
}
|
||||
impl IsVoid for () {
|
||||
#[type_const]
|
||||
const IS_VOID: bool = true;
|
||||
type const IS_VOID: bool = true;
|
||||
}
|
||||
|
||||
pub trait Maybe {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0119]: conflicting implementations of trait `Maybe` for type `()`
|
||||
--> $DIR/coherence.rs:15:1
|
||||
--> $DIR/coherence.rs:13:1
|
||||
|
|
||||
LL | impl Maybe for () {}
|
||||
| ----------------- first implementation here
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
#![allow(incomplete_features)]
|
||||
|
||||
trait TraitWAssocConst {
|
||||
#[type_const]
|
||||
const A: usize;
|
||||
type const A: usize;
|
||||
}
|
||||
|
||||
fn foo<T: TraitWAssocConst<A = 1>>() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0271]: type mismatch resolving `<T as TraitWAssocConst>::A == 1`
|
||||
--> $DIR/const-projection-err.rs:12:11
|
||||
--> $DIR/const-projection-err.rs:11:11
|
||||
|
|
||||
LL | foo::<T>();
|
||||
| ^ expected `1`, found `0`
|
||||
|
|
@ -7,7 +7,7 @@ LL | foo::<T>();
|
|||
= note: expected constant `1`
|
||||
found constant `0`
|
||||
note: required by a bound in `foo`
|
||||
--> $DIR/const-projection-err.rs:9:28
|
||||
--> $DIR/const-projection-err.rs:8:28
|
||||
|
|
||||
LL | fn foo<T: TraitWAssocConst<A = 1>>() {}
|
||||
| ^^^^^ required by this bound in `foo`
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
#![allow(incomplete_features)]
|
||||
|
||||
pub trait TraitA<T> {
|
||||
#[type_const]
|
||||
const K: u8 = 0;
|
||||
type const K: u8 = 0;
|
||||
}
|
||||
pub trait TraitB<T> {}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,14 +14,12 @@ trait Trait {
|
|||
// NOTE: The `ConstParamTy_` bound is intentionally on the assoc const and not on the trait as
|
||||
// doing the latter would already render the trait dyn incompatible due to it being
|
||||
// bounded by `PartialEq<Self>` and supertrait bounds cannot mention `Self` like this.
|
||||
#[type_const]
|
||||
const K: Self where Self: std::marker::ConstParamTy_;
|
||||
type const K: Self where Self: std::marker::ConstParamTy_;
|
||||
//~^ NOTE it contains associated const `K` whose type references the `Self` type
|
||||
|
||||
// This is not a "`Self` projection" in our sense (which would be allowed)
|
||||
// since the trait is not the principal trait or a supertrait thereof.
|
||||
#[type_const]
|
||||
const Q: <Self as SomeOtherTrait>::Output;
|
||||
type const Q: <Self as SomeOtherTrait>::Output;
|
||||
//~^ NOTE it contains associated const `Q` whose type references the `Self` type
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
error[E0038]: the trait `Trait` is not dyn compatible
|
||||
--> $DIR/dyn-compat-assoc-const-ty-mentions-self.rs:38:16
|
||||
--> $DIR/dyn-compat-assoc-const-ty-mentions-self.rs:36:16
|
||||
|
|
||||
LL | let _: dyn Trait;
|
||||
| ^^^^^ `Trait` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/dyn-compat-assoc-const-ty-mentions-self.rs:18:11
|
||||
--> $DIR/dyn-compat-assoc-const-ty-mentions-self.rs:17:16
|
||||
|
|
||||
LL | trait Trait {
|
||||
| ----- this trait is not dyn compatible...
|
||||
...
|
||||
LL | const K: Self where Self: std::marker::ConstParamTy_;
|
||||
| ^ ...because it contains associated const `K` whose type references the `Self` type
|
||||
LL | type const K: Self where Self: std::marker::ConstParamTy_;
|
||||
| ^ ...because it contains associated const `K` whose type references the `Self` type
|
||||
...
|
||||
LL | const Q: <Self as SomeOtherTrait>::Output;
|
||||
| ^ ...because it contains associated const `Q` whose type references the `Self` type
|
||||
LL | type const Q: <Self as SomeOtherTrait>::Output;
|
||||
| ^ ...because it contains associated const `Q` whose type references the `Self` type
|
||||
= help: consider moving `K` to another trait
|
||||
= help: consider moving `Q` to another trait
|
||||
|
||||
|
|
|
|||
|
|
@ -7,25 +7,20 @@
|
|||
#![expect(incomplete_features)]
|
||||
|
||||
trait Trait: SuperTrait<C = 3> {
|
||||
#[type_const]
|
||||
const K: usize;
|
||||
type const K: usize;
|
||||
}
|
||||
|
||||
trait SuperTrait {
|
||||
#[type_const]
|
||||
const Q: usize;
|
||||
#[type_const]
|
||||
const C: usize;
|
||||
type const Q: usize;
|
||||
type const C: usize;
|
||||
}
|
||||
|
||||
trait Bound {
|
||||
#[type_const]
|
||||
const N: usize;
|
||||
type const N: usize;
|
||||
}
|
||||
|
||||
impl Bound for () {
|
||||
#[type_const]
|
||||
const N: usize = 10;
|
||||
type const N: usize = 10;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -4,13 +4,11 @@
|
|||
#![expect(incomplete_features)]
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const N: usize;
|
||||
type const N: usize;
|
||||
}
|
||||
|
||||
impl Trait for () {
|
||||
#[type_const]
|
||||
const N: usize = 1;
|
||||
type const N: usize = 1;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0271]: type mismatch resolving `<() as Trait>::N == 0`
|
||||
--> $DIR/dyn-compat-const-mismatch.rs:17:32
|
||||
--> $DIR/dyn-compat-const-mismatch.rs:15:32
|
||||
|
|
||||
LL | let _: &dyn Trait<N = 0> = &();
|
||||
| ^^^ expected `0`, found `1`
|
||||
|
|
|
|||
|
|
@ -7,13 +7,11 @@
|
|||
trait X<const N: usize = { <Self as Y>::N }> {}
|
||||
|
||||
trait Y {
|
||||
#[type_const]
|
||||
const N: usize;
|
||||
type const N: usize;
|
||||
}
|
||||
|
||||
impl<T: ?Sized> Y for T {
|
||||
#[type_const]
|
||||
const N: usize = 1;
|
||||
type const N: usize = 1;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0393]: the const parameter `N` must be explicitly specified
|
||||
--> $DIR/dyn-compat-const-param-default-mentions-self.rs:20:16
|
||||
--> $DIR/dyn-compat-const-param-default-mentions-self.rs:18:16
|
||||
|
|
||||
LL | trait X<const N: usize = { <Self as Y>::N }> {}
|
||||
| -------------------------------------------- const parameter `N` must be specified for this
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@
|
|||
#![expect(incomplete_features)]
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const Y: i32;
|
||||
type const Y: i32;
|
||||
}
|
||||
|
||||
struct Hold<T: ?Sized>(T);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: associated constant binding in trait object type mentions `Self`
|
||||
--> $DIR/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs:21:12
|
||||
--> $DIR/dyn-compat-const-projection-behind-trait-alias-mentions-self.rs:20:12
|
||||
|
|
||||
LL | trait Bound = Trait<Y = { Hold::<Self> }>;
|
||||
| -------------------- this binding mentions `Self`
|
||||
|
|
|
|||
|
|
@ -5,13 +5,11 @@
|
|||
#![expect(incomplete_features)]
|
||||
|
||||
trait X: Y<K = { Self::Q }> {
|
||||
#[type_const]
|
||||
const Q: usize;
|
||||
type const Q: usize;
|
||||
}
|
||||
|
||||
trait Y {
|
||||
#[type_const]
|
||||
const K: usize;
|
||||
type const K: usize;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0191]: the value of the associated constant `K` in `Y` must be specified
|
||||
--> $DIR/dyn-compat-const-projection-from-supertrait-mentions-self.rs:18:16
|
||||
--> $DIR/dyn-compat-const-projection-from-supertrait-mentions-self.rs:16:16
|
||||
|
|
||||
LL | const K: usize;
|
||||
| -------------- `K` defined here
|
||||
LL | type const K: usize;
|
||||
| ------------------- `K` defined here
|
||||
...
|
||||
LL | let _: dyn X<Q = 10>;
|
||||
| ^^^^^^^^^ help: specify the associated constant: `X<Q = 10, K = /* CONST */>`
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
trait Trait {
|
||||
const K: usize;
|
||||
//~^ NOTE it contains associated const `K` that's not marked `#[type_const]`
|
||||
//~^ NOTE it contains associated const `K` that's not defined as `type const`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
@ -16,5 +16,5 @@ fn main() {
|
|||
// Check that specifying the non-type assoc const doesn't "magically make it work".
|
||||
let _: dyn Trait<K = 0>;
|
||||
//~^ ERROR the trait `Trait` is not dyn compatible
|
||||
//~| ERROR use of trait associated const without `#[type_const]`
|
||||
//~| ERROR use of trait associated const not defined as `type const`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@ note: for a trait to be dyn compatible it needs to allow building a vtable
|
|||
LL | trait Trait {
|
||||
| ----- this trait is not dyn compatible...
|
||||
LL | const K: usize;
|
||||
| ^ ...because it contains associated const `K` that's not marked `#[type_const]`
|
||||
| ^ ...because it contains associated const `K` that's not defined as `type const`
|
||||
= help: consider moving `K` to another trait
|
||||
|
||||
error: use of trait associated const without `#[type_const]`
|
||||
error: use of trait associated const not defined as `type const`
|
||||
--> $DIR/dyn-compat-non-type-assoc-const.rs:17:22
|
||||
|
|
||||
LL | let _: dyn Trait<K = 0>;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: the declaration in the trait must be marked with `#[type_const]`
|
||||
= note: the declaration in the trait must begin with `type const` not just `const` alone
|
||||
|
||||
error[E0038]: the trait `Trait` is not dyn compatible
|
||||
--> $DIR/dyn-compat-non-type-assoc-const.rs:17:16
|
||||
|
|
@ -35,7 +35,7 @@ note: for a trait to be dyn compatible it needs to allow building a vtable
|
|||
LL | trait Trait {
|
||||
| ----- this trait is not dyn compatible...
|
||||
LL | const K: usize;
|
||||
| ^ ...because it contains associated const `K` that's not marked `#[type_const]`
|
||||
| ^ ...because it contains associated const `K` that's not defined as `type const`
|
||||
= help: consider moving `K` to another trait
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
|
|
|||
|
|
@ -6,13 +6,11 @@
|
|||
#![expect(incomplete_features)]
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const N: i32 where Self: Bound;
|
||||
type const N: i32 where Self: Bound;
|
||||
}
|
||||
|
||||
impl Trait for () {
|
||||
#[type_const]
|
||||
const N: i32 = 0;
|
||||
type const N: i32 = 0;
|
||||
}
|
||||
|
||||
trait Bound {}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
error[E0277]: the trait bound `(): Bound` is not satisfied
|
||||
--> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:23:32
|
||||
--> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:21:32
|
||||
|
|
||||
LL | let _: &dyn Trait<N = 0> = &();
|
||||
| ^^^ the trait `Bound` is not implemented for `()`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:18:1
|
||||
--> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:16:1
|
||||
|
|
||||
LL | trait Bound {}
|
||||
| ^^^^^^^^^^^
|
||||
note: required by a bound in `Trait::N`
|
||||
--> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:10:30
|
||||
--> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:9:35
|
||||
|
|
||||
LL | const N: i32 where Self: Bound;
|
||||
| ^^^^^ required by this bound in `Trait::N`
|
||||
LL | type const N: i32 where Self: Bound;
|
||||
| ^^^^^ required by this bound in `Trait::N`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -14,14 +14,12 @@
|
|||
|
||||
trait A {
|
||||
type Ty: std::marker::ConstParamTy_;
|
||||
#[type_const]
|
||||
const CT: Self::Ty;
|
||||
type const CT: Self::Ty;
|
||||
}
|
||||
|
||||
impl A for () {
|
||||
type Ty = i32;
|
||||
#[type_const]
|
||||
const CT: i32 = 0;
|
||||
type const CT: i32 = 0;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
error[E0277]: the trait bound `FreshTy(0): A` is not satisfied
|
||||
--> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:34:33
|
||||
--> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:32:33
|
||||
|
|
||||
LL | let _: dyn A<Ty = i32, CT = 0>;
|
||||
| ^ the trait `A` is not implemented for `FreshTy(0)`
|
||||
|
|
||||
help: the trait `A` is implemented for `()`
|
||||
--> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:21:1
|
||||
--> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:20:1
|
||||
|
|
||||
LL | impl A for () {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `FreshTy(0): A` is not satisfied
|
||||
--> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:36:34
|
||||
--> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:34:34
|
||||
|
|
||||
LL | let _: &dyn A<Ty = i32, CT = 0> = &();
|
||||
| ^ the trait `A` is not implemented for `FreshTy(0)`
|
||||
|
|
||||
help: the trait `A` is implemented for `()`
|
||||
--> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:21:1
|
||||
--> $DIR/dyn-compat-self-const-projections-in-assoc-const-ty.rs:20:1
|
||||
|
|
||||
LL | impl A for () {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -15,15 +15,13 @@
|
|||
#![expect(incomplete_features)]
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const N: usize;
|
||||
type const N: usize;
|
||||
|
||||
fn process(&self, _: [u8; Self::N]) -> [u8; Self::N];
|
||||
}
|
||||
|
||||
impl Trait for u8 {
|
||||
#[type_const]
|
||||
const N: usize = 2;
|
||||
type const N: usize = 2;
|
||||
|
||||
fn process(&self, [x, y]: [u8; Self::N]) -> [u8; Self::N] {
|
||||
[self * x, self + y]
|
||||
|
|
@ -31,8 +29,7 @@ impl Trait for u8 {
|
|||
}
|
||||
|
||||
impl<const N: usize> Trait for [u8; N] {
|
||||
#[type_const]
|
||||
const N: usize = N;
|
||||
type const N: usize = N;
|
||||
|
||||
fn process(&self, other: [u8; Self::N]) -> [u8; Self::N] {
|
||||
let mut result = [0; _];
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@
|
|||
|
||||
trait Trait: SuperTrait<{ Self::N }> {
|
||||
//~^ NOTE it uses `Self` as a type parameter
|
||||
#[type_const]
|
||||
const N: usize;
|
||||
type const N: usize;
|
||||
}
|
||||
|
||||
trait SuperTrait<const N: usize> {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0038]: the trait `Trait` is not dyn compatible
|
||||
--> $DIR/dyn-compat-self-const-projections-in-supertrait-bounds.rs:19:16
|
||||
--> $DIR/dyn-compat-self-const-projections-in-supertrait-bounds.rs:18:16
|
||||
|
|
||||
LL | let _: dyn Trait;
|
||||
| ^^^^^ `Trait` is not dyn compatible
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@
|
|||
#![crate_name = "sym"]
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const N: usize;
|
||||
type const N: usize;
|
||||
}
|
||||
|
||||
#[rustc_symbol_name]
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
error: symbol-name(_RMCsCRATE_HASH_3symDNtB<REF>_5Traitp1NKj0_EL_)
|
||||
--> $DIR/dyn-compat-symbol-mangling.rs:22:1
|
||||
--> $DIR/dyn-compat-symbol-mangling.rs:21:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling(<dyn sym[HASH]::Trait<N = 0usize>>)
|
||||
--> $DIR/dyn-compat-symbol-mangling.rs:22:1
|
||||
--> $DIR/dyn-compat-symbol-mangling.rs:21:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: demangling-alt(<dyn sym::Trait<N = 0>>)
|
||||
--> $DIR/dyn-compat-symbol-mangling.rs:22:1
|
||||
--> $DIR/dyn-compat-symbol-mangling.rs:21:1
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
#![expect(incomplete_features)]
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const K: usize;
|
||||
type const K: usize;
|
||||
}
|
||||
|
||||
// fn ctxt / body
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
error[E0191]: the value of the associated constant `K` in `Trait` must be specified
|
||||
--> $DIR/dyn-compat-unspecified-assoc-consts.rs:20:18
|
||||
--> $DIR/dyn-compat-unspecified-assoc-consts.rs:19:18
|
||||
|
|
||||
LL | const K: usize;
|
||||
| -------------- `K` defined here
|
||||
LL | type const K: usize;
|
||||
| ------------------- `K` defined here
|
||||
...
|
||||
LL | struct Store(dyn Trait);
|
||||
| ^^^^^ help: specify the associated constant: `Trait<K = /* CONST */>`
|
||||
|
||||
error[E0191]: the value of the associated constant `K` in `Trait` must be specified
|
||||
--> $DIR/dyn-compat-unspecified-assoc-consts.rs:24:21
|
||||
--> $DIR/dyn-compat-unspecified-assoc-consts.rs:23:21
|
||||
|
|
||||
LL | const K: usize;
|
||||
| -------------- `K` defined here
|
||||
LL | type const K: usize;
|
||||
| ------------------- `K` defined here
|
||||
...
|
||||
LL | type DynTrait = dyn Trait;
|
||||
| ^^^^^ help: specify the associated constant: `Trait<K = /* CONST */>`
|
||||
|
||||
error[E0191]: the value of the associated constant `K` in `Trait` must be specified
|
||||
--> $DIR/dyn-compat-unspecified-assoc-consts.rs:15:16
|
||||
--> $DIR/dyn-compat-unspecified-assoc-consts.rs:14:16
|
||||
|
|
||||
LL | const K: usize;
|
||||
| -------------- `K` defined here
|
||||
LL | type const K: usize;
|
||||
| ------------------- `K` defined here
|
||||
...
|
||||
LL | let _: dyn Trait;
|
||||
| ^^^^^ help: specify the associated constant: `Trait<K = /* CONST */>`
|
||||
|
|
|
|||
|
|
@ -5,42 +5,34 @@
|
|||
#![deny(dead_code)]
|
||||
|
||||
trait Tr {
|
||||
#[type_const]
|
||||
const I: i32;
|
||||
type const I: i32;
|
||||
}
|
||||
|
||||
impl Tr for () {
|
||||
#[type_const]
|
||||
const I: i32 = 1;
|
||||
type const I: i32 = 1;
|
||||
}
|
||||
|
||||
fn foo() -> impl Tr<I = 1> {}
|
||||
|
||||
trait Tr2 {
|
||||
#[type_const]
|
||||
const J: i32;
|
||||
#[type_const]
|
||||
const K: i32;
|
||||
type const J: i32;
|
||||
type const K: i32;
|
||||
}
|
||||
|
||||
impl Tr2 for () {
|
||||
#[type_const]
|
||||
const J: i32 = 1;
|
||||
#[type_const]
|
||||
const K: i32 = 1;
|
||||
type const J: i32 = 1;
|
||||
type const K: i32 = 1;
|
||||
}
|
||||
|
||||
fn foo2() -> impl Tr2<J = 1, K = 1> {}
|
||||
|
||||
mod t {
|
||||
pub trait Tr3 {
|
||||
#[type_const]
|
||||
const L: i32;
|
||||
type const L: i32;
|
||||
}
|
||||
|
||||
impl Tr3 for () {
|
||||
#[type_const]
|
||||
const L: i32 = 1;
|
||||
type const L: i32 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,13 +7,11 @@
|
|||
// though it contained inference variables, which would cause ICEs.
|
||||
|
||||
trait Foo {
|
||||
#[type_const]
|
||||
const ASSOC<const N: u32>: u32;
|
||||
type const ASSOC<const N: u32>: u32;
|
||||
}
|
||||
|
||||
impl Foo for () {
|
||||
#[type_const]
|
||||
const ASSOC<const N: u32>: u32 = N;
|
||||
type const ASSOC<const N: u32>: u32 = N;
|
||||
}
|
||||
|
||||
fn bar<const N: u32, T: Foo<ASSOC<N> = 10>>() {}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@
|
|||
#![allow(incomplete_features)]
|
||||
|
||||
trait Trait<'a> {
|
||||
#[type_const]
|
||||
const K: &'a ();
|
||||
type const K: &'a ();
|
||||
}
|
||||
|
||||
fn take(_: impl for<'r> Trait<'r, K = const { &() }>) {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: the type of the associated constant `K` cannot capture late-bound generic parameters
|
||||
--> $DIR/esc-bound-var-in-ty.rs:16:35
|
||||
--> $DIR/esc-bound-var-in-ty.rs:15:35
|
||||
|
|
||||
LL | fn take(_: impl for<'r> Trait<'r, K = const { &() }>) {}
|
||||
| -- ^ its type cannot capture the late-bound lifetime parameter `'r`
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ trait T {
|
|||
}
|
||||
|
||||
trait S {
|
||||
#[type_const]
|
||||
const C: i32;
|
||||
type const C: i32;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,11 @@
|
|||
#![expect(incomplete_features)]
|
||||
|
||||
trait Foo {
|
||||
#[type_const]
|
||||
const ASSOC<const N: u32>: u32;
|
||||
type const ASSOC<const N: u32>: u32;
|
||||
}
|
||||
|
||||
impl Foo for () {
|
||||
#[type_const]
|
||||
const ASSOC<const N: u32>: u32 = N;
|
||||
type const ASSOC<const N: u32>: u32 = N;
|
||||
}
|
||||
|
||||
fn bar<const N: u64, T: Foo<ASSOC<N> = { N }>>() {}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
error: the constant `N` is not of type `u32`
|
||||
--> $DIR/mismatched-types-with-generic-in-ace.rs:14:29
|
||||
--> $DIR/mismatched-types-with-generic-in-ace.rs:12:29
|
||||
|
|
||||
LL | fn bar<const N: u64, T: Foo<ASSOC<N> = { N }>>() {}
|
||||
| ^^^^^^^^^^^^^^^^ expected `u32`, found `u64`
|
||||
|
|
||||
note: required by a const generic parameter in `Foo::ASSOC`
|
||||
--> $DIR/mismatched-types-with-generic-in-ace.rs:6:17
|
||||
--> $DIR/mismatched-types-with-generic-in-ace.rs:5:22
|
||||
|
|
||||
LL | const ASSOC<const N: u32>: u32;
|
||||
| ^^^^^^^^^^^^ required by this const generic parameter in `Foo::ASSOC`
|
||||
LL | type const ASSOC<const N: u32>: u32;
|
||||
| ^^^^^^^^^^^^ required by this const generic parameter in `Foo::ASSOC`
|
||||
|
||||
error: the constant `10` is not of type `u32`
|
||||
--> $DIR/mismatched-types-with-generic-in-ace.rs:18:5
|
||||
--> $DIR/mismatched-types-with-generic-in-ace.rs:16:5
|
||||
|
|
||||
LL | bar::<10_u64, ()>();
|
||||
| ^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64`
|
||||
|
|
||||
note: required by a const generic parameter in `Foo::ASSOC`
|
||||
--> $DIR/mismatched-types-with-generic-in-ace.rs:6:17
|
||||
--> $DIR/mismatched-types-with-generic-in-ace.rs:5:22
|
||||
|
|
||||
LL | const ASSOC<const N: u32>: u32;
|
||||
| ^^^^^^^^^^^^ required by this const generic parameter in `Foo::ASSOC`
|
||||
LL | type const ASSOC<const N: u32>: u32;
|
||||
| ^^^^^^^^^^^^ required by this const generic parameter in `Foo::ASSOC`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
// with associated const equality bounds.
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const C: usize;
|
||||
type const C: usize;
|
||||
}
|
||||
|
||||
fn f<T: Trait<C = 1>>() {
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@
|
|||
use std::marker::ConstParamTy_;
|
||||
|
||||
trait Trait<'a, T: 'a + ConstParamTy_, const N: usize> {
|
||||
#[type_const]
|
||||
const K: &'a [T; N];
|
||||
type const K: &'a [T; N];
|
||||
}
|
||||
|
||||
fn take0<'r, A: 'r + ConstParamTy_, const Q: usize>(
|
||||
|
|
@ -32,8 +31,7 @@ fn take0<'r, A: 'r + ConstParamTy_, const Q: usize>(
|
|||
) {}
|
||||
|
||||
trait Project: ConstParamTy_ {
|
||||
#[type_const]
|
||||
const SELF: Self;
|
||||
type const SELF: Self;
|
||||
}
|
||||
|
||||
fn take1(_: impl Project<SELF = const {}>) {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: the type of the associated constant `K` must not depend on generic parameters
|
||||
--> $DIR/param-in-ty.rs:22:29
|
||||
--> $DIR/param-in-ty.rs:21:29
|
||||
|
|
||||
LL | fn take0<'r, A: 'r + ConstParamTy_, const Q: usize>(
|
||||
| -- the lifetime parameter `'r` is defined here
|
||||
|
|
@ -10,7 +10,7 @@ LL | _: impl Trait<'r, A, Q, K = const { loop {} }>
|
|||
= note: `K` has type `&'r [A; Q]`
|
||||
|
||||
error: the type of the associated constant `K` must not depend on generic parameters
|
||||
--> $DIR/param-in-ty.rs:22:29
|
||||
--> $DIR/param-in-ty.rs:21:29
|
||||
|
|
||||
LL | fn take0<'r, A: 'r + ConstParamTy_, const Q: usize>(
|
||||
| - the type parameter `A` is defined here
|
||||
|
|
@ -21,7 +21,7 @@ LL | _: impl Trait<'r, A, Q, K = const { loop {} }>
|
|||
= note: `K` has type `&'r [A; Q]`
|
||||
|
||||
error: the type of the associated constant `K` must not depend on generic parameters
|
||||
--> $DIR/param-in-ty.rs:22:29
|
||||
--> $DIR/param-in-ty.rs:21:29
|
||||
|
|
||||
LL | fn take0<'r, A: 'r + ConstParamTy_, const Q: usize>(
|
||||
| - the const parameter `Q` is defined here
|
||||
|
|
@ -32,7 +32,7 @@ LL | _: impl Trait<'r, A, Q, K = const { loop {} }>
|
|||
= note: `K` has type `&'r [A; Q]`
|
||||
|
||||
error: the type of the associated constant `SELF` must not depend on `impl Trait`
|
||||
--> $DIR/param-in-ty.rs:39:26
|
||||
--> $DIR/param-in-ty.rs:37:26
|
||||
|
|
||||
LL | fn take1(_: impl Project<SELF = const {}>) {}
|
||||
| -------------^^^^------------
|
||||
|
|
@ -41,7 +41,7 @@ LL | fn take1(_: impl Project<SELF = const {}>) {}
|
|||
| the `impl Trait` is specified here
|
||||
|
||||
error: the type of the associated constant `SELF` must not depend on generic parameters
|
||||
--> $DIR/param-in-ty.rs:44:21
|
||||
--> $DIR/param-in-ty.rs:42:21
|
||||
|
|
||||
LL | fn take2<P: Project<SELF = const {}>>(_: P) {}
|
||||
| - ^^^^ its type must not depend on the type parameter `P`
|
||||
|
|
@ -51,7 +51,7 @@ LL | fn take2<P: Project<SELF = const {}>>(_: P) {}
|
|||
= note: `SELF` has type `P`
|
||||
|
||||
error: the type of the associated constant `K` must not depend on generic parameters
|
||||
--> $DIR/param-in-ty.rs:53:52
|
||||
--> $DIR/param-in-ty.rs:51:52
|
||||
|
|
||||
LL | trait Iface<'r>: ConstParamTy_ {
|
||||
| -- the lifetime parameter `'r` is defined here
|
||||
|
|
@ -62,7 +62,7 @@ LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
|
|||
= note: `K` has type `&'r [Self; Q]`
|
||||
|
||||
error: the type of the associated constant `K` must not depend on `Self`
|
||||
--> $DIR/param-in-ty.rs:53:52
|
||||
--> $DIR/param-in-ty.rs:51:52
|
||||
|
|
||||
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
|
||||
| ^ its type must not depend on `Self`
|
||||
|
|
@ -70,7 +70,7 @@ LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
|
|||
= note: `K` has type `&'r [Self; Q]`
|
||||
|
||||
error: the type of the associated constant `K` must not depend on generic parameters
|
||||
--> $DIR/param-in-ty.rs:53:52
|
||||
--> $DIR/param-in-ty.rs:51:52
|
||||
|
|
||||
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
|
||||
| - ^ its type must not depend on the const parameter `Q`
|
||||
|
|
@ -80,7 +80,7 @@ LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
|
|||
= note: `K` has type `&'r [Self; Q]`
|
||||
|
||||
error: the type of the associated constant `K` must not depend on generic parameters
|
||||
--> $DIR/param-in-ty.rs:53:52
|
||||
--> $DIR/param-in-ty.rs:51:52
|
||||
|
|
||||
LL | trait Iface<'r>: ConstParamTy_ {
|
||||
| -- the lifetime parameter `'r` is defined here
|
||||
|
|
@ -92,7 +92,7 @@ LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
|
|||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: the type of the associated constant `K` must not depend on `Self`
|
||||
--> $DIR/param-in-ty.rs:53:52
|
||||
--> $DIR/param-in-ty.rs:51:52
|
||||
|
|
||||
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
|
||||
| ^ its type must not depend on `Self`
|
||||
|
|
@ -101,7 +101,7 @@ LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
|
|||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: the type of the associated constant `K` must not depend on generic parameters
|
||||
--> $DIR/param-in-ty.rs:53:52
|
||||
--> $DIR/param-in-ty.rs:51:52
|
||||
|
|
||||
LL | type Assoc<const Q: usize>: Trait<'r, Self, Q, K = const { loop {} }>
|
||||
| - ^ its type must not depend on the const parameter `Q`
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
// Issue 110549
|
||||
|
||||
pub trait TraitWAssocConst {
|
||||
#[type_const]
|
||||
const A: usize;
|
||||
type const A: usize;
|
||||
}
|
||||
|
||||
fn foo<T: TraitWAssocConst<A = 32>>() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0271]: type mismatch resolving `<T as TraitWAssocConst>::A == 32`
|
||||
--> $DIR/projection-unspecified-but-bounded.rs:14:11
|
||||
--> $DIR/projection-unspecified-but-bounded.rs:13:11
|
||||
|
|
||||
LL | foo::<T>();
|
||||
| ^ expected `32`, found `<T as TraitWAssocConst>::A`
|
||||
|
|
@ -7,7 +7,7 @@ LL | foo::<T>();
|
|||
= note: expected constant `32`
|
||||
found constant `<T as TraitWAssocConst>::A`
|
||||
note: required by a bound in `foo`
|
||||
--> $DIR/projection-unspecified-but-bounded.rs:11:28
|
||||
--> $DIR/projection-unspecified-but-bounded.rs:10:28
|
||||
|
|
||||
LL | fn foo<T: TraitWAssocConst<A = 32>>() {}
|
||||
| ^^^^^^ required by this bound in `foo`
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ use std::marker::ConstParamTy_;
|
|||
trait Trait: SuperTrait {}
|
||||
trait SuperTrait: SuperSuperTrait<i32> {}
|
||||
trait SuperSuperTrait<T: ConstParamTy_> {
|
||||
#[type_const]
|
||||
const K: T;
|
||||
type const K: T;
|
||||
}
|
||||
|
||||
fn take(_: impl Trait<K = 0>) {}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#![feature(min_generic_const_args)]
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const F: fn();
|
||||
type const F: fn();
|
||||
//~^ ERROR using function pointers as const generic parameters is forbidden
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0741]: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/using-fnptr-as-type_const.rs:8:14
|
||||
--> $DIR/using-fnptr-as-type_const.rs:7:19
|
||||
|
|
||||
LL | const F: fn();
|
||||
| ^^^^
|
||||
LL | type const F: fn();
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#![feature(min_generic_const_args)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
#[type_const]
|
||||
pub const NON_LOCAL_CONST: char = 'a';
|
||||
pub type const NON_LOCAL_CONST: char = 'a';
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ use Option::Some;
|
|||
|
||||
fn foo<const N: Option<u32>>() {}
|
||||
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const ASSOC: u32;
|
||||
type const ASSOC: u32;
|
||||
}
|
||||
|
||||
fn bar<T: Trait, const N: u32>() {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#![feature(min_generic_const_args, adt_const_params, unsized_const_params)]
|
||||
#![expect(incomplete_features)]
|
||||
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const ASSOC: usize;
|
||||
type const ASSOC: usize;
|
||||
}
|
||||
|
||||
fn takes_tuple<const A: (u32, u32)>() {}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ struct Foo<T> {
|
|||
field: T,
|
||||
}
|
||||
|
||||
#[type_const]
|
||||
const WRAP<T: ConstParamTy_, const N: T>: Foo<T> = { Foo::<T> {
|
||||
type const WRAP<T: ConstParamTy_, const N: T>: Foo<T> = { Foo::<T> {
|
||||
field: N,
|
||||
} };
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
fn takes_array<const A: [u32; 3]>() {}
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const ASSOC: u32;
|
||||
type const ASSOC: u32;
|
||||
}
|
||||
|
||||
fn generic_caller<T: Trait, const N: u32>() {
|
||||
|
|
|
|||
|
|
@ -7,13 +7,11 @@
|
|||
trait Abc {}
|
||||
|
||||
trait A {
|
||||
#[type_const]
|
||||
const VALUE: usize;
|
||||
type const VALUE: usize;
|
||||
}
|
||||
|
||||
impl<T: Abc> A for T {
|
||||
#[type_const]
|
||||
const VALUE: usize = 0;
|
||||
type const VALUE: usize = 0;
|
||||
}
|
||||
|
||||
trait S<const K: usize> {}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ pub trait Tr {
|
|||
}
|
||||
|
||||
fn mk_array<T: Tr>(_x: T) -> [(); T::SIZE] {
|
||||
//~^ ERROR type_const
|
||||
//~^ ERROR: use of `const` in the type system not defined as `type const`
|
||||
[(); T::SIZE]
|
||||
//~^ ERROR type_const
|
||||
//~^ ERROR: use of `const` in the type system not defined as `type const`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,20 @@
|
|||
error: use of `const` in the type system without `#[type_const]`
|
||||
error: use of `const` in the type system not defined as `type const`
|
||||
--> $DIR/assoc-const-without-type_const.rs:8:35
|
||||
|
|
||||
LL | const SIZE: usize;
|
||||
| - help: add `type` before `const` for `Tr::SIZE`: `type`
|
||||
...
|
||||
LL | fn mk_array<T: Tr>(_x: T) -> [(); T::SIZE] {
|
||||
| ^^^^^^^
|
||||
|
|
||||
help: add `#[type_const]` attribute to `Tr::SIZE`
|
||||
|
|
||||
LL + #[type_const]
|
||||
LL | const SIZE: usize;
|
||||
|
|
||||
|
||||
error: use of `const` in the type system without `#[type_const]`
|
||||
error: use of `const` in the type system not defined as `type const`
|
||||
--> $DIR/assoc-const-without-type_const.rs:10:10
|
||||
|
|
||||
LL | const SIZE: usize;
|
||||
| - help: add `type` before `const` for `Tr::SIZE`: `type`
|
||||
...
|
||||
LL | [(); T::SIZE]
|
||||
| ^^^^^^^
|
||||
|
|
||||
help: add `#[type_const]` attribute to `Tr::SIZE`
|
||||
|
|
||||
LL + #[type_const]
|
||||
LL | const SIZE: usize;
|
||||
|
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#![allow(incomplete_features)]
|
||||
|
||||
pub trait Tr<X> {
|
||||
#[type_const]
|
||||
const SIZE: usize;
|
||||
type const SIZE: usize;
|
||||
}
|
||||
|
||||
fn mk_array<T: Tr<bool>>(_x: T) -> [(); <T as Tr<bool>>::SIZE] {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
trait Tr {
|
||||
#[type_const()]
|
||||
//~^ ERROR malformed
|
||||
//~| ERROR experimental
|
||||
const N: usize;
|
||||
type const N: usize;
|
||||
//~^ ERROR: `type const` syntax is experimental [E0658]
|
||||
//~| ERROR: associated `type const` are unstable [E0658]
|
||||
}
|
||||
|
||||
struct S;
|
||||
|
||||
impl Tr for S {
|
||||
#[type_const]
|
||||
//~^ ERROR experimental
|
||||
const N: usize = 0;
|
||||
|
||||
type const N: usize = 0;
|
||||
//~^ ERROR: `type const` syntax is experimental [E0658]
|
||||
//~| ERROR: associated `type const` are unstable [E0658]
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,33 +1,43 @@
|
|||
error[E0658]: the `#[type_const]` attribute is an experimental feature
|
||||
error[E0658]: `type const` syntax is experimental
|
||||
--> $DIR/bad-type_const-syntax.rs:2:5
|
||||
|
|
||||
LL | #[type_const()]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
LL | type const N: usize;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
|
||||
= help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: the `#[type_const]` attribute is an experimental feature
|
||||
error[E0658]: `type const` syntax is experimental
|
||||
--> $DIR/bad-type_const-syntax.rs:11:5
|
||||
|
|
||||
LL | #[type_const]
|
||||
| ^^^^^^^^^^^^^
|
||||
LL | type const N: usize = 0;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
|
||||
= help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0565]: malformed `type_const` attribute input
|
||||
error[E0658]: associated `type const` are unstable
|
||||
--> $DIR/bad-type_const-syntax.rs:2:5
|
||||
|
|
||||
LL | #[type_const()]
|
||||
| ^^^^^^^^^^^^--^
|
||||
| | |
|
||||
| | didn't expect any arguments here
|
||||
| help: must be of the form: `#[type_const]`
|
||||
LL | type const N: usize;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
|
||||
= help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error[E0658]: associated `type const` are unstable
|
||||
--> $DIR/bad-type_const-syntax.rs:11:5
|
||||
|
|
||||
LL | type const N: usize = 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
|
||||
= help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
Some errors have detailed explanations: E0565, E0658.
|
||||
For more information about an error, try `rustc --explain E0565`.
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
|
|||
|
|
@ -4,23 +4,17 @@
|
|||
#![feature(min_generic_const_args, generic_const_items)]
|
||||
|
||||
pub trait Tr<const X: usize> {
|
||||
#[type_const]
|
||||
const N1<T>: usize;
|
||||
#[type_const]
|
||||
const N2<const I: usize>: usize;
|
||||
#[type_const]
|
||||
const N3: usize;
|
||||
type const N1<T>: usize;
|
||||
type const N2<const I: usize>: usize;
|
||||
type const N3: usize;
|
||||
}
|
||||
|
||||
pub struct S;
|
||||
|
||||
impl<const X: usize> Tr<X> for S {
|
||||
#[type_const]
|
||||
const N1<T>: usize = 0;
|
||||
#[type_const]
|
||||
const N2<const I: usize>: usize = 1;
|
||||
#[type_const]
|
||||
const N3: usize = 2;
|
||||
type const N1<T>: usize = 0;
|
||||
type const N2<const I: usize>: usize = 1;
|
||||
type const N3: usize = 2;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
#![expect(incomplete_features)]
|
||||
#![feature(min_generic_const_args)]
|
||||
|
||||
#[type_const]
|
||||
const C: usize = 0;
|
||||
|
||||
type const C: usize = 0;
|
||||
pub struct A<const M: usize> {}
|
||||
impl A<C> {
|
||||
fn fun1() {}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#![feature(generic_const_exprs)]
|
||||
#![expect(incomplete_features)]
|
||||
|
||||
#[type_const]
|
||||
const A: u8 = A;
|
||||
type const A: u8 = A;
|
||||
//~^ ERROR overflow normalizing the unevaluated constant `A`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0275]: overflow normalizing the unevaluated constant `A`
|
||||
--> $DIR/cyclic-type-const-151251.rs:8:1
|
||||
--> $DIR/cyclic-type-const-151251.rs:7:1
|
||||
|
|
||||
LL | const A: u8 = A;
|
||||
| ^^^^^^^^^^^
|
||||
LL | type const A: u8 = A;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: in case this is a recursive type alias, consider using a struct, enum, or union instead
|
||||
|
||||
|
|
|
|||
|
|
@ -34,22 +34,22 @@ fn repeats<const N: usize>() -> [(); N] {
|
|||
//~^ ERROR: generic parameters may not be used in const operations
|
||||
}
|
||||
|
||||
#[type_const]
|
||||
const ITEM1<const N: usize>: usize = N;
|
||||
#[type_const]
|
||||
const ITEM2<const N: usize>: usize = { N };
|
||||
#[type_const]
|
||||
const ITEM3<const N: usize>: usize = const { N };
|
||||
|
||||
type const ITEM1<const N: usize>: usize = N;
|
||||
|
||||
type const ITEM2<const N: usize>: usize = { N };
|
||||
|
||||
type const ITEM3<const N: usize>: usize = const { N };
|
||||
//~^ ERROR: generic parameters may not be used in const operations
|
||||
#[type_const]
|
||||
const ITEM4<const N: usize>: usize = { 1 + 1 };
|
||||
|
||||
type const ITEM4<const N: usize>: usize = { 1 + 1 };
|
||||
//~^ ERROR: complex const arguments must be placed inside of a `const` block
|
||||
#[type_const]
|
||||
const ITEM5<const N: usize>: usize = const { 1 + 1};
|
||||
|
||||
type const ITEM5<const N: usize>: usize = const { 1 + 1};
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const ASSOC: usize;
|
||||
|
||||
type const ASSOC: usize;
|
||||
}
|
||||
|
||||
fn ace_bounds<
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ LL | let _4 = [(); 1 + 1];
|
|||
| ^^^^^
|
||||
|
||||
error: complex const arguments must be placed inside of a `const` block
|
||||
--> $DIR/explicit_anon_consts.rs:45:38
|
||||
--> $DIR/explicit_anon_consts.rs:45:43
|
||||
|
|
||||
LL | const ITEM4<const N: usize>: usize = { 1 + 1 };
|
||||
| ^^^^^^^^^
|
||||
LL | type const ITEM4<const N: usize>: usize = { 1 + 1 };
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: complex const arguments must be placed inside of a `const` block
|
||||
--> $DIR/explicit_anon_consts.rs:62:23
|
||||
|
|
@ -35,10 +35,10 @@ LL | struct Default4<const N: usize, const M: usize = { 1 + 1 }>;
|
|||
| ^^^^^^^^^
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/explicit_anon_consts.rs:42:46
|
||||
--> $DIR/explicit_anon_consts.rs:42:51
|
||||
|
|
||||
LL | const ITEM3<const N: usize>: usize = const { N };
|
||||
| ^
|
||||
LL | type const ITEM3<const N: usize>: usize = const { N };
|
||||
| ^
|
||||
|
|
||||
= help: add `#![feature(opaque_generic_const_args)]` to allow generic expressions as the RHS of const items
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#![expect(incomplete_features)]
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const ASSOC: isize;
|
||||
type const ASSOC: isize;
|
||||
}
|
||||
|
||||
fn ace<T: Trait<ASSOC = 1, ASSOC = -1>>() {}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
struct Foo<const N: usize>;
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const ASSOC: usize;
|
||||
type const ASSOC: usize;
|
||||
}
|
||||
|
||||
type Arr<const N: usize> = [(); {{{ N }}}];
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@
|
|||
extern crate non_local_const;
|
||||
fn main() {
|
||||
let x = [(); non_local_const::N];
|
||||
//~^ ERROR use of `const` in the type system without `#[type_const]`
|
||||
//~^ ERROR: use of `const` in the type system not defined as `type const`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error: use of `const` in the type system without `#[type_const]`
|
||||
error: use of `const` in the type system not defined as `type const`
|
||||
--> $DIR/non-local-const-without-type_const.rs:7:18
|
||||
|
|
||||
LL | let x = [(); non_local_const::N];
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only consts marked with `#[type_const]` may be used in types
|
||||
= note: only consts marked defined as `type const` may be used in types
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
struct Foo;
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const ASSOC: u32;
|
||||
|
||||
type const ASSOC: u32;
|
||||
}
|
||||
|
||||
fn foo<const N: Foo>() {}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,8 @@
|
|||
// containing erroneous types normalizes to a const error instead of
|
||||
// a type error.
|
||||
|
||||
|
||||
pub trait Tr<A> {
|
||||
#[type_const]
|
||||
const SIZE: usize;
|
||||
type const SIZE: usize;
|
||||
}
|
||||
|
||||
fn mk_array(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0425]: cannot find type `T` in this scope
|
||||
--> $DIR/projection-error.rs:14:17
|
||||
--> $DIR/projection-error.rs:12:17
|
||||
|
|
||||
LL | pub trait Tr<A> {
|
||||
| --------------- similarly named trait `Tr` defined here
|
||||
|
|
@ -17,7 +17,7 @@ LL | fn mk_array<T>(_x: T) -> [(); <T as Tr<bool>>::SIZE] {}
|
|||
| +++
|
||||
|
||||
error[E0425]: cannot find type `T` in this scope
|
||||
--> $DIR/projection-error.rs:14:29
|
||||
--> $DIR/projection-error.rs:12:29
|
||||
|
|
||||
LL | pub trait Tr<A> {
|
||||
| --------------- similarly named trait `Tr` defined here
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ enum MyEnum<T> {
|
|||
}
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const ASSOC: u32;
|
||||
type const ASSOC: u32;
|
||||
}
|
||||
|
||||
fn with_point<const P: Point>() -> Point {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ enum MyEnum<T> {
|
|||
Unit,
|
||||
}
|
||||
|
||||
#[type_const]
|
||||
const CONST_ITEM: u32 = 42;
|
||||
|
||||
type const CONST_ITEM: u32 = 42;
|
||||
|
||||
fn accepts_point<const P: Point>() {}
|
||||
fn accepts_enum<const E: MyEnum<u32>>() {}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
#![expect(incomplete_features)]
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const ASSOC: usize;
|
||||
|
||||
type const ASSOC: usize;
|
||||
}
|
||||
|
||||
fn takes_tuple<const A: (u32, u32)>() {}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#![expect(incomplete_features)]
|
||||
|
||||
trait Trait {
|
||||
#[type_const]
|
||||
const ASSOC: u32;
|
||||
type const ASSOC: u32;
|
||||
}
|
||||
|
||||
fn takes_tuple<const A: (u32, u32)>() {}
|
||||
|
|
|
|||
|
|
@ -4,15 +4,13 @@
|
|||
#![expect(incomplete_features)]
|
||||
|
||||
trait Tr {
|
||||
#[type_const]
|
||||
const SIZE: usize;
|
||||
type const SIZE: usize;
|
||||
}
|
||||
|
||||
struct T;
|
||||
|
||||
impl Tr for T {
|
||||
#[type_const]
|
||||
const SIZE: usize;
|
||||
type const SIZE: usize;
|
||||
//~^ ERROR associated constant in `impl` without body
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error: associated constant in `impl` without body
|
||||
--> $DIR/type-const-assoc-const-without-body.rs:15:5
|
||||
--> $DIR/type-const-assoc-const-without-body.rs:13:5
|
||||
|
|
||||
LL | const SIZE: usize;
|
||||
| ^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| help: provide a definition for the constant: `= <expr>;`
|
||||
LL | type const SIZE: usize;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| help: provide a definition for the constant: `= <expr>;`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#![expect(incomplete_features)]
|
||||
|
||||
impl S { //~ ERROR cannot find type `S` in this scope
|
||||
#[type_const]
|
||||
const SIZE: usize;
|
||||
type const SIZE: usize;
|
||||
//~^ ERROR associated constant in `impl` without body
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error: associated constant in `impl` without body
|
||||
--> $DIR/type-const-inherent-assoc-const-without-body.rs:8:5
|
||||
--> $DIR/type-const-inherent-assoc-const-without-body.rs:7:5
|
||||
|
|
||||
LL | const SIZE: usize;
|
||||
| ^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| help: provide a definition for the constant: `= <expr>;`
|
||||
LL | type const SIZE: usize;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^-
|
||||
| |
|
||||
| help: provide a definition for the constant: `= <expr>;`
|
||||
|
||||
error[E0425]: cannot find type `S` in this scope
|
||||
--> $DIR/type-const-inherent-assoc-const-without-body.rs:6:6
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
#![feature(min_generic_const_args)]
|
||||
#![expect(incomplete_features)]
|
||||
|
||||
#[type_const]
|
||||
const N: usize = 2;
|
||||
type const N: usize = 2;
|
||||
|
||||
trait CollectArray<A> {
|
||||
fn inner_array(&mut self) -> [A; N];
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue