Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that we get a hard error on generic ZST constants if their bod… #67134

Merged
merged 2 commits into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Show const_err lint in addition to the hard error
  • Loading branch information
oli-obk committed Dec 9, 2019
commit c1434716c1dc67f8c96b488121a9b91163516aa3
4 changes: 2 additions & 2 deletions src/test/ui/consts/assoc_const_generic_impl.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#![allow(const_err)]
#![warn(const_err)]

trait ZeroSized: Sized {
const I_AM_ZERO_SIZED: ();
fn requires_zero_size(self);
}

impl<T: Sized> ZeroSized for T {
const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()];
const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()]; //~ WARN any use of this value
fn requires_zero_size(self) {
let () = Self::I_AM_ZERO_SIZED; //~ ERROR erroneous constant encountered
println!("requires_zero_size called");
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/consts/assoc_const_generic_impl.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
warning: any use of this value will cause an error
--> $DIR/assoc_const_generic_impl.rs:9:34
|
LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()];
| -----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
| |
| index out of bounds: the len is 1 but the index is 4
|
note: lint level defined here
--> $DIR/assoc_const_generic_impl.rs:1:9
|
LL | #![warn(const_err)]
| ^^^^^^^^^

error: erroneous constant encountered
--> $DIR/assoc_const_generic_impl.rs:11:18
|
Expand Down