about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-06-11 13:15:53 +0200
committerGitHub <noreply@github.com>2020-06-11 13:15:53 +0200
commit298467ee9a7fa1bbc93383c3a67ea569a6e7c22c (patch)
treea8dc5451a4b50b0a62d05c8b03d3a8d5480e7b74 /src/test/ui
parent3ddf48053e83f4949d00dcaf6eb8d9e28fc6bb95 (diff)
parent6da17d244b08e5f14edd1645fbd07d1f042d00b7 (diff)
Rollup merge of #72380 - lcnr:const_context, r=estebank
Fix `is_const_context`, update `check_for_cast`

A better version of #71477

Adds `fn enclosing_body_owner` and uses it in `is_const_context`.
`is_const_context` now uses the same mechanism as `mir_const_qualif` as it was previously incorrect.
Renames `is_const_context` to `is_inside_const_context`.

I also updated `check_for_cast` in the second commit, so r? @estebank

(I removed one lvl of indentation, so it might be easier to review by hiding whitespace changes)
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/consts/enum-discr-type-err.stderr8
-rw-r--r--src/test/ui/issues/issue-31910.stderr5
-rw-r--r--src/test/ui/numeric/const-scope.stderr10
-rw-r--r--src/test/ui/repeat_count.rs3
-rw-r--r--src/test/ui/repeat_count.stderr21
5 files changed, 24 insertions, 23 deletions
diff --git a/src/test/ui/consts/enum-discr-type-err.stderr b/src/test/ui/consts/enum-discr-type-err.stderr
index 492b79e2e60..9834a99b79a 100644
--- a/src/test/ui/consts/enum-discr-type-err.stderr
+++ b/src/test/ui/consts/enum-discr-type-err.stderr
@@ -11,10 +11,6 @@ LL | | }
    | |_- in this macro invocation
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
-help: you can convert an `i32` to `isize` and panic if the converted value wouldn't fit
-   |
-LL |             $( $v = $s::V.try_into().unwrap(), )*
-   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/enum-discr-type-err.rs:18:21
@@ -29,10 +25,6 @@ LL | | }
    | |_- in this macro invocation
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
-help: you can convert an `i32` to `isize` and panic if the converted value wouldn't fit
-   |
-LL |             $( $v = $s::V.try_into().unwrap(), )*
-   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/issues/issue-31910.stderr b/src/test/ui/issues/issue-31910.stderr
index c5c988cdaa7..2603c944207 100644
--- a/src/test/ui/issues/issue-31910.stderr
+++ b/src/test/ui/issues/issue-31910.stderr
@@ -3,11 +3,6 @@ error[E0308]: mismatched types
    |
 LL |     X = Trait::Number,
    |         ^^^^^^^^^^^^^ expected `isize`, found `i32`
-   |
-help: you can convert an `i32` to `isize` and panic if the converted value wouldn't fit
-   |
-LL |     X = Trait::Number.try_into().unwrap(),
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/numeric/const-scope.stderr b/src/test/ui/numeric/const-scope.stderr
index 6e1990e3a72..d7f18e19b41 100644
--- a/src/test/ui/numeric/const-scope.stderr
+++ b/src/test/ui/numeric/const-scope.stderr
@@ -3,6 +3,11 @@ error[E0308]: mismatched types
    |
 LL | const C: i32 = 1i8;
    |                ^^^ expected `i32`, found `i8`
+   |
+help: change the type of the numeric literal from `i8` to `i32`
+   |
+LL | const C: i32 = 1i32;
+   |                ^^^^
 
 error[E0308]: mismatched types
   --> $DIR/const-scope.rs:2:15
@@ -17,6 +22,11 @@ LL |     let c: i32 = 1i8;
    |            ---   ^^^ expected `i32`, found `i8`
    |            |
    |            expected due to this
+   |
+help: change the type of the numeric literal from `i8` to `i32`
+   |
+LL |     let c: i32 = 1i32;
+   |                  ^^^^
 
 error[E0308]: mismatched types
   --> $DIR/const-scope.rs:6:17
diff --git a/src/test/ui/repeat_count.rs b/src/test/ui/repeat_count.rs
index aca7af144a9..7e30491f0bd 100644
--- a/src/test/ui/repeat_count.rs
+++ b/src/test/ui/repeat_count.rs
@@ -22,6 +22,9 @@ fn main() {
     let f = [0_usize; -1_isize];
     //~^ ERROR mismatched types
     //~| expected `usize`, found `isize`
+    let f = [0; 4u8];
+    //~^ ERROR mismatched types
+    //~| expected `usize`, found `u8`
     struct G {
         g: (),
     }
diff --git a/src/test/ui/repeat_count.stderr b/src/test/ui/repeat_count.stderr
index 4a2d1d9f921..6a081e23d9d 100644
--- a/src/test/ui/repeat_count.stderr
+++ b/src/test/ui/repeat_count.stderr
@@ -29,7 +29,7 @@ LL |     let e = [0; "foo"];
    |                 ^^^^^ expected `usize`, found `&str`
 
 error[E0308]: mismatched types
-  --> $DIR/repeat_count.rs:28:17
+  --> $DIR/repeat_count.rs:31:17
    |
 LL |     let g = [0; G { g: () }];
    |                 ^^^^^^^^^^^ expected `usize`, found struct `main::G`
@@ -39,24 +39,25 @@ error[E0308]: mismatched types
    |
 LL |     let f = [0; -4_isize];
    |                 ^^^^^^^^ expected `usize`, found `isize`
-   |
-help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit
-   |
-LL |     let f = [0; (-4_isize).try_into().unwrap()];
-   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/repeat_count.rs:22:23
    |
 LL |     let f = [0_usize; -1_isize];
    |                       ^^^^^^^^ expected `usize`, found `isize`
+
+error[E0308]: mismatched types
+  --> $DIR/repeat_count.rs:25:17
+   |
+LL |     let f = [0; 4u8];
+   |                 ^^^ expected `usize`, found `u8`
    |
-help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit
+help: change the type of the numeric literal from `u8` to `usize`
    |
-LL |     let f = [0_usize; (-1_isize).try_into().unwrap()];
-   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     let f = [0; 4usize];
+   |                 ^^^^^^
 
-error: aborting due to 8 previous errors
+error: aborting due to 9 previous errors
 
 Some errors have detailed explanations: E0308, E0435.
 For more information about an error, try `rustc --explain E0308`.