-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #49779 - oli-obk:const_err_regression, r=eddyb
Don't report compile-time errors for promoteds Fixes the regression part of #49760, the missing warnings still are missing r? @eddyb
- Loading branch information
Showing
13 changed files
with
129 additions
and
30 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
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
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
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,17 +1,14 @@ | ||
warning: attempt to subtract with overflow | ||
--> $DIR/conditional_array_execution.rs:13:19 | ||
--> $DIR/conditional_array_execution.rs:15:19 | ||
| | ||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; | ||
| ^^^^^ | ||
| | ||
= note: #[warn(const_err)] on by default | ||
|
||
error[E0080]: constant evaluation error | ||
--> $DIR/conditional_array_execution.rs:17:20 | ||
warning: constant evaluation error | ||
--> $DIR/conditional_array_execution.rs:19:20 | ||
| | ||
LL | println!("{}", FOO); //~ E0080 | ||
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
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,29 +1,26 @@ | ||
warning: attempt to subtract with overflow | ||
--> $DIR/issue-43197.rs:18:20 | ||
--> $DIR/issue-43197.rs:20:20 | ||
| | ||
LL | const X: u32 = 0-1; | ||
| ^^^ | ||
| | ||
= note: #[warn(const_err)] on by default | ||
|
||
error[E0080]: constant evaluation error | ||
--> $DIR/issue-43197.rs:22:23 | ||
warning: constant evaluation error | ||
--> $DIR/issue-43197.rs:24:23 | ||
| | ||
LL | println!("{} {}", X, Y); | ||
| ^ referenced constant has errors | ||
|
||
warning: attempt to subtract with overflow | ||
--> $DIR/issue-43197.rs:20:24 | ||
--> $DIR/issue-43197.rs:22:24 | ||
| | ||
LL | const Y: u32 = foo(0-1); | ||
| ^^^ | ||
|
||
error[E0080]: constant evaluation error | ||
--> $DIR/issue-43197.rs:22:26 | ||
warning: constant evaluation error | ||
--> $DIR/issue-43197.rs:24:26 | ||
| | ||
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
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,14 @@ | ||
warning: constant evaluation error | ||
--> $DIR/issue-44578.rs:35:20 | ||
| | ||
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); //~ WARN const_err | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors | ||
| | ||
= note: #[warn(const_err)] on by default | ||
|
||
warning: constant evaluation error | ||
--> $DIR/issue-44578.rs:35:20 | ||
| | ||
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); //~ WARN const_err | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors | ||
|
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,28 @@ | ||
// 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. | ||
|
||
// compile-pass | ||
// compile-flags: -O | ||
fn main() { | ||
println!("{}", 0u32 - 1); | ||
//~^ WARN const_err | ||
//~| WARN const_err | ||
let _x = 0u32 - 1; | ||
//~^ WARN const_err | ||
println!("{}", 1/(1-1)); | ||
//~^ WARN const_err | ||
//~| WARN const_err | ||
let _x = 1/(1-1); | ||
//~^ WARN const_err | ||
//~| WARN const_err | ||
println!("{}", 1/(false as u32)); | ||
//~^ WARN const_err | ||
let _x = 1/(false as u32); | ||
} |
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,50 @@ | ||
warning: constant evaluation error | ||
--> $DIR/promoted_errors.rs:14:20 | ||
| | ||
LL | println!("{}", 0u32 - 1); | ||
| ^^^^^^^^ attempted to do overflowing math | ||
| | ||
= note: #[warn(const_err)] on by default | ||
|
||
warning: constant evaluation error | ||
--> $DIR/promoted_errors.rs:14:20 | ||
| | ||
LL | println!("{}", 0u32 - 1); | ||
| ^^^^^^^^ attempted to do overflowing math | ||
|
||
warning: constant evaluation error | ||
--> $DIR/promoted_errors.rs:17:14 | ||
| | ||
LL | let _x = 0u32 - 1; | ||
| ^^^^^^^^ attempted to do overflowing math | ||
|
||
warning: attempt to divide by zero | ||
--> $DIR/promoted_errors.rs:19:20 | ||
| | ||
LL | println!("{}", 1/(1-1)); | ||
| ^^^^^^^ | ||
|
||
warning: constant evaluation error | ||
--> $DIR/promoted_errors.rs:19:20 | ||
| | ||
LL | println!("{}", 1/(1-1)); | ||
| ^^^^^^^ attempted to do overflowing math | ||
|
||
warning: attempt to divide by zero | ||
--> $DIR/promoted_errors.rs:22:14 | ||
| | ||
LL | let _x = 1/(1-1); | ||
| ^^^^^^^ | ||
|
||
warning: constant evaluation error | ||
--> $DIR/promoted_errors.rs:22:14 | ||
| | ||
LL | let _x = 1/(1-1); | ||
| ^^^^^^^ attempted to do overflowing math | ||
|
||
warning: constant evaluation error | ||
--> $DIR/promoted_errors.rs:25:20 | ||
| | ||
LL | println!("{}", 1/(false as u32)); | ||
| ^^^^^^^^^^^^^^^^ attempted to do overflowing math | ||
|