diff options
| author | bors <bors@rust-lang.org> | 2019-06-25 18:35:41 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-06-25 18:35:41 +0000 |
| commit | 5f9c0448dde167128d668da4555879f64e56af1d (patch) | |
| tree | 6e99033118ee25fc4064c4b2968f43132ac8f67e /src/test | |
| parent | 303f77ee1d60e1b351ff6478143dd866403c27f5 (diff) | |
| parent | d406d89b3182f05629dd949932bc10a9db28140e (diff) | |
| download | rust-5f9c0448dde167128d668da4555879f64e56af1d.tar.gz rust-5f9c0448dde167128d668da4555879f64e56af1d.zip | |
Auto merge of #62119 - Centril:rollup-el20wu0, r=Centril
Rollup of 7 pull requests Successful merges: - #61814 (Fix an ICE with uninhabited consts) - #61987 (rustc: produce AST instead of HIR from `hir::lowering::Resolver` methods.) - #62055 (Fix error counting) - #62078 (Remove built-in derive macros `Send` and `Sync`) - #62085 (Add test for issue-38591) - #62091 (HirIdification: almost there) - #62096 (Implement From<Local> for Place and PlaceBase) Failed merges: r? @ghost
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/consts/enum-discr-type-err.rs | 29 | ||||
| -rw-r--r-- | src/test/ui/consts/enum-discr-type-err.stderr | 19 | ||||
| -rw-r--r-- | src/test/ui/consts/uninhabited-const-issue-61744.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/consts/uninhabited-const-issue-61744.stderr | 24 | ||||
| -rw-r--r-- | src/test/ui/derives/deriving-bounds.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/derives/deriving-bounds.stderr | 16 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-33571.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-33571.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-38591.rs | 10 |
9 files changed, 125 insertions, 6 deletions
diff --git a/src/test/ui/consts/enum-discr-type-err.rs b/src/test/ui/consts/enum-discr-type-err.rs new file mode 100644 index 00000000000..d66c4f47d03 --- /dev/null +++ b/src/test/ui/consts/enum-discr-type-err.rs @@ -0,0 +1,29 @@ +// Test that we mark enum discriminant values as having errors, even when the +// diagnostic is deduplicated. + +struct F; +struct T; + +impl F { + const V: i32 = 0; +} + +impl T { + const V: i32 = 0; +} + +macro_rules! mac { + ($( $v: ident = $s: ident,)*) => { + enum E { + $( $v = $s::V, )* + //~^ ERROR mismatched types + } + } +} + +mac! { + A = F, + B = T, +} + +fn main() {} diff --git a/src/test/ui/consts/enum-discr-type-err.stderr b/src/test/ui/consts/enum-discr-type-err.stderr new file mode 100644 index 00000000000..3c4fac7327d --- /dev/null +++ b/src/test/ui/consts/enum-discr-type-err.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/enum-discr-type-err.rs:18:21 + | +LL | $( $v = $s::V, )* + | ^^^^^ expected isize, found i32 +... +LL | / mac! { +LL | | A = F, +LL | | B = T, +LL | | } + | |_- in this macro invocation +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 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/consts/uninhabited-const-issue-61744.rs b/src/test/ui/consts/uninhabited-const-issue-61744.rs new file mode 100644 index 00000000000..21fbbf8cfb5 --- /dev/null +++ b/src/test/ui/consts/uninhabited-const-issue-61744.rs @@ -0,0 +1,19 @@ +// compile-fail + +pub const unsafe fn fake_type<T>() -> T { + hint_unreachable() +} + +pub const unsafe fn hint_unreachable() -> ! { + fake_type() //~ ERROR any use of this value will cause an error +} + +trait Const { + const CONSTANT: i32 = unsafe { fake_type() }; +} + +impl <T> Const for T {} + +pub fn main() -> () { + dbg!(i32::CONSTANT); //~ ERROR erroneous constant used +} diff --git a/src/test/ui/consts/uninhabited-const-issue-61744.stderr b/src/test/ui/consts/uninhabited-const-issue-61744.stderr new file mode 100644 index 00000000000..5c285543711 --- /dev/null +++ b/src/test/ui/consts/uninhabited-const-issue-61744.stderr @@ -0,0 +1,24 @@ +error: any use of this value will cause an error + --> $DIR/uninhabited-const-issue-61744.rs:8:5 + | +LL | fake_type() + | ^^^^^^^^^^^ + | | + | tried to call a function with return type T passing return place of type ! + | inside call to `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:4:5 + | inside call to `fake_type::<i32>` at $DIR/uninhabited-const-issue-61744.rs:12:36 +... +LL | const CONSTANT: i32 = unsafe { fake_type() }; + | --------------------------------------------- + | + = note: #[deny(const_err)] on by default + +error[E0080]: erroneous constant used + --> $DIR/uninhabited-const-issue-61744.rs:18:10 + | +LL | dbg!(i32::CONSTANT); + | ^^^^^^^^^^^^^ referenced constant has errors + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/derives/deriving-bounds.rs b/src/test/ui/derives/deriving-bounds.rs index 607cfa1bb2c..52659bd11e0 100644 --- a/src/test/ui/derives/deriving-bounds.rs +++ b/src/test/ui/derives/deriving-bounds.rs @@ -1,9 +1,9 @@ #[derive(Send)] -//~^ ERROR this unsafe trait should be implemented explicitly +//~^ ERROR cannot find derive macro `Send` in this scope struct Test; #[derive(Sync)] -//~^ ERROR this unsafe trait should be implemented explicitly +//~^ ERROR cannot find derive macro `Sync` in this scope struct Test1; pub fn main() {} diff --git a/src/test/ui/derives/deriving-bounds.stderr b/src/test/ui/derives/deriving-bounds.stderr index deb84fd99bd..99976da72da 100644 --- a/src/test/ui/derives/deriving-bounds.stderr +++ b/src/test/ui/derives/deriving-bounds.stderr @@ -1,10 +1,22 @@ -error: this unsafe trait should be implemented explicitly +error: cannot find derive macro `Send` in this scope + --> $DIR/deriving-bounds.rs:1:10 + | +LL | #[derive(Send)] + | ^^^^ + | +note: unsafe traits like `Send` should be implemented explicitly --> $DIR/deriving-bounds.rs:1:10 | LL | #[derive(Send)] | ^^^^ -error: this unsafe trait should be implemented explicitly +error: cannot find derive macro `Sync` in this scope + --> $DIR/deriving-bounds.rs:5:10 + | +LL | #[derive(Sync)] + | ^^^^ + | +note: unsafe traits like `Sync` should be implemented explicitly --> $DIR/deriving-bounds.rs:5:10 | LL | #[derive(Sync)] diff --git a/src/test/ui/issues/issue-33571.rs b/src/test/ui/issues/issue-33571.rs index 223bbc3ff5e..147fb3fa8cf 100644 --- a/src/test/ui/issues/issue-33571.rs +++ b/src/test/ui/issues/issue-33571.rs @@ -1,5 +1,5 @@ #[derive(Clone, - Sync, //~ ERROR this unsafe trait should be implemented explicitly + Sync, //~ ERROR cannot find derive macro `Sync` in this scope Copy)] enum Foo {} diff --git a/src/test/ui/issues/issue-33571.stderr b/src/test/ui/issues/issue-33571.stderr index 5d83a08e907..78e72020774 100644 --- a/src/test/ui/issues/issue-33571.stderr +++ b/src/test/ui/issues/issue-33571.stderr @@ -1,4 +1,10 @@ -error: this unsafe trait should be implemented explicitly +error: cannot find derive macro `Sync` in this scope + --> $DIR/issue-33571.rs:2:10 + | +LL | Sync, + | ^^^^ + | +note: unsafe traits like `Sync` should be implemented explicitly --> $DIR/issue-33571.rs:2:10 | LL | Sync, diff --git a/src/test/ui/issues/issue-38591.rs b/src/test/ui/issues/issue-38591.rs new file mode 100644 index 00000000000..7aa71f8b9eb --- /dev/null +++ b/src/test/ui/issues/issue-38591.rs @@ -0,0 +1,10 @@ +// run-pass + +struct S<T> { + t : T, + s : Box<S<fn(u : T)>> +} + +fn f(x : S<u32>) {} + +fn main () {} |
