From fc4b916b187b3a57226d9be95276372fe55c3f4b Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 25 Feb 2019 23:07:12 +0000 Subject: [PATCH 01/14] Add a test for #10876 --- src/test/ui/borrowck/issue-10876.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/test/ui/borrowck/issue-10876.rs diff --git a/src/test/ui/borrowck/issue-10876.rs b/src/test/ui/borrowck/issue-10876.rs new file mode 100644 index 0000000000000..d8fff5f17760a --- /dev/null +++ b/src/test/ui/borrowck/issue-10876.rs @@ -0,0 +1,19 @@ +// run-pass + +#![feature(nll)] + +enum Nat { + S(Box), + Z +} +fn test(x: &mut Nat) { + let mut p = &mut *x; + loop { + match p { + &mut Nat::Z => break, + &mut Nat::S(ref mut n) => p = &mut *n + } + } +} + +fn main() {} From e206d4e6126eee4e0619b7b99edd03449f90907c Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 25 Feb 2019 23:54:49 +0000 Subject: [PATCH 02/14] Add tests for #26448 --- src/test/ui/issues/issue-26448-1.rs | 13 +++++++++++++ src/test/ui/issues/issue-26448-2.rs | 21 +++++++++++++++++++++ src/test/ui/issues/issue-26448-3.rs | 25 +++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 src/test/ui/issues/issue-26448-1.rs create mode 100644 src/test/ui/issues/issue-26448-2.rs create mode 100644 src/test/ui/issues/issue-26448-3.rs diff --git a/src/test/ui/issues/issue-26448-1.rs b/src/test/ui/issues/issue-26448-1.rs new file mode 100644 index 0000000000000..7d2d75bf2e878 --- /dev/null +++ b/src/test/ui/issues/issue-26448-1.rs @@ -0,0 +1,13 @@ +// run-pass + +pub trait Foo { + fn foo(self) -> T; +} + +impl<'a, T> Foo for &'a str where &'a str: Into { + fn foo(self) -> T { + panic!(); + } +} + +fn main() {} diff --git a/src/test/ui/issues/issue-26448-2.rs b/src/test/ui/issues/issue-26448-2.rs new file mode 100644 index 0000000000000..17e7c1f977a6d --- /dev/null +++ b/src/test/ui/issues/issue-26448-2.rs @@ -0,0 +1,21 @@ +// run-pass + +pub struct Bar { + items: Vec<&'static str>, + inner: T, +} + +pub trait IntoBar { + fn into_bar(self) -> Bar; +} + +impl<'a, T> IntoBar for &'a str where &'a str: Into { + fn into_bar(self) -> Bar { + Bar { + items: Vec::new(), + inner: self.into(), + } + } +} + +fn main() {} diff --git a/src/test/ui/issues/issue-26448-3.rs b/src/test/ui/issues/issue-26448-3.rs new file mode 100644 index 0000000000000..e57352e57f4fc --- /dev/null +++ b/src/test/ui/issues/issue-26448-3.rs @@ -0,0 +1,25 @@ +// run-pass + +pub struct Item { + _inner: &'static str, +} + +pub struct Bar { + items: Vec, + inner: T, +} + +pub trait IntoBar { + fn into_bar(self) -> Bar; +} + +impl<'a, T> IntoBar for &'a str where &'a str: Into { + fn into_bar(self) -> Bar { + Bar { + items: Vec::new(), + inner: self.into(), + } + } +} + +fn main() {} From 93ff7dc25ff7e5146e2bc47bc915a7cd87278c13 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 25 Feb 2019 23:55:00 +0000 Subject: [PATCH 03/14] Add a test for #26619 --- src/test/ui/issues/issue-26619.rs | 24 ++++++++++++++++++++++++ src/test/ui/issues/issue-26619.stderr | 12 ++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/test/ui/issues/issue-26619.rs create mode 100644 src/test/ui/issues/issue-26619.stderr diff --git a/src/test/ui/issues/issue-26619.rs b/src/test/ui/issues/issue-26619.rs new file mode 100644 index 0000000000000..cd89c674e4996 --- /dev/null +++ b/src/test/ui/issues/issue-26619.rs @@ -0,0 +1,24 @@ +#![feature(slice_patterns)] + +pub struct History<'a> { pub _s: &'a str } + +impl<'a> History<'a> { + pub fn get_page(&self) { + for s in vec!["1|2".to_string()].into_iter().filter_map(|ref line| self.make_entry(line)) { + //~^ ERROR borrowed value does not live long enough + println!("{:?}", s); + } + } + + fn make_entry(&self, s: &'a String) -> Option<&str> { + let parts: Vec<_> = s.split('|').collect(); + println!("{:?} -> {:?}", s, parts); + + if let [commit, ..] = &parts[..] { Some(commit) } else { None } + } +} + +fn main() { + let h = History{ _s: "" }; + h.get_page(); +} diff --git a/src/test/ui/issues/issue-26619.stderr b/src/test/ui/issues/issue-26619.stderr new file mode 100644 index 0000000000000..3ac6c4e308d21 --- /dev/null +++ b/src/test/ui/issues/issue-26619.stderr @@ -0,0 +1,12 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/issue-26619.rs:7:66 + | +LL | for s in vec!["1|2".to_string()].into_iter().filter_map(|ref line| self.make_entry(line)) { + | ^^^^^^^^ -- temporary value needs to live until here + | | | + | | temporary value dropped here while still borrowed + | temporary value does not live long enough + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. From 987d71f8f6655e0f79ff3bec1074bcd8793b4b89 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 25 Feb 2019 23:55:08 +0000 Subject: [PATCH 04/14] Add a test for #44127 --- src/test/ui/issues/issue-44127.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/test/ui/issues/issue-44127.rs diff --git a/src/test/ui/issues/issue-44127.rs b/src/test/ui/issues/issue-44127.rs new file mode 100644 index 0000000000000..21b2e68264a14 --- /dev/null +++ b/src/test/ui/issues/issue-44127.rs @@ -0,0 +1,17 @@ +// run-pass + +#![feature(decl_macro)] + +pub struct Foo { + bar: u32, +} +pub macro pattern($a:pat) { + Foo { bar: $a } +} + +fn main() { + match (Foo { bar: 3 }) { + pattern!(3) => println!("Test OK"), + _ => unreachable!(), + } +} From bdd38263c03a7166f550811247902a624c07749f Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 25 Feb 2019 23:55:16 +0000 Subject: [PATCH 05/14] Add a test for #44255 --- src/test/ui/issues/issue-44255.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/test/ui/issues/issue-44255.rs diff --git a/src/test/ui/issues/issue-44255.rs b/src/test/ui/issues/issue-44255.rs new file mode 100644 index 0000000000000..2245032043257 --- /dev/null +++ b/src/test/ui/issues/issue-44255.rs @@ -0,0 +1,29 @@ +// run-pass + +use std::marker::PhantomData; + +fn main() { + let _arr = [1; >::VAL]; +} + +trait TypeVal { + const VAL: T; +} + +struct Five; + +impl TypeVal for Five { + const VAL: usize = 5; +} + +struct Multiply { + _n: PhantomData, + _m: PhantomData, +} + +impl TypeVal for Multiply + where N: TypeVal, + M: TypeVal, +{ + const VAL: usize = N::VAL * M::VAL; +} From 36b1326a26959c0dc9e7c06b6b3849653a9b265c Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 25 Feb 2019 23:55:25 +0000 Subject: [PATCH 06/14] Add a test for #46101 --- src/test/ui/issues/issue-46101.rs | 4 ++++ src/test/ui/issues/issue-46101.stderr | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/test/ui/issues/issue-46101.rs create mode 100644 src/test/ui/issues/issue-46101.stderr diff --git a/src/test/ui/issues/issue-46101.rs b/src/test/ui/issues/issue-46101.rs new file mode 100644 index 0000000000000..2d9111e9b3a98 --- /dev/null +++ b/src/test/ui/issues/issue-46101.rs @@ -0,0 +1,4 @@ +#![feature(use_extern_macros)] +trait Foo {} +#[derive(Foo::Anything)] //~ ERROR failed to resolve: partially resolved path in a derive macro +struct S; diff --git a/src/test/ui/issues/issue-46101.stderr b/src/test/ui/issues/issue-46101.stderr new file mode 100644 index 0000000000000..f8b95d7a23bf2 --- /dev/null +++ b/src/test/ui/issues/issue-46101.stderr @@ -0,0 +1,14 @@ +error[E0433]: failed to resolve: partially resolved path in a derive macro + --> $DIR/issue-46101.rs:3:10 + | +LL | #[derive(Foo::Anything)] //~ ERROR failed to resolve: partially resolved path in a derive macro + | ^^^^^^^^^^^^^ partially resolved path in a derive macro + +error[E0601]: `main` function not found in crate `issue_46101` + | + = note: consider adding a `main` function to `$DIR/issue-46101.rs` + +error: aborting due to 2 previous errors + +Some errors occurred: E0433, E0601. +For more information about an error, try `rustc --explain E0433`. From 1068424cbfc98fc0d61f8100e31b5361ea008b34 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 25 Feb 2019 23:55:34 +0000 Subject: [PATCH 07/14] Add a test for #55731 --- src/test/ui/issues/issue-55731.rs | 52 +++++++++++++++++++++++++++ src/test/ui/issues/issue-55731.stderr | 12 +++++++ 2 files changed, 64 insertions(+) create mode 100644 src/test/ui/issues/issue-55731.rs create mode 100644 src/test/ui/issues/issue-55731.stderr diff --git a/src/test/ui/issues/issue-55731.rs b/src/test/ui/issues/issue-55731.rs new file mode 100644 index 0000000000000..7b4f4e2cd3b40 --- /dev/null +++ b/src/test/ui/issues/issue-55731.rs @@ -0,0 +1,52 @@ +use std::marker::PhantomData; + +trait DistributedIterator { + fn reduce(self) + where + Self: Sized, + { + unreachable!() + } +} + +trait DistributedIteratorMulti { + type Item; +} + +struct Connect(PhantomData); +impl DistributedIteratorMulti<&'a ()>> DistributedIterator for Connect where {} + +struct Cloned(PhantomData); +impl<'a, Source> DistributedIteratorMulti<&'a Source> for Cloned<&'a Source> { + type Item = (); +} + +struct Map { + i: I, + f: F, +} +impl, F, Source> DistributedIteratorMulti for Map +where + F: A<>::Item>, +{ + type Item = (); +} + +trait A {} + +struct X; +impl A<()> for X {} + +fn multi(_reducer: I) +where + I: for<'a> DistributedIteratorMulti<&'a ()>, +{ + DistributedIterator::reduce(Connect::(PhantomData)) +} + +fn main() { + multi(Map { //~ ERROR implementation of `DistributedIteratorMulti` is not general enough + i: Cloned(PhantomData), + f: X, + }); +} diff --git a/src/test/ui/issues/issue-55731.stderr b/src/test/ui/issues/issue-55731.stderr new file mode 100644 index 0000000000000..67f2053de1ebe --- /dev/null +++ b/src/test/ui/issues/issue-55731.stderr @@ -0,0 +1,12 @@ +error: implementation of `DistributedIteratorMulti` is not general enough + --> $DIR/issue-55731.rs:48:5 + | +LL | multi(Map { //~ ERROR implementation of `DistributedIteratorMulti` is not general enough + | ^^^^^ + | + = note: Due to a where-clause on `multi`, + = note: `Map, X>` must implement `DistributedIteratorMulti<&'0 ()>`, for any lifetime `'0` + = note: but `Map, X>` actually implements `DistributedIteratorMulti<&'1 ()>`, for some specific lifetime `'1` + +error: aborting due to previous error + From 525dc46018232197f8b4412e3c615f5659e0c567 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 25 Feb 2019 23:55:43 +0000 Subject: [PATCH 08/14] Add a test for #57781 --- src/test/ui/issues/issue-57781.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/test/ui/issues/issue-57781.rs diff --git a/src/test/ui/issues/issue-57781.rs b/src/test/ui/issues/issue-57781.rs new file mode 100644 index 0000000000000..f5015aaf5d81f --- /dev/null +++ b/src/test/ui/issues/issue-57781.rs @@ -0,0 +1,20 @@ +// run-pass + +use std::cell::UnsafeCell; +use std::collections::HashMap; + +struct OnceCell { + _value: UnsafeCell>, +} + +impl OnceCell { + const INIT: OnceCell = OnceCell { + _value: UnsafeCell::new(None), + }; +} + +pub fn crash() { + let _ = OnceCell::>::INIT; +} + +fn main() {} From 5fb2d8b68f6efc48db7594ac107acf9f2da4e5bd Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 25 Feb 2019 23:56:10 +0000 Subject: [PATCH 09/14] Add a test for #22892 --- src/test/ui/asm/invalid-inline-asm.rs | 9 +++++++++ src/test/ui/asm/invalid-inline-asm.stderr | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/test/ui/asm/invalid-inline-asm.rs create mode 100644 src/test/ui/asm/invalid-inline-asm.stderr diff --git a/src/test/ui/asm/invalid-inline-asm.rs b/src/test/ui/asm/invalid-inline-asm.rs new file mode 100644 index 0000000000000..1dcded0be0b74 --- /dev/null +++ b/src/test/ui/asm/invalid-inline-asm.rs @@ -0,0 +1,9 @@ +#![feature(asm)] + +fn main() { + let byte = 0; + let port = 0x80; + + unsafe { asm!("out %al, %dx" :: "a" (byte), "d" (port) :: "volatile"); } + //~^ ERROR couldn't allocate input reg for constraint 'a' +} diff --git a/src/test/ui/asm/invalid-inline-asm.stderr b/src/test/ui/asm/invalid-inline-asm.stderr new file mode 100644 index 0000000000000..11a32d3141e08 --- /dev/null +++ b/src/test/ui/asm/invalid-inline-asm.stderr @@ -0,0 +1,8 @@ +error: couldn't allocate input reg for constraint 'a' + --> $DIR/invalid-inline-asm.rs:7:14 + | +LL | unsafe { asm!("out %al, %dx" :: "a" (byte), "d" (port) :: "volatile"); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + From 0976e5e7fe8bd7cb072b9392e64081881874ee44 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 25 Feb 2019 23:56:27 +0000 Subject: [PATCH 10/14] Add a test for #28587 --- src/test/ui/asm/invalid-inline-asm-2.rs | 10 ++++++++++ src/test/ui/asm/invalid-inline-asm-2.stderr | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/test/ui/asm/invalid-inline-asm-2.rs create mode 100644 src/test/ui/asm/invalid-inline-asm-2.stderr diff --git a/src/test/ui/asm/invalid-inline-asm-2.rs b/src/test/ui/asm/invalid-inline-asm-2.rs new file mode 100644 index 0000000000000..7b3f1cdd67949 --- /dev/null +++ b/src/test/ui/asm/invalid-inline-asm-2.rs @@ -0,0 +1,10 @@ +#![feature(asm)] + +fn main() { + let a: usize; + + unsafe { + asm!("" : "=d"(a) : : : ); + //~^ ERROR couldn't allocate output register for constraint 'd' + } +} diff --git a/src/test/ui/asm/invalid-inline-asm-2.stderr b/src/test/ui/asm/invalid-inline-asm-2.stderr new file mode 100644 index 0000000000000..3534a2ea58c7a --- /dev/null +++ b/src/test/ui/asm/invalid-inline-asm-2.stderr @@ -0,0 +1,8 @@ +error: couldn't allocate output register for constraint 'd' + --> $DIR/invalid-inline-asm-2.rs:7:9 + | +LL | asm!("" : "=d"(a) : : : ); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + From 42a89c6b1794cf6ebe3578a7233c9b6497e87c61 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 25 Feb 2019 23:56:53 +0000 Subject: [PATCH 11/14] Add a test for #26577 --- .../ui/block-expression-remove-semicolon.rs | 10 ++++++++++ .../ui/block-expression-remove-semicolon.stderr | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/test/ui/block-expression-remove-semicolon.rs create mode 100644 src/test/ui/block-expression-remove-semicolon.stderr diff --git a/src/test/ui/block-expression-remove-semicolon.rs b/src/test/ui/block-expression-remove-semicolon.rs new file mode 100644 index 0000000000000..afa10b38b9144 --- /dev/null +++ b/src/test/ui/block-expression-remove-semicolon.rs @@ -0,0 +1,10 @@ +fn foo() -> i32 { + 0 +} + +fn main() { + let x: i32 = { + //~^ ERROR mismatched types + foo(); //~ HELP consider removing this semicolon + }; +} diff --git a/src/test/ui/block-expression-remove-semicolon.stderr b/src/test/ui/block-expression-remove-semicolon.stderr new file mode 100644 index 0000000000000..aa4889fc5a577 --- /dev/null +++ b/src/test/ui/block-expression-remove-semicolon.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/block-expression-remove-semicolon.rs:6:18 + | +LL | let x: i32 = { + | __________________^ +LL | | //~^ ERROR mismatched types +LL | | foo(); //~ HELP consider removing this semicolon + | | - help: consider removing this semicolon +LL | | }; + | |_____^ expected i32, found () + | + = note: expected type `i32` + found type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. From 0df193f39e3c38422452d689fd2e0ef6ce53c1eb Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 25 Feb 2019 23:57:08 +0000 Subject: [PATCH 12/14] Add a test for #27054 --- src/test/ui/primitive-binop-lhs-mut.rs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/test/ui/primitive-binop-lhs-mut.rs diff --git a/src/test/ui/primitive-binop-lhs-mut.rs b/src/test/ui/primitive-binop-lhs-mut.rs new file mode 100644 index 0000000000000..4f1c456ace354 --- /dev/null +++ b/src/test/ui/primitive-binop-lhs-mut.rs @@ -0,0 +1,6 @@ +// run-pass + +fn main() { + let x = Box::new(0); + assert_eq!(0, *x + { drop(x); let _ = Box::new(main); 0 }); +} From 70b853d6cb964c74d5444e0d7284a49604dfa413 Mon Sep 17 00:00:00 2001 From: varkor Date: Tue, 26 Feb 2019 20:56:52 +0000 Subject: [PATCH 13/14] Update test for issue #55731 --- src/test/ui/issues/issue-55731.stderr | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/ui/issues/issue-55731.stderr b/src/test/ui/issues/issue-55731.stderr index 67f2053de1ebe..f490b45bf9767 100644 --- a/src/test/ui/issues/issue-55731.stderr +++ b/src/test/ui/issues/issue-55731.stderr @@ -4,9 +4,8 @@ error: implementation of `DistributedIteratorMulti` is not general enough LL | multi(Map { //~ ERROR implementation of `DistributedIteratorMulti` is not general enough | ^^^^^ | - = note: Due to a where-clause on `multi`, - = note: `Map, X>` must implement `DistributedIteratorMulti<&'0 ()>`, for any lifetime `'0` - = note: but `Map, X>` actually implements `DistributedIteratorMulti<&'1 ()>`, for some specific lifetime `'1` + = note: `DistributedIteratorMulti<&'0 ()>` would have to be implemented for the type `Cloned<&()>`, for any lifetime `'0` + = note: but `DistributedIteratorMulti<&'1 ()>` is actually implemented for the type `Cloned<&'1 ()>`, for some specific lifetime `'1` error: aborting due to previous error From c38c9595ec83f590928c1750a91b353a37a12d09 Mon Sep 17 00:00:00 2001 From: varkor Date: Sat, 2 Mar 2019 12:47:39 +0000 Subject: [PATCH 14/14] Ignore WASM on asm tests --- src/test/ui/asm/invalid-inline-asm-2.rs | 3 +++ src/test/ui/asm/invalid-inline-asm-2.stderr | 2 +- src/test/ui/asm/invalid-inline-asm.rs | 3 +++ src/test/ui/asm/invalid-inline-asm.stderr | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/test/ui/asm/invalid-inline-asm-2.rs b/src/test/ui/asm/invalid-inline-asm-2.rs index 7b3f1cdd67949..faa7249ff8115 100644 --- a/src/test/ui/asm/invalid-inline-asm-2.rs +++ b/src/test/ui/asm/invalid-inline-asm-2.rs @@ -1,3 +1,6 @@ +// ignore-wasm +// ignore-emscripten + #![feature(asm)] fn main() { diff --git a/src/test/ui/asm/invalid-inline-asm-2.stderr b/src/test/ui/asm/invalid-inline-asm-2.stderr index 3534a2ea58c7a..41232b9f4b015 100644 --- a/src/test/ui/asm/invalid-inline-asm-2.stderr +++ b/src/test/ui/asm/invalid-inline-asm-2.stderr @@ -1,5 +1,5 @@ error: couldn't allocate output register for constraint 'd' - --> $DIR/invalid-inline-asm-2.rs:7:9 + --> $DIR/invalid-inline-asm-2.rs:10:9 | LL | asm!("" : "=d"(a) : : : ); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/asm/invalid-inline-asm.rs b/src/test/ui/asm/invalid-inline-asm.rs index 1dcded0be0b74..0d9470cf1733d 100644 --- a/src/test/ui/asm/invalid-inline-asm.rs +++ b/src/test/ui/asm/invalid-inline-asm.rs @@ -1,3 +1,6 @@ +// ignore-wasm +// ignore-emscripten + #![feature(asm)] fn main() { diff --git a/src/test/ui/asm/invalid-inline-asm.stderr b/src/test/ui/asm/invalid-inline-asm.stderr index 11a32d3141e08..53e95084f3aa6 100644 --- a/src/test/ui/asm/invalid-inline-asm.stderr +++ b/src/test/ui/asm/invalid-inline-asm.stderr @@ -1,5 +1,5 @@ error: couldn't allocate input reg for constraint 'a' - --> $DIR/invalid-inline-asm.rs:7:14 + --> $DIR/invalid-inline-asm.rs:10:14 | LL | unsafe { asm!("out %al, %dx" :: "a" (byte), "d" (port) :: "volatile"); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^