Skip to content

Commit c143471

Browse files
committed
Show const_err lint in addition to the hard error
1 parent df26968 commit c143471

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/test/ui/consts/assoc_const_generic_impl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#![allow(const_err)]
1+
#![warn(const_err)]
22

33
trait ZeroSized: Sized {
44
const I_AM_ZERO_SIZED: ();
55
fn requires_zero_size(self);
66
}
77

88
impl<T: Sized> ZeroSized for T {
9-
const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()];
9+
const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()]; //~ WARN any use of this value
1010
fn requires_zero_size(self) {
1111
let () = Self::I_AM_ZERO_SIZED; //~ ERROR erroneous constant encountered
1212
println!("requires_zero_size called");

src/test/ui/consts/assoc_const_generic_impl.stderr

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
warning: any use of this value will cause an error
2+
--> $DIR/assoc_const_generic_impl.rs:9:34
3+
|
4+
LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()];
5+
| -----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
6+
| |
7+
| index out of bounds: the len is 1 but the index is 4
8+
|
9+
note: lint level defined here
10+
--> $DIR/assoc_const_generic_impl.rs:1:9
11+
|
12+
LL | #![warn(const_err)]
13+
| ^^^^^^^^^
14+
115
error: erroneous constant encountered
216
--> $DIR/assoc_const_generic_impl.rs:11:18
317
|

0 commit comments

Comments
 (0)