Skip to content

Commit d60ebe3

Browse files
committed
bless tests, remove nonexistent E0395
1 parent a6f9826 commit d60ebe3

24 files changed

+182
-194
lines changed

src/test/ui/const-generics/issues/issue-90318.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@ impl True for If<true> {}
1212
fn consume<T: 'static>(_val: T)
1313
where
1414
If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
15-
//~^ ERROR: overly complex generic constant
16-
//~| ERROR: cannot call non-const operator in constants
15+
//~^ ERROR: can't compare
1716
{
1817
}
1918

2019
fn test<T: 'static>()
2120
where
2221
If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
23-
//~^ ERROR: overly complex generic constant
24-
//~| ERROR: cannot call non-const operator in constants
22+
//~^ ERROR: can't compare
2523
{
2624
}
2725

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,31 @@
1-
error: overly complex generic constant
2-
--> $DIR/issue-90318.rs:14:8
1+
error[E0277]: can't compare `TypeId` with `_` in const contexts
2+
--> $DIR/issue-90318.rs:14:28
33
|
44
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
5-
| ^^-----------------^^^^^^^^^^^^^^^^^^^^^^^^
6-
| |
7-
| borrowing is not supported in generic constants
5+
| ^^ no implementation for `TypeId == _`
86
|
9-
= help: consider moving this anonymous constant into a `const` function
10-
= note: this operation may be supported in the future
11-
12-
error[E0015]: cannot call non-const operator in constants
13-
--> $DIR/issue-90318.rs:14:10
7+
= help: the trait `~const PartialEq<_>` is not implemented for `TypeId`
8+
note: the trait `PartialEq<_>` is implemented for `TypeId`, but that implementation is not `const`
9+
--> $DIR/issue-90318.rs:14:28
1410
|
1511
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17-
|
18-
note: impl defined here, but it is not `const`
19-
--> $SRC_DIR/core/src/any.rs:LL:COL
20-
|
21-
LL | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
22-
| ^^^^^^^^^
23-
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
24-
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
12+
| ^^
13+
= help: the trait `PartialEq` is implemented for `TypeId`
2514

26-
error: overly complex generic constant
27-
--> $DIR/issue-90318.rs:22:8
15+
error[E0277]: can't compare `TypeId` with `_` in const contexts
16+
--> $DIR/issue-90318.rs:21:28
2817
|
2918
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
30-
| ^^-----------------^^^^^^^^^^^^^^^^^^^^^^^^
31-
| |
32-
| borrowing is not supported in generic constants
19+
| ^^ no implementation for `TypeId == _`
3320
|
34-
= help: consider moving this anonymous constant into a `const` function
35-
= note: this operation may be supported in the future
36-
37-
error[E0015]: cannot call non-const operator in constants
38-
--> $DIR/issue-90318.rs:22:10
21+
= help: the trait `~const PartialEq<_>` is not implemented for `TypeId`
22+
note: the trait `PartialEq<_>` is implemented for `TypeId`, but that implementation is not `const`
23+
--> $DIR/issue-90318.rs:21:28
3924
|
4025
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
41-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42-
|
43-
note: impl defined here, but it is not `const`
44-
--> $SRC_DIR/core/src/any.rs:LL:COL
45-
|
46-
LL | #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
47-
| ^^^^^^^^^
48-
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
49-
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
26+
| ^^
27+
= help: the trait `PartialEq` is implemented for `TypeId`
5028

51-
error: aborting due to 4 previous errors
29+
error: aborting due to 2 previous errors
5230

53-
For more information about this error, try `rustc --explain E0015`.
31+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fn main() {}
22

33
// unconst and bad, will thus error in miri
4-
const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR cannot be reliably
4+
const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR can't compare
55
// unconst and bad, will thus error in miri
6-
const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; //~ ERROR cannot be reliably
6+
const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; //~ ERROR can't compare
Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,49 @@
1-
error: pointers cannot be reliably compared during const eval
2-
--> $DIR/const_raw_ptr_ops.rs:4:26
1+
error[E0277]: can't compare `*const i32` with `_` in const contexts
2+
--> $DIR/const_raw_ptr_ops.rs:4:43
33
|
44
LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 };
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^ no implementation for `*const i32 == _`
66
|
7-
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
7+
= help: the trait `~const PartialEq<_>` is not implemented for `*const i32`
8+
note: the trait `PartialEq<_>` is implemented for `*const i32`, but that implementation is not `const`
9+
--> $DIR/const_raw_ptr_ops.rs:4:43
10+
|
11+
LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 };
12+
| ^^
13+
= help: the following other types implement trait `PartialEq<Rhs>`:
14+
f32
15+
f64
16+
i128
17+
i16
18+
i32
19+
i64
20+
i8
21+
isize
22+
and 6 others
823

9-
error: pointers cannot be reliably compared during const eval
10-
--> $DIR/const_raw_ptr_ops.rs:6:27
24+
error[E0277]: can't compare `*const i32` with `_` in const contexts
25+
--> $DIR/const_raw_ptr_ops.rs:6:44
1126
|
1227
LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 };
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28+
| ^^ no implementation for `*const i32 == _`
1429
|
15-
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
30+
= help: the trait `~const PartialEq<_>` is not implemented for `*const i32`
31+
note: the trait `PartialEq<_>` is implemented for `*const i32`, but that implementation is not `const`
32+
--> $DIR/const_raw_ptr_ops.rs:6:44
33+
|
34+
LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 };
35+
| ^^
36+
= help: the following other types implement trait `PartialEq<Rhs>`:
37+
f32
38+
f64
39+
i128
40+
i16
41+
i32
42+
i64
43+
i8
44+
isize
45+
and 6 others
1646

1747
error: aborting due to 2 previous errors
1848

49+
For more information about this error, try `rustc --explain E0277`.

src/test/ui/consts/issue-25826.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fn id<T>(t: T) -> T { t }
22
fn main() {
33
const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () };
4-
//~^ ERROR pointers cannot be reliably compared during const eval
4+
//~^ ERROR can't compare
55
println!("{}", A);
66
}

src/test/ui/consts/issue-25826.stderr

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
error: pointers cannot be reliably compared during const eval
2-
--> $DIR/issue-25826.rs:3:30
1+
error[E0277]: can't compare `*const ()` with `*const ()` in const contexts
2+
--> $DIR/issue-25826.rs:3:52
33
|
44
LL | const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () };
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^ no implementation for `*const () < *const ()` and `*const () > *const ()`
66
|
7-
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
7+
= help: the trait `~const PartialOrd` is not implemented for `*const ()`
8+
note: the trait `PartialOrd` is implemented for `*const ()`, but that implementation is not `const`
9+
--> $DIR/issue-25826.rs:3:52
10+
|
11+
LL | const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () };
12+
| ^
13+
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
14+
|
15+
LL | fn main() where *const (): ~const PartialOrd {
16+
| ++++++++++++++++++++++++++++++++++
817

918
error: aborting due to previous error
1019

20+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const fn cmp(x: fn(), y: fn()) -> bool {
22
unsafe { x == y }
3-
//~^ ERROR pointers cannot be reliably compared
3+
//~^ ERROR can't compare
44
}
55

66
fn main() {}
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1-
error: pointers cannot be reliably compared during const eval
2-
--> $DIR/cmp_fn_pointers.rs:2:14
1+
error[E0277]: can't compare `fn()` with `_` in const contexts
2+
--> $DIR/cmp_fn_pointers.rs:2:16
33
|
44
LL | unsafe { x == y }
5-
| ^^^^^^
5+
| ^^ no implementation for `fn() == _`
66
|
7-
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
7+
= help: the trait `~const PartialEq<_>` is not implemented for `fn()`
8+
note: the trait `PartialEq<_>` is implemented for `fn()`, but that implementation is not `const`
9+
--> $DIR/cmp_fn_pointers.rs:2:16
10+
|
11+
LL | unsafe { x == y }
12+
| ^^
13+
= help: the following other types implement trait `PartialEq<Rhs>`:
14+
extern "C" fn() -> Ret
15+
extern "C" fn(A, B) -> Ret
16+
extern "C" fn(A, B, ...) -> Ret
17+
extern "C" fn(A, B, C) -> Ret
18+
extern "C" fn(A, B, C, ...) -> Ret
19+
extern "C" fn(A, B, C, D) -> Ret
20+
extern "C" fn(A, B, C, D, ...) -> Ret
21+
extern "C" fn(A, B, C, D, E) -> Ret
22+
and 68 others
823

924
error: aborting due to previous error
1025

26+
For more information about this error, try `rustc --explain E0277`.

src/test/ui/consts/miri_unleashed/ptr_arith.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@
22
#![feature(core_intrinsics)]
33
#![allow(const_err)]
44

5-
// During CTFE, we prevent pointer comparison and pointer-to-int casts.
6-
7-
static CMP: () = {
8-
let x = &0 as *const _;
9-
let _v = x == x;
10-
//~^ ERROR could not evaluate static initializer
11-
//~| "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
12-
};
5+
// During CTFE, we prevent pointer-to-int casts.
6+
// Pointer comparisons are prevented in the trait system.
137

148
static PTR_INT_CAST: () = {
159
let x = &0 as *const _ as usize;
Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,23 @@
11
error[E0080]: could not evaluate static initializer
2-
--> $DIR/ptr_arith.rs:9:14
3-
|
4-
LL | let _v = x == x;
5-
| ^^^^^^ "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
6-
7-
error[E0080]: could not evaluate static initializer
8-
--> $DIR/ptr_arith.rs:15:13
2+
--> $DIR/ptr_arith.rs:9:13
93
|
104
LL | let x = &0 as *const _ as usize;
115
| ^^^^^^^^^^^^^^^^^^^^^^^ "exposing pointers" needs an rfc before being allowed inside constants
126

137
error[E0080]: could not evaluate static initializer
14-
--> $DIR/ptr_arith.rs:23:14
8+
--> $DIR/ptr_arith.rs:17:14
159
|
1610
LL | let _v = x + 0;
1711
| ^ unable to turn pointer into raw bytes
1812

1913
warning: skipping const checks
2014
|
2115
help: skipping check that does not even have a feature gate
22-
--> $DIR/ptr_arith.rs:9:14
23-
|
24-
LL | let _v = x == x;
25-
| ^^^^^^
26-
help: skipping check that does not even have a feature gate
27-
--> $DIR/ptr_arith.rs:15:13
16+
--> $DIR/ptr_arith.rs:9:13
2817
|
2918
LL | let x = &0 as *const _ as usize;
3019
| ^^^^^^^^^^^^^^^^^^^^^^^
3120

32-
error: aborting due to 3 previous errors; 1 warning emitted
21+
error: aborting due to 2 previous errors; 1 warning emitted
3322

3423
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)