-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Referring to erroneous constants in promoteds must abort the build
- Loading branch information
Showing
14 changed files
with
291 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/ui/const-eval/conditional_array_execution.nll.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
warning: attempt to subtract with overflow | ||
--> $DIR/conditional_array_execution.rs:15:19 | ||
| | ||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; | ||
| ^^^^^ | ||
| | ||
note: lint level defined here | ||
--> $DIR/conditional_array_execution.rs:11:9 | ||
| | ||
LL | #![warn(const_err)] | ||
| ^^^^^^^^^ | ||
|
||
warning: this constant cannot be used | ||
--> $DIR/conditional_array_execution.rs:15:1 | ||
| | ||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; | ||
| ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| attempt to subtract with overflow | ||
|
||
warning: this expression will panic at runtime | ||
--> $DIR/conditional_array_execution.rs:20:20 | ||
| | ||
LL | println!("{}", FOO); | ||
| ^^^ referenced constant has errors | ||
|
||
error[E0080]: erroneous constant used | ||
--> $DIR/conditional_array_execution.rs:20:5 | ||
| | ||
LL | println!("{}", FOO); | ||
| ^^^^^^^^^^^^^^^---^^ | ||
| | | ||
| referenced constant has errors | ||
| | ||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
error[E0080]: erroneous constant used | ||
--> $DIR/conditional_array_execution.rs:20:20 | ||
| | ||
LL | println!("{}", FOO); | ||
| ^^^ referenced constant has errors | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,35 @@ | ||
warning: attempt to subtract with overflow | ||
--> $DIR/conditional_array_execution.rs:16:19 | ||
--> $DIR/conditional_array_execution.rs:15:19 | ||
| | ||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; | ||
| ^^^^^ | ||
| | ||
note: lint level defined here | ||
--> $DIR/conditional_array_execution.rs:12:9 | ||
--> $DIR/conditional_array_execution.rs:11:9 | ||
| | ||
LL | #![warn(const_err)] | ||
| ^^^^^^^^^ | ||
|
||
warning: this constant cannot be used | ||
--> $DIR/conditional_array_execution.rs:16:1 | ||
--> $DIR/conditional_array_execution.rs:15:1 | ||
| | ||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; | ||
| ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| attempt to subtract with overflow | ||
|
||
warning: this expression will panic at runtime | ||
--> $DIR/conditional_array_execution.rs:21:20 | ||
--> $DIR/conditional_array_execution.rs:20:20 | ||
| | ||
LL | println!("{}", FOO); | ||
| ^^^ referenced constant has errors | ||
|
||
error[E0080]: erroneous constant used | ||
--> $DIR/conditional_array_execution.rs:20:20 | ||
| | ||
LL | println!("{}", FOO); | ||
| ^^^ referenced constant has errors | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
warning: attempt to subtract with overflow | ||
--> $DIR/issue-43197.rs:20:20 | ||
| | ||
LL | const X: u32 = 0-1; | ||
| ^^^ | ||
| | ||
note: lint level defined here | ||
--> $DIR/issue-43197.rs:11:9 | ||
| | ||
LL | #![warn(const_err)] | ||
| ^^^^^^^^^ | ||
|
||
warning: this constant cannot be used | ||
--> $DIR/issue-43197.rs:20:5 | ||
| | ||
LL | const X: u32 = 0-1; | ||
| ^^^^^^^^^^^^^^^---^ | ||
| | | ||
| attempt to subtract with overflow | ||
|
||
warning: attempt to subtract with overflow | ||
--> $DIR/issue-43197.rs:23:24 | ||
| | ||
LL | const Y: u32 = foo(0-1); | ||
| ^^^ | ||
|
||
warning: this constant cannot be used | ||
--> $DIR/issue-43197.rs:23:5 | ||
| | ||
LL | const Y: u32 = foo(0-1); | ||
| ^^^^^^^^^^^^^^^^^^^---^^ | ||
| | | ||
| attempt to subtract with overflow | ||
|
||
warning: this expression will panic at runtime | ||
--> $DIR/issue-43197.rs:26:23 | ||
| | ||
LL | println!("{} {}", X, Y); | ||
| ^ referenced constant has errors | ||
|
||
warning: this expression will panic at runtime | ||
--> $DIR/issue-43197.rs:26:26 | ||
| | ||
LL | println!("{} {}", X, Y); | ||
| ^ referenced constant has errors | ||
|
||
error[E0080]: erroneous constant used | ||
--> $DIR/issue-43197.rs:26:5 | ||
| | ||
LL | println!("{} {}", X, Y); | ||
| ^^^^^^^^^^^^^^^^^^-^^^^^ | ||
| | | ||
| referenced constant has errors | ||
| | ||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
error[E0080]: erroneous constant used | ||
--> $DIR/issue-43197.rs:26:26 | ||
| | ||
LL | println!("{} {}", X, Y); | ||
| ^ referenced constant has errors | ||
|
||
error[E0080]: erroneous constant used | ||
--> $DIR/issue-43197.rs:26:23 | ||
| | ||
LL | println!("{} {}", X, Y); | ||
| ^ referenced constant has errors | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,61 @@ | ||
warning: attempt to subtract with overflow | ||
--> $DIR/issue-43197.rs:21:20 | ||
--> $DIR/issue-43197.rs:20:20 | ||
| | ||
LL | const X: u32 = 0-1; | ||
| ^^^ | ||
| | ||
note: lint level defined here | ||
--> $DIR/issue-43197.rs:12:9 | ||
--> $DIR/issue-43197.rs:11:9 | ||
| | ||
LL | #![warn(const_err)] | ||
| ^^^^^^^^^ | ||
|
||
warning: this constant cannot be used | ||
--> $DIR/issue-43197.rs:21:5 | ||
--> $DIR/issue-43197.rs:20:5 | ||
| | ||
LL | const X: u32 = 0-1; | ||
| ^^^^^^^^^^^^^^^---^ | ||
| | | ||
| attempt to subtract with overflow | ||
|
||
warning: attempt to subtract with overflow | ||
--> $DIR/issue-43197.rs:24:24 | ||
--> $DIR/issue-43197.rs:23:24 | ||
| | ||
LL | const Y: u32 = foo(0-1); | ||
| ^^^ | ||
|
||
warning: this constant cannot be used | ||
--> $DIR/issue-43197.rs:24:5 | ||
--> $DIR/issue-43197.rs:23:5 | ||
| | ||
LL | const Y: u32 = foo(0-1); | ||
| ^^^^^^^^^^^^^^^^^^^---^^ | ||
| | | ||
| attempt to subtract with overflow | ||
|
||
warning: this expression will panic at runtime | ||
--> $DIR/issue-43197.rs:27:23 | ||
--> $DIR/issue-43197.rs:26:23 | ||
| | ||
LL | println!("{} {}", X, Y); | ||
| ^ referenced constant has errors | ||
|
||
warning: this expression will panic at runtime | ||
--> $DIR/issue-43197.rs:27:26 | ||
--> $DIR/issue-43197.rs:26:26 | ||
| | ||
LL | println!("{} {}", X, Y); | ||
| ^ referenced constant has errors | ||
|
||
error[E0080]: erroneous constant used | ||
--> $DIR/issue-43197.rs:26:26 | ||
| | ||
LL | println!("{} {}", X, Y); | ||
| ^ referenced constant has errors | ||
|
||
error[E0080]: erroneous constant used | ||
--> $DIR/issue-43197.rs:26:23 | ||
| | ||
LL | println!("{} {}", X, Y); | ||
| ^ referenced constant has errors | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0080]: erroneous constant used | ||
--> $DIR/issue-44578.rs:35:5 | ||
| | ||
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); | ||
| ^^^^^^^^^^^^^^^--------------------------^^ | ||
| | | ||
| referenced constant has errors | ||
| | ||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
error[E0080]: erroneous constant used | ||
--> $DIR/issue-44578.rs:35:20 | ||
| | ||
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,9 @@ | ||
warning: this expression will panic at runtime | ||
--> $DIR/issue-44578.rs:36:20 | ||
error[E0080]: erroneous constant used | ||
--> $DIR/issue-44578.rs:35:20 | ||
| | ||
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); //~ WARN const_err | ||
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors | ||
| | ||
note: lint level defined here | ||
--> $DIR/issue-44578.rs:12:9 | ||
| | ||
LL | #![warn(const_err)] | ||
| ^^^^^^^^^ | ||
|
||
warning: this expression will panic at runtime | ||
--> $DIR/issue-44578.rs:36:20 | ||
| | ||
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); //~ WARN const_err | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors | ||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
trait C { | ||
const BOO: usize; | ||
} | ||
|
||
trait Foo<T> { | ||
const BAR: usize; | ||
} | ||
|
||
struct A<T>(T); | ||
|
||
impl<T: C> Foo<T> for A<T> { | ||
const BAR: usize = [5, 6, 7][T::BOO]; | ||
} | ||
|
||
fn foo<T: C>() -> &'static usize { | ||
&<A<T> as Foo<T>>::BAR //~ ERROR erroneous constant used | ||
} | ||
|
||
impl C for () { | ||
const BOO: usize = 42; | ||
} | ||
|
||
impl C for u32 { | ||
const BOO: usize = 1; | ||
} | ||
|
||
fn main() { | ||
println!("{:x}", foo::<()>() as *const usize as usize); | ||
println!("{:x}", foo::<u32>() as *const usize as usize); | ||
println!("{:x}", foo::<()>()); | ||
println!("{:x}", foo::<u32>()); | ||
} |
Oops, something went wrong.