fix library and rustdoc tests
This commit is contained in:
parent
147e850691
commit
4c6ddc036b
108 changed files with 841 additions and 444 deletions
|
@ -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` in const contexts
|
||||
error[E0277]: cannot add `u8` to `i8`
|
||||
--> $DIR/const-eval-overflow-3b.rs:16:20
|
||||
|
|
||||
LL | = [0; (i8::MAX + 1u8) as usize];
|
||||
| ^ no implementation for `i8 + u8`
|
||||
|
|
||||
= help: the trait `~const Add<u8>` is not implemented for `i8`
|
||||
= help: the trait `Add<u8>` is not implemented for `i8`
|
||||
= help: the following other types implement trait `Add<Rhs>`:
|
||||
<&'a i8 as Add<i8>>
|
||||
<&i8 as Add<&i8>>
|
||||
|
|
|
@ -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` in const contexts
|
||||
error[E0277]: cannot add `u8` to `i8`
|
||||
--> $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 `~const Add<u8>` is not implemented for `i8`
|
||||
= help: the trait `Add<u8>` is not implemented for `i8`
|
||||
= help: the following other types implement trait `Add<Rhs>`:
|
||||
<&'a i8 as Add<i8>>
|
||||
<&i8 as Add<&i8>>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
fn main() {}
|
||||
|
||||
// unconst and bad, will thus error in miri
|
||||
const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR can't compare
|
||||
const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR pointers cannot
|
||||
// unconst and bad, will thus error in miri
|
||||
const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; //~ ERROR can't compare
|
||||
const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; //~ ERROR pointers cannot
|
||||
|
|
|
@ -1,29 +1,18 @@
|
|||
error[E0277]: can't compare `*const i32` with `_` in const contexts
|
||||
--> $DIR/const_raw_ptr_ops.rs:4:43
|
||||
error: pointers cannot be reliably compared during const eval
|
||||
--> $DIR/const_raw_ptr_ops.rs:4:26
|
||||
|
|
||||
LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 };
|
||||
| ^^ no implementation for `*const i32 == _`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: the trait `~const PartialEq<_>` is not implemented for `*const i32`
|
||||
note: the trait `PartialEq<_>` is implemented for `*const i32`, but that implementation is not `const`
|
||||
--> $DIR/const_raw_ptr_ops.rs:4:43
|
||||
|
|
||||
LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 };
|
||||
| ^^
|
||||
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
|
||||
|
||||
error[E0277]: can't compare `*const i32` with `_` in const contexts
|
||||
--> $DIR/const_raw_ptr_ops.rs:6:44
|
||||
error: pointers cannot be reliably compared during const eval
|
||||
--> $DIR/const_raw_ptr_ops.rs:6:27
|
||||
|
|
||||
LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 };
|
||||
| ^^ no implementation for `*const i32 == _`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: the trait `~const PartialEq<_>` is not implemented for `*const i32`
|
||||
note: the trait `PartialEq<_>` is implemented for `*const i32`, but that implementation is not `const`
|
||||
--> $DIR/const_raw_ptr_ops.rs:6:44
|
||||
|
|
||||
LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 };
|
||||
| ^^
|
||||
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// known-bug: #110395
|
||||
|
||||
#![feature(const_slice_index)]
|
||||
|
||||
const A: [(); 5] = [(), (), (), (), ()];
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
error[E0080]: evaluation of constant value failed
|
||||
--> $SRC_DIR/core/src/slice/index.rs:LL:COL
|
||||
|
|
||||
= note: overflow executing `unchecked_sub`
|
||||
|
|
||||
note: inside `<std::ops::Range<usize> as SliceIndex<[()]>>::get_unchecked`
|
||||
--> $SRC_DIR/core/src/slice/index.rs:LL:COL
|
||||
note: inside `core::slice::<impl [()]>::get_unchecked::<std::ops::Range<usize>>`
|
||||
--> $SRC_DIR/core/src/slice/mod.rs:LL:COL
|
||||
note: inside `B`
|
||||
--> $DIR/ub-slice-get-unchecked.rs:7:27
|
||||
error[E0015]: cannot call non-const fn `core::slice::<impl [()]>::get_unchecked::<std::ops::Range<usize>>` in constants
|
||||
--> $DIR/ub-slice-get-unchecked.rs:9:29
|
||||
|
|
||||
LL | const B: &[()] = unsafe { A.get_unchecked(3..1) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
For more information about this error, try `rustc --explain E0015`.
|
||||
|
|
|
@ -8,11 +8,33 @@
|
|||
// Don't promote
|
||||
const fn nop<T>(x: T) -> T { x }
|
||||
|
||||
// FIXME(const-hack): replace with PartialEq
|
||||
#[const_trait]
|
||||
trait MyEq<T> {
|
||||
fn eq(self, b: T) -> bool;
|
||||
}
|
||||
|
||||
impl const MyEq<bool> for bool {
|
||||
fn eq(self, b: bool) -> bool {
|
||||
self == b
|
||||
}
|
||||
}
|
||||
|
||||
impl const MyEq<NonDet> for bool {
|
||||
fn eq(self, _: NonDet) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
const fn eq<A: ~const MyEq<B>, B>(x: A, y: B) -> bool {
|
||||
x.eq(y)
|
||||
}
|
||||
|
||||
macro_rules! const_assert {
|
||||
($a:expr, $b:expr) => {
|
||||
{
|
||||
const _: () = assert!($a == $b);
|
||||
assert_eq!(nop($a), nop($b));
|
||||
const _: () = assert!(eq($a, $b));
|
||||
assert!(eq(nop($a), nop($b)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -47,15 +69,6 @@ macro_rules! suite_inner {
|
|||
#[derive(Debug)]
|
||||
struct NonDet;
|
||||
|
||||
impl const PartialEq<NonDet> for bool {
|
||||
fn eq(&self, _: &NonDet) -> bool {
|
||||
true
|
||||
}
|
||||
fn ne(&self, _: &NonDet) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
// The result of the `is_sign` methods are not checked for correctness, since LLVM does not
|
||||
// guarantee anything about the signedness of NaNs. See
|
||||
// https://github.com/rust-lang/rust/issues/55131.
|
||||
|
|
|
@ -7,7 +7,6 @@ const fn f(x: usize) -> usize {
|
|||
//~| ERROR `for` is not allowed in a `const fn`
|
||||
//~| ERROR mutable references are not allowed in constant functions
|
||||
//~| ERROR cannot call non-const fn
|
||||
//~| ERROR the trait bound
|
||||
sum += i;
|
||||
}
|
||||
sum
|
||||
|
|
|
@ -5,7 +5,7 @@ LL | / for i in 0..x {
|
|||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | |
|
||||
LL | | sum += i;
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
@ -33,19 +33,6 @@ 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[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 {
|
||||
| ^^^^
|
||||
|
||||
error[E0015]: cannot call non-const fn `<std::ops::Range<usize> as Iterator>::next` in constant functions
|
||||
--> $DIR/const-fn-error.rs:5:14
|
||||
|
|
||||
|
@ -55,7 +42,7 @@ LL | for i in 0..x {
|
|||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0015, E0277, E0658.
|
||||
Some errors have detailed explanations: E0015, E0658.
|
||||
For more information about an error, try `rustc --explain E0015`.
|
||||
|
|
|
@ -5,7 +5,6 @@ const _: () = {
|
|||
for _ in 0..5 {}
|
||||
//~^ error: cannot call
|
||||
//~| error: cannot convert
|
||||
//~| error: the trait bound
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -9,19 +9,6 @@ note: impl defined here, but it is not `const`
|
|||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
||||
|
||||
error[E0277]: the trait bound `std::ops::Range<i32>: Iterator` is not satisfied
|
||||
--> $DIR/const-for.rs:5:14
|
||||
|
|
||||
LL | for _ in 0..5 {}
|
||||
| ^^^^ `std::ops::Range<i32>` is not an iterator
|
||||
|
|
||||
= help: the trait `~const Iterator` is not implemented for `std::ops::Range<i32>`
|
||||
note: the trait `Iterator` is implemented for `std::ops::Range<i32>`, but that implementation is not `const`
|
||||
--> $DIR/const-for.rs:5:14
|
||||
|
|
||||
LL | for _ in 0..5 {}
|
||||
| ^^^^
|
||||
|
||||
error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants
|
||||
--> $DIR/const-for.rs:5:14
|
||||
|
|
||||
|
@ -31,7 +18,6 @@ LL | for _ in 0..5 {}
|
|||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
|
||||
|
||||
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 E0015`.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// check-pass
|
||||
// known-bug: #110395
|
||||
|
||||
// Demonstrates what's needed to make use of `?` in const contexts.
|
||||
|
||||
|
|
20
tests/ui/consts/const-try.stderr
Normal file
20
tests/ui/consts/const-try.stderr
Normal file
|
@ -0,0 +1,20 @@
|
|||
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
|
||||
--> $DIR/const-try.rs:15:12
|
||||
|
|
||||
LL | impl const FromResidual<Error> for TryMe {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error: const `impl` for trait `Try` which is not marked with `#[const_trait]`
|
||||
--> $DIR/const-try.rs:21:12
|
||||
|
|
||||
LL | impl const Try for TryMe {
|
||||
| ^^^
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// run-pass
|
||||
// known-bug: #110395
|
||||
#![feature(const_type_id)]
|
||||
#![feature(const_trait_impl)]
|
||||
|
||||
|
|
76
tests/ui/consts/const_cmp_type_id.stderr
Normal file
76
tests/ui/consts/const_cmp_type_id.stderr
Normal file
|
@ -0,0 +1,76 @@
|
|||
error[E0277]: can't compare `TypeId` with `TypeId` in const contexts
|
||||
--> $DIR/const_cmp_type_id.rs:8:13
|
||||
|
|
||||
LL | assert!(TypeId::of::<u8>() == TypeId::of::<u8>());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId`
|
||||
|
|
||||
= help: the trait `~const PartialEq` is not implemented for `TypeId`
|
||||
note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const`
|
||||
--> $DIR/const_cmp_type_id.rs:8:13
|
||||
|
|
||||
LL | assert!(TypeId::of::<u8>() == TypeId::of::<u8>());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0015]: cannot call non-const operator in constant functions
|
||||
--> $DIR/const_cmp_type_id.rs:8:13
|
||||
|
|
||||
LL | assert!(TypeId::of::<u8>() == TypeId::of::<u8>());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: impl defined here, but it is not `const`
|
||||
--> $SRC_DIR/core/src/any.rs:LL:COL
|
||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0277]: can't compare `TypeId` with `TypeId` in const contexts
|
||||
--> $DIR/const_cmp_type_id.rs:9:13
|
||||
|
|
||||
LL | assert!(TypeId::of::<()>() != TypeId::of::<u8>());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId`
|
||||
|
|
||||
= help: the trait `~const PartialEq` is not implemented for `TypeId`
|
||||
note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const`
|
||||
--> $DIR/const_cmp_type_id.rs:9:13
|
||||
|
|
||||
LL | assert!(TypeId::of::<()>() != TypeId::of::<u8>());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0015]: cannot call non-const operator in constant functions
|
||||
--> $DIR/const_cmp_type_id.rs:9:13
|
||||
|
|
||||
LL | assert!(TypeId::of::<()>() != TypeId::of::<u8>());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: impl defined here, but it is not `const`
|
||||
--> $SRC_DIR/core/src/any.rs:LL:COL
|
||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0277]: can't compare `TypeId` with `TypeId` in const contexts
|
||||
--> $DIR/const_cmp_type_id.rs:10:22
|
||||
|
|
||||
LL | const _A: bool = TypeId::of::<u8>() < TypeId::of::<u16>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId < TypeId` and `TypeId > TypeId`
|
||||
|
|
||||
= help: the trait `~const PartialOrd` is not implemented for `TypeId`
|
||||
note: the trait `PartialOrd` is implemented for `TypeId`, but that implementation is not `const`
|
||||
--> $DIR/const_cmp_type_id.rs:10:22
|
||||
|
|
||||
LL | const _A: bool = TypeId::of::<u8>() < TypeId::of::<u16>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0015]: cannot call non-const operator in constants
|
||||
--> $DIR/const_cmp_type_id.rs:10:22
|
||||
|
|
||||
LL | const _A: bool = TypeId::of::<u8>() < TypeId::of::<u16>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: impl defined here, but it is not `const`
|
||||
--> $SRC_DIR/core/src/any.rs:LL:COL
|
||||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
|
||||
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0015, E0277.
|
||||
For more information about an error, try `rustc --explain E0015`.
|
|
@ -1,4 +1,4 @@
|
|||
// check-pass
|
||||
// known-bug: #110395
|
||||
|
||||
#![feature(const_fn_trait_ref_impls)]
|
||||
#![feature(fn_traits)]
|
||||
|
|
15
tests/ui/consts/fn_trait_refs.stderr
Normal file
15
tests/ui/consts/fn_trait_refs.stderr
Normal file
|
@ -0,0 +1,15 @@
|
|||
error[E0635]: unknown feature `const_fn_trait_ref_impls`
|
||||
--> $DIR/fn_trait_refs.rs:3:12
|
||||
|
|
||||
LL | #![feature(const_fn_trait_ref_impls)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0635]: unknown feature `const_cmp`
|
||||
--> $DIR/fn_trait_refs.rs:8:12
|
||||
|
|
||||
LL | #![feature(const_cmp)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0635`.
|
|
@ -1,6 +1,6 @@
|
|||
fn id<T>(t: T) -> T { t }
|
||||
fn main() {
|
||||
const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () };
|
||||
//~^ ERROR can't compare
|
||||
//~^ ERROR pointers cannot
|
||||
println!("{}", A);
|
||||
}
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
error[E0277]: can't compare `*const ()` with `*const ()` in const contexts
|
||||
--> $DIR/issue-25826.rs:3:52
|
||||
error: pointers cannot be reliably compared during const eval
|
||||
--> $DIR/issue-25826.rs:3:30
|
||||
|
|
||||
LL | const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () };
|
||||
| ^ no implementation for `*const () < *const ()` and `*const () > *const ()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: the trait `~const PartialOrd` is not implemented for `*const ()`
|
||||
note: the trait `PartialOrd` is implemented for `*const ()`, but that implementation is not `const`
|
||||
--> $DIR/issue-25826.rs:3:52
|
||||
|
|
||||
LL | const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () };
|
||||
| ^
|
||||
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// check-pass
|
||||
// known-bug: #110395
|
||||
//
|
||||
// This test is complement to the test in issue-73976-polymorphic.rs.
|
||||
// In that test we ensure that polymorphic use of type_id and type_name in patterns
|
||||
|
|
28
tests/ui/consts/issue-73976-monomorphic.stderr
Normal file
28
tests/ui/consts/issue-73976-monomorphic.stderr
Normal file
|
@ -0,0 +1,28 @@
|
|||
error[E0277]: can't compare `TypeId` with `TypeId` in const contexts
|
||||
--> $DIR/issue-73976-monomorphic.rs:21:5
|
||||
|
|
||||
LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId`
|
||||
|
|
||||
= help: the trait `~const PartialEq` is not implemented for `TypeId`
|
||||
note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const`
|
||||
--> $DIR/issue-73976-monomorphic.rs:21:5
|
||||
|
|
||||
LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0015]: cannot call non-const operator in constant functions
|
||||
--> $DIR/issue-73976-monomorphic.rs:21:5
|
||||
|
|
||||
LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: impl defined here, but it is not `const`
|
||||
--> $SRC_DIR/core/src/any.rs:LL:COL
|
||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0015, E0277.
|
||||
For more information about an error, try `rustc --explain E0015`.
|
|
@ -7,8 +7,9 @@ struct Foo<'a> {
|
|||
impl<'a> Foo<'a> {
|
||||
const fn spam(&mut self, baz: &mut Vec<u32>) {
|
||||
self.bar[0] = baz.len();
|
||||
//~^ the trait bound `Vec<usize>: ~const Index<_>` is not satisfied
|
||||
//~| the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied
|
||||
//~^ ERROR: cannot call
|
||||
//~| ERROR: cannot call
|
||||
//~| ERROR: the trait bound
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
error[E0277]: the trait bound `Vec<usize>: ~const Index<_>` is not satisfied
|
||||
--> $DIR/issue-94675.rs:9:9
|
||||
error[E0015]: cannot call non-const fn `Vec::<u32>::len` in constant functions
|
||||
--> $DIR/issue-94675.rs:9:27
|
||||
|
|
||||
LL | self.bar[0] = baz.len();
|
||||
| ^^^^^^^^^^^ vector indices are of type `usize` or ranges of `usize`
|
||||
| ^^^^^
|
||||
|
|
||||
= 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();
|
||||
| ^^^^^^^^^^^
|
||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||
|
||||
error[E0277]: the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied
|
||||
--> $DIR/issue-94675.rs:9:9
|
||||
|
@ -24,6 +19,17 @@ note: the trait `IndexMut<usize>` is implemented for `Vec<usize>`, but that impl
|
|||
LL | self.bar[0] = baz.len();
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0015]: cannot call non-const operator in constant functions
|
||||
--> $DIR/issue-94675.rs:9:9
|
||||
|
|
||||
LL | self.bar[0] = baz.len();
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: impl defined here, but it is not `const`
|
||||
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
|
||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0015, E0277.
|
||||
For more information about an error, try `rustc --explain E0015`.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const fn cmp(x: fn(), y: fn()) -> bool {
|
||||
unsafe { x == y }
|
||||
//~^ ERROR can't compare
|
||||
//~^ ERROR pointers cannot
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
error[E0277]: can't compare `fn()` with `_` in const contexts
|
||||
--> $DIR/cmp_fn_pointers.rs:2:16
|
||||
error: pointers cannot be reliably compared during const eval
|
||||
--> $DIR/cmp_fn_pointers.rs:2:14
|
||||
|
|
||||
LL | unsafe { x == y }
|
||||
| ^^ no implementation for `fn() == _`
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: the trait `~const PartialEq<_>` is not implemented for `fn()`
|
||||
note: the trait `PartialEq<_>` is implemented for `fn()`, but that implementation is not `const`
|
||||
--> $DIR/cmp_fn_pointers.rs:2:16
|
||||
|
|
||||
LL | unsafe { x == y }
|
||||
| ^^
|
||||
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#![feature(const_mut_refs)]
|
||||
#![feature(const_trait_impl)]
|
||||
|
||||
struct Panic;
|
||||
impl const Drop for Panic { fn drop(&mut self) { panic!(); } }
|
||||
|
||||
pub const fn id<T>(x: T) -> T { x }
|
||||
pub const C: () = {
|
||||
let _: &'static _ = &id(&Panic);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted_const_call.rs:7:26
|
||||
--> $DIR/promoted_const_call.rs:9:26
|
||||
|
|
||||
LL | let _: &'static _ = &id(&Panic);
|
||||
| ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use
|
||||
|
@ -10,7 +10,7 @@ LL | };
|
|||
| - temporary value is freed at the end of this statement
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted_const_call.rs:7:30
|
||||
--> $DIR/promoted_const_call.rs:9:30
|
||||
|
|
||||
LL | let _: &'static _ = &id(&Panic);
|
||||
| ---------- ^^^^^ - temporary value is freed at the end of this statement
|
||||
|
@ -19,7 +19,7 @@ LL | let _: &'static _ = &id(&Panic);
|
|||
| type annotation requires that borrow lasts for `'static`
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted_const_call.rs:13:26
|
||||
--> $DIR/promoted_const_call.rs:15:26
|
||||
|
|
||||
LL | let _: &'static _ = &id(&Panic);
|
||||
| ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use
|
||||
|
@ -30,7 +30,7 @@ LL | }
|
|||
| - temporary value is freed at the end of this statement
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted_const_call.rs:13:30
|
||||
--> $DIR/promoted_const_call.rs:15:30
|
||||
|
|
||||
LL | let _: &'static _ = &id(&Panic);
|
||||
| ---------- ^^^^^ - temporary value is freed at the end of this statement
|
||||
|
@ -39,7 +39,7 @@ LL | let _: &'static _ = &id(&Panic);
|
|||
| type annotation requires that borrow lasts for `'static`
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted_const_call.rs:16:26
|
||||
--> $DIR/promoted_const_call.rs:18:26
|
||||
|
|
||||
LL | let _: &'static _ = &&(Panic, 0).1;
|
||||
| ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
|
||||
|
@ -50,7 +50,7 @@ LL | }
|
|||
| - temporary value is freed at the end of this statement
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted_const_call.rs:16:27
|
||||
--> $DIR/promoted_const_call.rs:18:27
|
||||
|
|
||||
LL | let _: &'static _ = &&(Panic, 0).1;
|
||||
| ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// check-pass
|
||||
// known-bug: #110395
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(staged_api)]
|
||||
|
|
11
tests/ui/consts/rustc-impl-const-stability.stderr
Normal file
11
tests/ui/consts/rustc-impl-const-stability.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
error: const `impl` for trait `Default` which is not marked with `#[const_trait]`
|
||||
--> $DIR/rustc-impl-const-stability.rs:15:12
|
||||
|
|
||||
LL | impl const Default for Data {
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
|
||||
= note: adding a non-const method body in the future would be a breaking change
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// run-pass
|
||||
// known-bug: #110395
|
||||
|
||||
#![feature(try_trait_v2)]
|
||||
#![feature(const_trait_impl)]
|
||||
|
|
9
tests/ui/consts/try-operator.stderr
Normal file
9
tests/ui/consts/try-operator.stderr
Normal file
|
@ -0,0 +1,9 @@
|
|||
error[E0635]: unknown feature `const_convert`
|
||||
--> $DIR/try-operator.rs:6:12
|
||||
|
|
||||
LL | #![feature(const_convert)]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0635`.
|
Loading…
Add table
Add a link
Reference in a new issue