bless tests

This commit is contained in:
Deadbeef 2022-08-28 06:27:31 +00:00
parent 08ac185e99
commit 1bcc26a6b1
55 changed files with 241 additions and 176 deletions

View file

@ -2,6 +2,7 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Func<T> {
type Output;

View file

@ -3,6 +3,7 @@
#![allow(incomplete_features)]
#![feature(const_trait_impl, generic_const_exprs)]
#[const_trait]
trait ConstName {
const NAME_BYTES: &'static [u8];
}

View file

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

View file

@ -1,5 +1,5 @@
error[E0046]: not all trait items implemented, missing: `N`
--> $DIR/issue-98629.rs:7:1
--> $DIR/issue-98629.rs:8:1
|
LL | const N: usize;
| -------------- `N` from trait

View file

@ -4,13 +4,13 @@ error[E0308]: mismatched types
LL | = [0; (i8::MAX + 1u8) as usize];
| ^^^ expected `i8`, found `u8`
error[E0277]: cannot add `u8` to `i8`
error[E0277]: cannot add `u8` to `i8` in const contexts
--> $DIR/const-eval-overflow-3b.rs:16:20
|
LL | = [0; (i8::MAX + 1u8) as usize];
| ^ no implementation for `i8 + u8`
|
= help: the trait `Add<u8>` is not implemented for `i8`
= help: the trait `~const Add<u8>` is not implemented for `i8`
= help: the following other types implement trait `Add<Rhs>`:
<&'a f32 as Add<f32>>
<&'a f64 as Add<f64>>

View file

@ -4,13 +4,13 @@ error[E0308]: mismatched types
LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
| ^^^ expected `i8`, found `u8`
error[E0277]: cannot add `u8` to `i8`
error[E0277]: cannot add `u8` to `i8` in const contexts
--> $DIR/const-eval-overflow-4b.rs:9:28
|
LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
| ^ no implementation for `i8 + u8`
|
= help: the trait `Add<u8>` is not implemented for `i8`
= help: the trait `~const Add<u8>` is not implemented for `i8`
= help: the following other types implement trait `Add<Rhs>`:
<&'a f32 as Add<f32>>
<&'a f64 as Add<f64>>

View file

@ -3,9 +3,7 @@ const X : usize = 2;
const fn f(x: usize) -> usize {
let mut sum = 0;
for i in 0..x {
//~^ ERROR mutable references
//~| ERROR cannot convert
//~| ERROR cannot call non-const fn
//~^ ERROR the trait bound
//~| ERROR `for` is not allowed in a `const fn`
sum += i;
}

View file

@ -4,8 +4,6 @@ error[E0658]: `for` is not allowed in a `const fn`
LL | / for i in 0..x {
LL | |
LL | |
LL | |
LL | |
LL | | sum += i;
LL | | }
| |_____^
@ -13,37 +11,25 @@ LL | | }
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
= help: add `#![feature(const_for)]` to the crate attributes to enable
error[E0015]: cannot convert `std::ops::Range<usize>` into an iterator in constant functions
error[E0277]: the trait bound `std::ops::Range<usize>: Iterator` is not satisfied
--> $DIR/const-fn-error.rs:5:14
|
LL | for i in 0..x {
| ^^^^ `std::ops::Range<usize>` is not an iterator
|
= help: the trait `~const Iterator` is not implemented for `std::ops::Range<usize>`
note: the trait `Iterator` is implemented for `std::ops::Range<usize>`, but that implementation is not `const`
--> $DIR/const-fn-error.rs:5:14
|
LL | for i in 0..x {
| ^^^^
= note: required for `std::ops::Range<usize>` to implement `~const IntoIterator`
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
LL | impl<I: ~const Iterator> const IntoIterator for I {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
LL | const fn f(x: usize) -> usize where std::ops::Range<usize>: ~const Iterator {
| +++++++++++++++++++++++++++++++++++++++++++++
error[E0658]: mutable references are not allowed in constant functions
--> $DIR/const-fn-error.rs:5:14
|
LL | for i in 0..x {
| ^^^^
|
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error: aborting due to 2 previous errors
error[E0015]: cannot call non-const fn `<std::ops::Range<usize> as Iterator>::next` in constant functions
--> $DIR/const-fn-error.rs:5:14
|
LL | for i in 0..x {
| ^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0015, E0658.
For more information about an error, try `rustc --explain E0015`.
Some errors have detailed explanations: E0277, E0658.
For more information about an error, try `rustc --explain E0277`.

View file

@ -3,6 +3,7 @@
const _: () = {
for _ in 0..5 {}
//~^ error: `for` is not allowed in a `const`
//~| error: the trait bound
};
fn main() {}

View file

@ -7,6 +7,21 @@ LL | for _ in 0..5 {}
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
= help: add `#![feature(const_for)]` to the crate attributes to enable
error: aborting due to previous error
error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied
--> $DIR/const-for-feature-gate.rs:4:14
|
LL | for _ in 0..5 {}
| ^^^^ `std::ops::Range<{integer}>` is not an iterator
|
= help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>`
note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const`
--> $DIR/const-for-feature-gate.rs:4:14
|
LL | for _ in 0..5 {}
| ^^^^
= note: required for `std::ops::Range<{integer}>` to implement `~const IntoIterator`
For more information about this error, try `rustc --explain E0658`.
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0277, E0658.
For more information about an error, try `rustc --explain E0277`.

View file

@ -3,8 +3,7 @@
const _: () = {
for _ in 0..5 {}
//~^ error: cannot convert
//~| error: cannot call non-const fn
//~^ error: the trait bound
};
fn main() {}

View file

@ -1,24 +1,17 @@
error[E0015]: cannot convert `std::ops::Range<i32>` into an iterator in constants
error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied
--> $DIR/const-for.rs:5:14
|
LL | for _ in 0..5 {}
| ^^^^ `std::ops::Range<{integer}>` is not an iterator
|
= help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>`
note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const`
--> $DIR/const-for.rs:5:14
|
LL | for _ in 0..5 {}
| ^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
LL | impl<I: ~const Iterator> const IntoIterator for I {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= note: required for `std::ops::Range<{integer}>` to implement `~const IntoIterator`
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
--> $DIR/const-for.rs:5:14
|
LL | for _ in 0..5 {}
| ^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0015`.
For more information about this error, try `rustc --explain E0277`.

View file

@ -51,10 +51,12 @@ const _: i32 = {
let mut x = 0;
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
//~^ ERROR the trait bound
x += i;
}
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
//~^ ERROR the trait bound
x += i;
}

View file

@ -2,6 +2,7 @@ error[E0658]: `for` is not allowed in a `const`
--> $DIR/loop.rs:53:5
|
LL | / for i in 0..4 {
LL | |
LL | | x += i;
LL | | }
| |_____^
@ -10,9 +11,10 @@ LL | | }
= help: add `#![feature(const_for)]` to the crate attributes to enable
error[E0658]: `for` is not allowed in a `const`
--> $DIR/loop.rs:57:5
--> $DIR/loop.rs:58:5
|
LL | / for i in 0..4 {
LL | |
LL | | x += i;
LL | | }
| |_____^
@ -20,6 +22,35 @@ LL | | }
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
= help: add `#![feature(const_for)]` to the crate attributes to enable
error: aborting due to 2 previous errors
error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied
--> $DIR/loop.rs:53:14
|
LL | for i in 0..4 {
| ^^^^ `std::ops::Range<{integer}>` is not an iterator
|
= help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>`
note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const`
--> $DIR/loop.rs:53:14
|
LL | for i in 0..4 {
| ^^^^
= note: required for `std::ops::Range<{integer}>` to implement `~const IntoIterator`
For more information about this error, try `rustc --explain E0658`.
error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied
--> $DIR/loop.rs:58:14
|
LL | for i in 0..4 {
| ^^^^ `std::ops::Range<{integer}>` is not an iterator
|
= help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>`
note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const`
--> $DIR/loop.rs:58:14
|
LL | for i in 0..4 {
| ^^^^
= note: required for `std::ops::Range<{integer}>` to implement `~const IntoIterator`
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0277, E0658.
For more information about an error, try `rustc --explain E0277`.

View file

@ -7,9 +7,8 @@ struct Foo<'a> {
impl<'a> Foo<'a> {
const fn spam(&mut self, baz: &mut Vec<u32>) {
self.bar[0] = baz.len();
//~^ ERROR cannot call non-const fn `Vec::<u32>::len` in constant functions
//~| ERROR the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied
//~| ERROR cannot call non-const operator in constant functions
//~^ the trait bound `Vec<usize>: ~const Index<_>` is not satisfied
//~| the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied
}
}

View file

@ -1,10 +1,15 @@
error[E0015]: cannot call non-const fn `Vec::<u32>::len` in constant functions
--> $DIR/issue-94675.rs:9:27
error[E0277]: the trait bound `Vec<usize>: ~const Index<_>` is not satisfied
--> $DIR/issue-94675.rs:9:9
|
LL | self.bar[0] = baz.len();
| ^^^^^
| ^^^^^^^^^^^ vector indices are of type `usize` or ranges of `usize`
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= help: the trait `~const Index<_>` is not implemented for `Vec<usize>`
note: the trait `Index<_>` is implemented for `Vec<usize>`, but that implementation is not `const`
--> $DIR/issue-94675.rs:9:9
|
LL | self.bar[0] = baz.len();
| ^^^^^^^^^^^
error[E0277]: the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied
--> $DIR/issue-94675.rs:9:9
@ -18,21 +23,11 @@ note: the trait `IndexMut<usize>` is implemented for `Vec<usize>`, but that impl
|
LL | self.bar[0] = baz.len();
| ^^^^^^^^^^^
error[E0015]: cannot call non-const operator in constant functions
--> $DIR/issue-94675.rs:9:9
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | self.bar[0] = baz.len();
| ^^^^^^^^^^^
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
|
LL | impl<T, I: SliceIndex<[T]>, A: Allocator> IndexMut<I> for Vec<T, A> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
LL | impl<'a> Foo<'a> where Vec<usize>: ~const IndexMut<usize> {
| ++++++++++++++++++++++++++++++++++++++++
error: aborting due to 3 previous errors
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.
For more information about this error, try `rustc --explain E0277`.

View file

@ -15,13 +15,13 @@ help: Unicode character '' (Minus Sign) looks like '-' (Minus/Hyphen), but it
LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e-11; // m³⋅kg⁻¹⋅s⁻²
| ~
error[E0277]: cannot subtract `{integer}` from `{float}`
error[E0277]: cannot subtract `{integer}` from `{float}` in const contexts
--> $DIR/issue-49746-unicode-confusable-in-float-literal-expt.rs:1:53
|
LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e11; // m³⋅kg⁻¹⋅s⁻²
| ^ no implementation for `{float} - {integer}`
|
= help: the trait `Sub<{integer}>` is not implemented for `{float}`
= help: the trait `~const Sub<{integer}>` is not implemented for `{float}`
= help: the following other types implement trait `Sub<Rhs>`:
<&'a f32 as Sub<f32>>
<&'a f64 as Sub<f64>>

View file

@ -2,7 +2,7 @@ error[E0277]: the size for values of type `dyn Iterator<Item = &'a mut u8>` cann
--> $DIR/issue-20605.rs:2:17
|
LL | for item in *things { *item = 0 }
| ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator<Item = &'a mut u8>`
| ^^^^^^^ the trait `~const IntoIterator` is not implemented for `dyn Iterator<Item = &'a mut u8>`
|
= note: the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied
= note: required for `dyn Iterator<Item = &'a mut u8>` to implement `IntoIterator`

View file

@ -2,7 +2,7 @@ struct A;
struct B;
static S: &'static B = &A;
//~^ ERROR cannot perform deref coercion on `A` in statics
//~^ ERROR the trait bound
use std::ops::Deref;

View file

@ -1,23 +1,15 @@
error[E0015]: cannot perform deref coercion on `A` in statics
error[E0277]: the trait bound `A: Deref` is not satisfied
--> $DIR/issue-25901.rs:4:24
|
LL | static S: &'static B = &A;
| ^^ the trait `~const Deref` is not implemented for `A`
|
note: the trait `Deref` is implemented for `A`, but that implementation is not `const`
--> $DIR/issue-25901.rs:4:24
|
LL | static S: &'static B = &A;
| ^^
|
= note: attempting to deref into `B`
note: deref defined here
--> $DIR/issue-25901.rs:10:5
|
LL | type Target = B;
| ^^^^^^^^^^^
note: impl defined here, but it is not `const`
--> $DIR/issue-25901.rs:9:1
|
LL | impl Deref for A {
| ^^^^^^^^^^^^^^^^
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
= note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
error: aborting due to previous error
For more information about this error, try `rustc --explain E0015`.
For more information about this error, try `rustc --explain E0277`.

View file

@ -7,9 +7,7 @@ LL | Err(5)?;
| ^ the trait `From<{integer}>` is not implemented for `()`
|
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
= help: the following other types implement trait `FromResidual<R>`:
<Result<T, F> as FromResidual<Result<Infallible, E>>>
<Result<T, F> as FromResidual<Yeet<E>>>
= help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>`
= note: required for `Result<i32, ()>` to implement `FromResidual<Result<Infallible, {integer}>>`
error: aborting due to previous error

View file

@ -2,4 +2,5 @@ fn main() {
Vec::<[(); 1 + for x in 0..1 {}]>::new();
//~^ ERROR cannot add
//~| ERROR `for` is not allowed in a `const`
//~| ERROR the trait bound
}

View file

@ -7,13 +7,27 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new();
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
= help: add `#![feature(const_for)]` to the crate attributes to enable
error[E0277]: cannot add `()` to `{integer}`
error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied
--> $DIR/issue-50582.rs:2:29
|
LL | Vec::<[(); 1 + for x in 0..1 {}]>::new();
| ^^^^ `std::ops::Range<{integer}>` is not an iterator
|
= help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>`
note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const`
--> $DIR/issue-50582.rs:2:29
|
LL | Vec::<[(); 1 + for x in 0..1 {}]>::new();
| ^^^^
= note: required for `std::ops::Range<{integer}>` to implement `~const IntoIterator`
error[E0277]: cannot add `()` to `{integer}` in const contexts
--> $DIR/issue-50582.rs:2:18
|
LL | Vec::<[(); 1 + for x in 0..1 {}]>::new();
| ^ no implementation for `{integer} + ()`
|
= help: the trait `Add<()>` is not implemented for `{integer}`
= help: the trait `~const Add<()>` is not implemented for `{integer}`
= help: the following other types implement trait `Add<Rhs>`:
<&'a f32 as Add<f32>>
<&'a f64 as Add<f64>>
@ -25,7 +39,7 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new();
<&'a isize as Add<isize>>
and 48 others
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0277, E0658.
For more information about an error, try `rustc --explain E0277`.

View file

@ -2,4 +2,5 @@ fn main() {
|y: Vec<[(); for x in 0..2 {}]>| {};
//~^ ERROR mismatched types
//~| ERROR `for` is not allowed in a `const`
//~| ERROR the trait bound
}

View file

@ -7,13 +7,27 @@ LL | |y: Vec<[(); for x in 0..2 {}]>| {};
= note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
= help: add `#![feature(const_for)]` to the crate attributes to enable
error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied
--> $DIR/issue-50585.rs:2:27
|
LL | |y: Vec<[(); for x in 0..2 {}]>| {};
| ^^^^ `std::ops::Range<{integer}>` is not an iterator
|
= help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>`
note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const`
--> $DIR/issue-50585.rs:2:27
|
LL | |y: Vec<[(); for x in 0..2 {}]>| {};
| ^^^^
= note: required for `std::ops::Range<{integer}>` to implement `~const IntoIterator`
error[E0308]: mismatched types
--> $DIR/issue-50585.rs:2:18
|
LL | |y: Vec<[(); for x in 0..2 {}]>| {};
| ^^^^^^^^^^^^^^^^ expected `usize`, found `()`
error: aborting due to 2 previous errors
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0308, E0658.
For more information about an error, try `rustc --explain E0308`.
Some errors have detailed explanations: E0277, E0308, E0658.
For more information about an error, try `rustc --explain E0277`.

View file

@ -8,7 +8,5 @@ fn main() {
[(); { for _ in 0usize.. {}; 0}];
//~^ ERROR `for` is not allowed in a `const`
//~| ERROR cannot convert
//~| ERROR mutable references are not allowed in constants
//~| ERROR cannot call non-const fn
//~| ERROR the trait bound
}

View file

@ -38,37 +38,25 @@ LL | [(); loop { break }];
| expected `usize`, found `()`
| help: give it a value of the expected type: `break 42`
error[E0015]: cannot convert `RangeFrom<usize>` into an iterator in constants
error[E0277]: the trait bound `RangeFrom<usize>: Iterator` is not satisfied
--> $DIR/issue-52443.rs:9:21
|
LL | [(); { for _ in 0usize.. {}; 0}];
| ^^^^^^^^ `RangeFrom<usize>` is not an iterator
|
= help: the trait `~const Iterator` is not implemented for `RangeFrom<usize>`
note: the trait `Iterator` is implemented for `RangeFrom<usize>`, but that implementation is not `const`
--> $DIR/issue-52443.rs:9:21
|
LL | [(); { for _ in 0usize.. {}; 0}];
| ^^^^^^^^
= note: required for `RangeFrom<usize>` to implement `~const IntoIterator`
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
|
LL | impl<I: ~const Iterator> const IntoIterator for I {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
LL | fn main() where RangeFrom<usize>: ~const Iterator {
| +++++++++++++++++++++++++++++++++++++++
error[E0658]: mutable references are not allowed in constants
--> $DIR/issue-52443.rs:9:21
|
LL | [(); { for _ in 0usize.. {}; 0}];
| ^^^^^^^^
|
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
error: aborting due to 4 previous errors; 1 warning emitted
error[E0015]: cannot call non-const fn `<RangeFrom<usize> as Iterator>::next` in constants
--> $DIR/issue-52443.rs:9:21
|
LL | [(); { for _ in 0usize.. {}; 0}];
| ^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to 6 previous errors; 1 warning emitted
Some errors have detailed explanations: E0015, E0308, E0658.
For more information about an error, try `rustc --explain E0015`.
Some errors have detailed explanations: E0277, E0308, E0658.
For more information about an error, try `rustc --explain E0277`.

View file

@ -10,6 +10,7 @@ impl std::ops::Add for NonConstAdd {
}
}
#[const_trait]
trait Foo {
type Bar: ~const std::ops::Add;
}
@ -19,6 +20,7 @@ impl const Foo for NonConstAdd {
//~^ ERROR: cannot add `NonConstAdd` to `NonConstAdd` in const contexts
}
#[const_trait]
trait Baz {
type Qux: std::ops::Add;
}

View file

@ -1,17 +1,17 @@
error[E0277]: cannot add `NonConstAdd` to `NonConstAdd` in const contexts
--> $DIR/assoc-type.rs:18:16
--> $DIR/assoc-type.rs:19:16
|
LL | type Bar = NonConstAdd;
| ^^^^^^^^^^^ no implementation for `NonConstAdd + NonConstAdd`
|
= help: the trait `~const Add` is not implemented for `NonConstAdd`
note: the trait `Add` is implemented for `NonConstAdd`, but that implementation is not `const`
--> $DIR/assoc-type.rs:18:16
--> $DIR/assoc-type.rs:19:16
|
LL | type Bar = NonConstAdd;
| ^^^^^^^^^^^
note: required by a bound in `Foo::Bar`
--> $DIR/assoc-type.rs:14:15
--> $DIR/assoc-type.rs:15:15
|
LL | type Bar: ~const std::ops::Add;
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::Bar`

View file

@ -3,6 +3,7 @@
#![stable(feature = "rust1", since = "1.0.0")]
#[stable(feature = "rust1", since = "1.0.0")]
#[const_trait]
pub trait MyTrait {
#[stable(feature = "rust1", since = "1.0.0")]
fn func();

View file

@ -1,5 +1,6 @@
#![feature(const_trait_impl)]
#[const_trait]
pub trait Plus {
fn plus(self, rhs: Self) -> Self;
}
@ -23,7 +24,6 @@ pub const fn add_i32(a: i32, b: i32) -> i32 {
pub const fn add_u32(a: u32, b: u32) -> u32 {
a.plus(b)
//~^ ERROR the trait bound
//~| ERROR cannot call non-const fn
}
fn main() {}

View file

@ -1,24 +1,19 @@
error[E0277]: the trait bound `u32: ~const Plus` is not satisfied
--> $DIR/call-const-trait-method-fail.rs:24:7
--> $DIR/call-const-trait-method-fail.rs:25:7
|
LL | a.plus(b)
| ^^^^^^^ the trait `~const Plus` is not implemented for `u32`
| ^^^^ the trait `~const Plus` is not implemented for `u32`
|
note: the trait `Plus` is implemented for `u32`, but that implementation is not `const`
--> $DIR/call-const-trait-method-fail.rs:24:7
--> $DIR/call-const-trait-method-fail.rs:25:7
|
LL | a.plus(b)
| ^^^^^^^
error[E0015]: cannot call non-const fn `<u32 as Plus>::plus` in constant functions
--> $DIR/call-const-trait-method-fail.rs:24:7
| ^^^^
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | a.plus(b)
| ^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
LL | pub const fn add_u32(a: u32, b: u32) -> u32 where u32: ~const Plus {
| ++++++++++++++++++++++
error: aborting due to 2 previous errors
error: aborting due to previous error
Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.
For more information about this error, try `rustc --explain E0277`.

View file

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

View file

@ -1,6 +1,7 @@
// check-pass
#![feature(const_trait_impl)]
#[const_trait]
trait MyPartialEq {
fn eq(&self, other: &Self) -> bool;
}

View file

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

View file

@ -1,5 +1,5 @@
error[E0015]: cannot call non-const fn `non_const` in constant functions
--> $DIR/const-check-fns-in-const-impl.rs:11:16
--> $DIR/const-check-fns-in-const-impl.rs:12:16
|
LL | fn foo() { non_const() }
| ^^^^^^^^^^^

View file

@ -48,6 +48,7 @@ mod t {
pub struct HasConstDrop(pub ConstDrop);
pub struct TrivialFields(pub u8, pub i8, pub usize, pub isize);
#[const_trait]
pub trait SomeTrait {
fn foo();
}

View file

@ -1,9 +1,11 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Foo {}
const impl Foo for i32 {} //~ ERROR: expected identifier, found keyword
#[const_trait]
trait Bar {}
const impl<T: Foo> Bar for T {} //~ ERROR: expected identifier, found keyword

View file

@ -1,5 +1,5 @@
error: expected identifier, found keyword `impl`
--> $DIR/const-impl-recovery.rs:5:7
--> $DIR/const-impl-recovery.rs:6:7
|
LL | const impl Foo for i32 {}
| ^^^^ expected identifier, found keyword
@ -11,7 +11,7 @@ LL + impl const Foo for i32 {}
|
error: expected identifier, found keyword `impl`
--> $DIR/const-impl-recovery.rs:9:7
--> $DIR/const-impl-recovery.rs:11:7
|
LL | const impl<T: Foo> Bar for T {}
| ^^^^ expected identifier, found keyword

View file

@ -1,5 +1,5 @@
error: fatal error triggered by #[rustc_error]
--> $DIR/feature-gate.rs:13:1
--> $DIR/feature-gate.rs:14:1
|
LL | fn main() {}
| ^^^^^^^^^

View file

@ -5,6 +5,7 @@
#![feature(rustc_attrs)]
struct S;
#[const_trait] //[stock]~ ERROR `const_trait` is a temporary placeholder
trait T {}
impl const T for S {}
//[stock]~^ ERROR const trait impls are experimental

View file

@ -1,5 +1,5 @@
error[E0658]: const trait impls are experimental
--> $DIR/feature-gate.rs:9:6
--> $DIR/feature-gate.rs:10:6
|
LL | impl const T for S {}
| ^^^^^
@ -7,6 +7,15 @@ LL | impl const T for S {}
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
error: aborting due to previous error
error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future.
--> $DIR/feature-gate.rs:8:1
|
LL | #[const_trait]
| ^^^^^^^^^^^^^^
|
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -2,6 +2,7 @@
#![feature(const_trait_impl)]
#[const_trait]
pub trait MyTrait {
fn method(&self) -> Option<()>;
}

View file

@ -1,5 +1,5 @@
error[E0658]: `?` is not allowed in a `const fn`
--> $DIR/hir-const-check.rs:11:9
--> $DIR/hir-const-check.rs:12:9
|
LL | Some(())?;
| ^^^^^^^^^

View file

@ -3,7 +3,9 @@
struct S;
#[const_trait]
trait A {}
#[const_trait]
trait B {}
impl const A for S {}

View file

@ -16,6 +16,7 @@ pub trait IndexMut where Self: Index {
impl Index for () { type Output = (); }
#[cfg(not(any(nn, yn)))]
impl const IndexMut for <() as Index>::Output {
const C: <Self as Index>::Output = ();
type Assoc = <Self as Index>::Output;
@ -24,6 +25,15 @@ impl const IndexMut for <() as Index>::Output {
{}
}
#[cfg(any(nn, yn))]
impl IndexMut for <() as Index>::Output {
const C: <Self as Index>::Output = ();
type Assoc = <Self as Index>::Output;
fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output
where <Self as Index>::Output:,
{}
}
const C: <() as Index>::Output = ();
fn main() {}

View file

@ -4,7 +4,9 @@
#![feature(const_trait_impl)]
#[const_trait]
pub trait Super {}
#[const_trait]
pub trait Sub: Super {}
impl<A> const Super for &A where A: ~const Super {}

View file

@ -2,6 +2,7 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Convert<T> {
fn to(self) -> T;
}

View file

@ -1,8 +1,10 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Foo {
fn a(&self);
}
#[const_trait]
trait Bar: ~const Foo {}
struct S;

View file

@ -1,16 +1,16 @@
error[E0277]: the trait bound `S: ~const Foo` is not satisfied
--> $DIR/super-traits-fail.rs:13:12
--> $DIR/super-traits-fail.rs:15:12
|
LL | impl const Bar for S {}
| ^^^ the trait `~const Foo` is not implemented for `S`
|
note: the trait `Foo` is implemented for `S`, but that implementation is not `const`
--> $DIR/super-traits-fail.rs:13:12
--> $DIR/super-traits-fail.rs:15:12
|
LL | impl const Bar for S {}
| ^^^
note: required by a bound in `Bar`
--> $DIR/super-traits-fail.rs:6:12
--> $DIR/super-traits-fail.rs:8:12
|
LL | trait Bar: ~const Foo {}
| ^^^^^^^^^^ required by this bound in `Bar`

View file

@ -1,9 +1,12 @@
// check-pass
#![feature(const_trait_impl)]
#[const_trait]
trait Foo {
fn a(&self);
}
#[const_trait]
trait Bar: ~const Foo {}
struct S;

View file

@ -2,6 +2,7 @@
#![feature(const_trait_impl)]
#[const_trait]
trait Bar {
fn bar() -> u8;
}

View file

@ -19,6 +19,7 @@ impl Foo {
}
#[stable(feature = "stable", since = "1.0.0")]
#[const_trait]
pub trait Bar {
#[stable(feature = "stable", since = "1.0.0")]
fn fun();

View file

@ -5,7 +5,7 @@ LL | pub const fn foo() {}
| ^^^^^^^^^^^^^^^^^^^^^
error: implementation has missing const stability attribute
--> $DIR/missing-const-stability.rs:27:1
--> $DIR/missing-const-stability.rs:28:1
|
LL | / impl const Bar for Foo {
LL | |

View file

@ -2,7 +2,7 @@ error[E0277]: the size for values of type `[i32]` cannot be known at compilation
--> $DIR/slice-issue-87994.rs:3:12
|
LL | for _ in v[1..] {
| ^^^^^^ the trait `IntoIterator` is not implemented for `[i32]`
| ^^^^^^ the trait `~const IntoIterator` is not implemented for `[i32]`
|
= note: the trait bound `[i32]: IntoIterator` is not satisfied
= note: required for `[i32]` to implement `IntoIterator`
@ -17,7 +17,7 @@ error[E0277]: `[i32]` is not an iterator
--> $DIR/slice-issue-87994.rs:3:12
|
LL | for _ in v[1..] {
| ^^^^^^ the trait `IntoIterator` is not implemented for `[i32]`
| ^^^^^^ the trait `~const IntoIterator` is not implemented for `[i32]`
|
= note: the trait bound `[i32]: IntoIterator` is not satisfied
= note: required for `[i32]` to implement `IntoIterator`
@ -32,7 +32,7 @@ error[E0277]: the size for values of type `[K]` cannot be known at compilation t
--> $DIR/slice-issue-87994.rs:11:13
|
LL | for i2 in v2[1..] {
| ^^^^^^^ the trait `IntoIterator` is not implemented for `[K]`
| ^^^^^^^ the trait `~const IntoIterator` is not implemented for `[K]`
|
= note: the trait bound `[K]: IntoIterator` is not satisfied
= note: required for `[K]` to implement `IntoIterator`
@ -47,7 +47,7 @@ error[E0277]: `[K]` is not an iterator
--> $DIR/slice-issue-87994.rs:11:13
|
LL | for i2 in v2[1..] {
| ^^^^^^^ the trait `IntoIterator` is not implemented for `[K]`
| ^^^^^^^ the trait `~const IntoIterator` is not implemented for `[K]`
|
= note: the trait bound `[K]: IntoIterator` is not satisfied
= note: required for `[K]` to implement `IntoIterator`