Skip to content

Commit

Permalink
Auto merge of rust-lang#81718 - m-ou-se:rollup-3ftbymt, r=m-ou-se
Browse files Browse the repository at this point in the history
Rollup of 5 pull requests

Successful merges:

 - rust-lang#80394 (make const_err a future incompat lint)
 - rust-lang#81532 (Remove incorrect `delay_span_bug`)
 - rust-lang#81692 (Update clippy)
 - rust-lang#81715 (Reduce tab formatting assertions to debug only)
 - rust-lang#81716 (Fix non-existent-field ICE for generic fields.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Feb 3, 2021
2 parents 186f7ae + 4617418 commit 120b2a7
Show file tree
Hide file tree
Showing 149 changed files with 1,497 additions and 395 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ impl EmitterWriter {
margin: Margin,
) {
// Tabs are assumed to have been replaced by spaces in calling code.
assert!(!source_string.contains('\t'));
debug_assert!(!source_string.contains('\t'));
let line_len = source_string.len();
// Create the source line we will highlight.
let left = margin.left(line_len);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/styled_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl StyledBuffer {

pub fn render(&self) -> Vec<Vec<StyledString>> {
// Tabs are assumed to have been replaced by spaces in calling code.
assert!(self.text.iter().all(|r| !r.contains(&'\t')));
debug_assert!(self.text.iter().all(|r| !r.contains(&'\t')));

let mut output: Vec<Vec<StyledString>> = vec![];
let mut styled_vec: Vec<StyledString> = vec![];
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ declare_lint! {
pub CONST_ERR,
Deny,
"constant evaluation encountered erroneous expression",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #71800 <https://github.com/rust-lang/rust/issues/71800>",
edition: None,
};
report_in_external_macro
}

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_typeck/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ pub(super) fn check_fn<'a, 'tcx>(
// possible cases.
fcx.check_expr(&body.value);
fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType);
tcx.sess.delay_span_bug(decl.output.span(), "`!Sized` return type");
} else {
fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType);
fcx.check_return_expr(&body.value);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1974,7 +1974,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

field_path.push(candidate_field.ident.normalize_to_macros_2_0());
let field_ty = candidate_field.ty(self.tcx, subst);
if let Some((nested_fields, _)) = self.get_field_candidates(span, &field_ty) {
if let Some((nested_fields, subst)) = self.get_field_candidates(span, &field_ty) {
for field in nested_fields.iter() {
let ident = field.ident.normalize_to_macros_2_0();
if ident == target_field {
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/array-slice-vec/array_const_index-0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const A: &'static [i32] = &[];
const B: i32 = (&A)[1];
//~^ index out of bounds: the length is 0 but the index is 1
//~| ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out

fn main() {
let _ = B;
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/array-slice-vec/array_const_index-0.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ LL | const B: i32 = (&A)[1];
| index out of bounds: the length is 0 but the index is 1
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: aborting due to previous error

1 change: 1 addition & 0 deletions src/test/ui/array-slice-vec/array_const_index-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const A: [i32; 0] = [];
const B: i32 = A[1];
//~^ index out of bounds: the length is 0 but the index is 1
//~| ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out

fn main() {
let _ = B;
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/array-slice-vec/array_const_index-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ LL | const B: i32 = A[1];
| index out of bounds: the length is 0 but the index is 1
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: aborting due to previous error

2 changes: 2 additions & 0 deletions src/test/ui/associated-consts/defaults-not-assumed-fail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ trait Tr {
// `Self::A` must not be assumed to hold inside the trait.
const B: u8 = Self::A + 1;
//~^ ERROR any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out
}

// An impl that doesn't override any constant will NOT cause a const eval error
Expand All @@ -33,6 +34,7 @@ fn main() {
assert_eq!(<() as Tr>::B, 0); // causes the error above
//~^ ERROR evaluation of constant value failed
//~| ERROR erroneous constant used
//~| WARN this was previously accepted by the compiler but is being phased out

assert_eq!(<u8 as Tr>::A, 254);
assert_eq!(<u8 as Tr>::B, 255);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@ LL | const B: u8 = Self::A + 1;
| attempt to compute `u8::MAX + 1_u8`, which would overflow
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error[E0080]: evaluation of constant value failed
--> $DIR/defaults-not-assumed-fail.rs:33:16
--> $DIR/defaults-not-assumed-fail.rs:34:16
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
| ^^^^^^^^^^^^^ referenced constant has errors

error: erroneous constant used
--> $DIR/defaults-not-assumed-fail.rs:33:5
--> $DIR/defaults-not-assumed-fail.rs:34:5
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 3 previous errors
Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/const-ptr/out_of_bounds_read.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
| ------------------------------------------------------
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: any use of this value will cause an error
--> $SRC_DIR/core/src/intrinsics.rs:LL:COL
Expand All @@ -32,6 +34,9 @@ LL | unsafe { copy_nonoverlapping(src, dst, count) }
|
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
| --------------------------------------------------------
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: any use of this value will cause an error
--> $SRC_DIR/core/src/intrinsics.rs:LL:COL
Expand All @@ -49,6 +54,9 @@ LL | unsafe { copy_nonoverlapping(src, dst, count) }
|
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
| --------------------------------------------------------------------
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: aborting due to 3 previous errors

1 change: 1 addition & 0 deletions src/test/ui/consts/assoc_const_generic_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ trait ZeroSized: Sized {

impl<T: Sized> ZeroSized for T {
const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()]; //~ WARN any use of this value
//~| WARN this was previously accepted by the compiler but is being phased out
fn requires_zero_size(self) {
let () = Self::I_AM_ZERO_SIZED; //~ ERROR erroneous constant encountered
println!("requires_zero_size called");
Expand Down
4 changes: 3 additions & 1 deletion src/test/ui/consts/assoc_const_generic_impl.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ note: the lint level is defined here
|
LL | #![warn(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: erroneous constant encountered
--> $DIR/assoc_const_generic_impl.rs:13:18
--> $DIR/assoc_const_generic_impl.rs:14:18
|
LL | let () = Self::I_AM_ZERO_SIZED;
| ^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/consts/assume-type-intrinsics.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ LL | | };
| |______-
|
= note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: aborting due to previous error

5 changes: 5 additions & 0 deletions src/test/ui/consts/const-err-early.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#![deny(const_err)]

pub const A: i8 = -i8::MIN; //~ ERROR const_err
//~| WARN this was previously accepted by the compiler but is being phased out
pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err
//~| WARN this was previously accepted by the compiler but is being phased out
pub const C: u8 = 200u8 * 4; //~ ERROR const_err
//~| WARN this was previously accepted by the compiler but is being phased out
pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err
//~| WARN this was previously accepted by the compiler but is being phased out
pub const E: u8 = [5u8][1]; //~ ERROR const_err
//~| WARN this was previously accepted by the compiler but is being phased out

fn main() {
let _a = A;
Expand Down
22 changes: 18 additions & 4 deletions src/test/ui/consts/const-err-early.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,52 @@ note: the lint level is defined here
|
LL | #![deny(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: any use of this value will cause an error
--> $DIR/const-err-early.rs:4:19
--> $DIR/const-err-early.rs:5:19
|
LL | pub const B: u8 = 200u8 + 200u8;
| ------------------^^^^^^^^^^^^^-
| |
| attempt to compute `200_u8 + 200_u8`, which would overflow
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: any use of this value will cause an error
--> $DIR/const-err-early.rs:5:19
--> $DIR/const-err-early.rs:7:19
|
LL | pub const C: u8 = 200u8 * 4;
| ------------------^^^^^^^^^-
| |
| attempt to compute `200_u8 * 4_u8`, which would overflow
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: any use of this value will cause an error
--> $DIR/const-err-early.rs:6:19
--> $DIR/const-err-early.rs:9:19
|
LL | pub const D: u8 = 42u8 - (42u8 + 1);
| ------------------^^^^^^^^^^^^^^^^^-
| |
| attempt to compute `42_u8 - 43_u8`, which would overflow
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: any use of this value will cause an error
--> $DIR/const-err-early.rs:7:19
--> $DIR/const-err-early.rs:11:19
|
LL | pub const E: u8 = [5u8][1];
| ------------------^^^^^^^^-
| |
| index out of bounds: the length is 1 but the index is 1
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: aborting due to 5 previous errors

4 changes: 4 additions & 0 deletions src/test/ui/consts/const-err-multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

pub const A: i8 = -i8::MIN;
//~^ ERROR const_err
//~| WARN this was previously accepted by the compiler but is being phased out
pub const B: i8 = A;
//~^ ERROR const_err
//~| WARN this was previously accepted by the compiler but is being phased out
pub const C: u8 = A as u8;
//~^ ERROR const_err
//~| WARN this was previously accepted by the compiler but is being phased out
pub const D: i8 = 50 - A;
//~^ ERROR const_err
//~| WARN this was previously accepted by the compiler but is being phased out

fn main() {
let _ = (A, B, C, D);
Expand Down
17 changes: 14 additions & 3 deletions src/test/ui/consts/const-err-multi.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,41 @@ note: the lint level is defined here
|
LL | #![deny(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: any use of this value will cause an error
--> $DIR/const-err-multi.rs:5:19
--> $DIR/const-err-multi.rs:6:19
|
LL | pub const B: i8 = A;
| ------------------^-
| |
| referenced constant has errors
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: any use of this value will cause an error
--> $DIR/const-err-multi.rs:7:19
--> $DIR/const-err-multi.rs:9:19
|
LL | pub const C: u8 = A as u8;
| ------------------^-------
| |
| referenced constant has errors
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: any use of this value will cause an error
--> $DIR/const-err-multi.rs:9:24
--> $DIR/const-err-multi.rs:12:24
|
LL | pub const D: i8 = 50 - A;
| -----------------------^-
| |
| referenced constant has errors
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: aborting due to 4 previous errors

1 change: 1 addition & 0 deletions src/test/ui/consts/const-err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ fn black_box<T>(_: T) {

const FOO: u8 = [5u8][1];
//~^ WARN any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out

fn main() {
black_box((FOO, FOO));
Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/consts/const-err.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ note: the lint level is defined here
|
LL | #![warn(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error[E0080]: erroneous constant used
--> $DIR/const-err.rs:15:16
--> $DIR/const-err.rs:16:16
|
LL | black_box((FOO, FOO));
| ^^^ referenced constant has errors

error[E0080]: erroneous constant used
--> $DIR/const-err.rs:15:21
--> $DIR/const-err.rs:16:21
|
LL | black_box((FOO, FOO));
| ^^^ referenced constant has errors
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/consts/const-eval/conditional_array_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ const X: u32 = 5;
const Y: u32 = 6;
const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
//~^ WARN any use of this value will cause an error
//~| WARN this was previously accepted by the compiler but is being phased out

fn main() {
println!("{}", FOO);
//~^ ERROR
//~| WARN erroneous constant used [const_err]
//~| WARN this was previously accepted by the compiler but is being phased out
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@ note: the lint level is defined here
|
LL | #![warn(const_err)]
| ^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error[E0080]: evaluation of constant value failed
--> $DIR/conditional_array_execution.rs:11:20
--> $DIR/conditional_array_execution.rs:12:20
|
LL | println!("{}", FOO);
| ^^^ referenced constant has errors

warning: erroneous constant used
--> $DIR/conditional_array_execution.rs:11:20
--> $DIR/conditional_array_execution.rs:12:20
|
LL | println!("{}", FOO);
| ^^^ referenced constant has errors
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

error: aborting due to previous error; 2 warnings emitted

Expand Down
Loading

0 comments on commit 120b2a7

Please sign in to comment.