From 0e9aa75bcdf7653d1755f43547969319a559c027 Mon Sep 17 00:00:00 2001 From: Caio Date: Tue, 13 Feb 2024 18:08:25 -0300 Subject: Move tests --- src/tools/tidy/src/ui_tests.rs | 2 +- tests/ui/closures/issue-10682.rs | 13 ++++++++ tests/ui/consts/issue-44255.rs | 29 +++++++++++++++++ tests/ui/extern/issue-18576.rs | 16 +++++++++ tests/ui/extern/issue-18819.rs | 18 ++++++++++ tests/ui/extern/issue-18819.stderr | 30 +++++++++++++++++ tests/ui/fmt/issue-23781.rs | 29 +++++++++++++++++ tests/ui/hygiene/issue-29746.rs | 36 ++++++++++++++++++++ tests/ui/inference/issue-12028.rs | 38 ++++++++++++++++++++++ tests/ui/inference/issue-12028.stderr | 15 +++++++++ tests/ui/issues/issue-10682.rs | 13 -------- tests/ui/issues/issue-12028.rs | 38 ---------------------- tests/ui/issues/issue-12028.stderr | 15 --------- tests/ui/issues/issue-18576.rs | 16 --------- tests/ui/issues/issue-18819.rs | 18 ---------- tests/ui/issues/issue-18819.stderr | 30 ----------------- tests/ui/issues/issue-19102.rs | 12 ------- tests/ui/issues/issue-19707.rs | 7 ---- tests/ui/issues/issue-19707.stderr | 36 -------------------- tests/ui/issues/issue-23781.rs | 29 ----------------- tests/ui/issues/issue-29746.rs | 36 -------------------- tests/ui/issues/issue-44255.rs | 29 ----------------- .../issue-5008-borrowed-traitobject-method-call.rs | 34 ------------------- tests/ui/lifetimes/issue-19707.rs | 7 ++++ tests/ui/lifetimes/issue-19707.stderr | 36 ++++++++++++++++++++ tests/ui/lint/issue-19102.rs | 12 +++++++ .../issue-5008-borrowed-traitobject-method-call.rs | 34 +++++++++++++++++++ 27 files changed, 314 insertions(+), 314 deletions(-) create mode 100644 tests/ui/closures/issue-10682.rs create mode 100644 tests/ui/consts/issue-44255.rs create mode 100644 tests/ui/extern/issue-18576.rs create mode 100644 tests/ui/extern/issue-18819.rs create mode 100644 tests/ui/extern/issue-18819.stderr create mode 100644 tests/ui/fmt/issue-23781.rs create mode 100644 tests/ui/hygiene/issue-29746.rs create mode 100644 tests/ui/inference/issue-12028.rs create mode 100644 tests/ui/inference/issue-12028.stderr delete mode 100644 tests/ui/issues/issue-10682.rs delete mode 100644 tests/ui/issues/issue-12028.rs delete mode 100644 tests/ui/issues/issue-12028.stderr delete mode 100644 tests/ui/issues/issue-18576.rs delete mode 100644 tests/ui/issues/issue-18819.rs delete mode 100644 tests/ui/issues/issue-18819.stderr delete mode 100644 tests/ui/issues/issue-19102.rs delete mode 100644 tests/ui/issues/issue-19707.rs delete mode 100644 tests/ui/issues/issue-19707.stderr delete mode 100644 tests/ui/issues/issue-23781.rs delete mode 100644 tests/ui/issues/issue-29746.rs delete mode 100644 tests/ui/issues/issue-44255.rs delete mode 100644 tests/ui/issues/issue-5008-borrowed-traitobject-method-call.rs create mode 100644 tests/ui/lifetimes/issue-19707.rs create mode 100644 tests/ui/lifetimes/issue-19707.stderr create mode 100644 tests/ui/lint/issue-19102.rs create mode 100644 tests/ui/traits/issue-5008-borrowed-traitobject-method-call.rs diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 03f8a701627..1dbd221fde5 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -14,7 +14,7 @@ use std::path::{Path, PathBuf}; // #73494. const ENTRY_LIMIT: usize = 900; // FIXME: The following limits should be reduced eventually. -const ISSUES_ENTRY_LIMIT: usize = 1794; +const ISSUES_ENTRY_LIMIT: usize = 1781; const ROOT_ENTRY_LIMIT: usize = 870; const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ diff --git a/tests/ui/closures/issue-10682.rs b/tests/ui/closures/issue-10682.rs new file mode 100644 index 00000000000..72e4559d31a --- /dev/null +++ b/tests/ui/closures/issue-10682.rs @@ -0,0 +1,13 @@ +// run-pass +// Regression test for issue #10682 +// Nested `proc` usage can't use outer owned data + +// pretty-expanded FIXME #23616 + +fn work(_: Box) {} +fn foo(_: F) {} + +pub fn main() { + let a = Box::new(1); + foo(move|| { foo(move|| { work(a) }) }) +} diff --git a/tests/ui/consts/issue-44255.rs b/tests/ui/consts/issue-44255.rs new file mode 100644 index 00000000000..22450320432 --- /dev/null +++ b/tests/ui/consts/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; +} diff --git a/tests/ui/extern/issue-18576.rs b/tests/ui/extern/issue-18576.rs new file mode 100644 index 00000000000..389cf108b05 --- /dev/null +++ b/tests/ui/extern/issue-18576.rs @@ -0,0 +1,16 @@ +// run-fail +// error-pattern:stop +// ignore-emscripten no processes + +// #18576 +// Make sure that calling an extern function pointer in an unreachable +// context doesn't cause an LLVM assertion + +#[allow(unreachable_code)] +fn main() { + panic!("stop"); + let pointer = other; + pointer(); +} + +extern "C" fn other() {} diff --git a/tests/ui/extern/issue-18819.rs b/tests/ui/extern/issue-18819.rs new file mode 100644 index 00000000000..e634c55f824 --- /dev/null +++ b/tests/ui/extern/issue-18819.rs @@ -0,0 +1,18 @@ +trait Foo { + type Item; +} + +struct X; + +impl Foo for X { + type Item = bool; +} + +fn print_x(_: &dyn Foo, extra: &str) { + println!("{}", extra); +} + +fn main() { + print_x(X); + //~^ ERROR E0061 +} diff --git a/tests/ui/extern/issue-18819.stderr b/tests/ui/extern/issue-18819.stderr new file mode 100644 index 00000000000..b2cf0bad1df --- /dev/null +++ b/tests/ui/extern/issue-18819.stderr @@ -0,0 +1,30 @@ +error[E0061]: this function takes 2 arguments but 1 argument was supplied + --> $DIR/issue-18819.rs:16:5 + | +LL | print_x(X); + | ^^^^^^^--- an argument of type `&str` is missing + | +note: expected `&dyn Foo`, found `X` + --> $DIR/issue-18819.rs:16:13 + | +LL | print_x(X); + | ^ + = note: expected reference `&dyn Foo` + found struct `X` +note: function defined here + --> $DIR/issue-18819.rs:11:4 + | +LL | fn print_x(_: &dyn Foo, extra: &str) { + | ^^^^^^^ ---------------------- ----------- +help: consider borrowing here + | +LL | print_x(&X); + | + +help: provide the argument + | +LL | print_x(/* &dyn Foo */, /* &str */); + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/fmt/issue-23781.rs b/tests/ui/fmt/issue-23781.rs new file mode 100644 index 00000000000..220ebdb1872 --- /dev/null +++ b/tests/ui/fmt/issue-23781.rs @@ -0,0 +1,29 @@ +// run-pass +use std::fmt; + +struct Foo; +impl fmt::Debug for Foo { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + println!("::fmt()"); + + write!(fmt, "") + } +} + +fn test1() { + let foo_str = format!("{:?}", Foo); + + println!("{}", foo_str); +} + +fn test2() { + println!("{:?}", Foo); +} + +fn main() { + // This works fine + test1(); + + // This fails + test2(); +} diff --git a/tests/ui/hygiene/issue-29746.rs b/tests/ui/hygiene/issue-29746.rs new file mode 100644 index 00000000000..3470a7e09ad --- /dev/null +++ b/tests/ui/hygiene/issue-29746.rs @@ -0,0 +1,36 @@ +// run-pass +// zip!(a1,a2,a3,a4) is equivalent to: +// a1.zip(a2).zip(a3).zip(a4).map(|(((x1,x2),x3),x4)| (x1,x2,x3,x4)) +macro_rules! zip { + // Entry point + ([$a:expr, $b:expr, $($rest:expr),*]) => { + zip!([$($rest),*], $a.zip($b), (x,y), [x,y]) + }; + + // Intermediate steps to build the zipped expression, the match pattern + // and the output tuple of the closure, using macro hygiene to repeatedly + // introduce new variables named 'x'. + ([$a:expr, $($rest:expr),*], $zip:expr, $pat:pat, [$($flat:expr),*]) => { + zip!([$($rest),*], $zip.zip($a), ($pat,x), [$($flat),*, x]) + }; + + // Final step + ([], $zip:expr, $pat:pat, [$($flat:expr),+]) => { + $zip.map(|$pat| ($($flat),+)) + }; + + // Comma + ([$a:expr], $zip:expr, $pat:pat, [$($flat:expr),*]) => { + zip!([$a,], $zip, $pat, [$($flat),*]) + }; +} + +fn main() { + let p1 = vec![1i32, 2].into_iter(); + let p2 = vec!["10", "20"].into_iter(); + let p3 = vec![100u16, 200].into_iter(); + let p4 = vec![1000i64, 2000].into_iter(); + + let e = zip!([p1,p2,p3,p4]).collect::>(); + assert_eq!(e[0], (1i32,"10",100u16,1000i64)); +} diff --git a/tests/ui/inference/issue-12028.rs b/tests/ui/inference/issue-12028.rs new file mode 100644 index 00000000000..7503766ff20 --- /dev/null +++ b/tests/ui/inference/issue-12028.rs @@ -0,0 +1,38 @@ +// Test an example where we fail to infer the type parameter H. This +// is because there is really nothing constraining it. At one time, we +// would infer based on the where clauses in scope, but that no longer +// works. + +trait Hash { + fn hash2(&self, hasher: &H) -> u64; +} + +trait Stream { + fn input(&mut self, bytes: &[u8]); + fn result(&self) -> u64; +} + +trait StreamHasher { + type S : Stream; + fn stream(&self) -> Self::S; +} + +trait StreamHash: Hash { + fn input_stream(&self, stream: &mut H::S); +} + +impl Hash for u8 { + fn hash2(&self, hasher: &H) -> u64 { + let mut stream = hasher.stream(); + self.input_stream(&mut stream); //~ ERROR type annotations needed + Stream::result(&stream) + } +} + +impl StreamHash for u8 { + fn input_stream(&self, stream: &mut H::S) { + Stream::input(stream, &[*self]); + } +} + +fn main() {} diff --git a/tests/ui/inference/issue-12028.stderr b/tests/ui/inference/issue-12028.stderr new file mode 100644 index 00000000000..3d7fb13d447 --- /dev/null +++ b/tests/ui/inference/issue-12028.stderr @@ -0,0 +1,15 @@ +error[E0284]: type annotations needed + --> $DIR/issue-12028.rs:27:14 + | +LL | self.input_stream(&mut stream); + | ^^^^^^^^^^^^ + | + = note: cannot satisfy `<_ as StreamHasher>::S == ::S` +help: try using a fully qualified path to specify the expected types + | +LL | >::input_stream(self, &mut stream); + | ++++++++++++++++++++++++++++++++++++ ~ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/issues/issue-10682.rs b/tests/ui/issues/issue-10682.rs deleted file mode 100644 index 72e4559d31a..00000000000 --- a/tests/ui/issues/issue-10682.rs +++ /dev/null @@ -1,13 +0,0 @@ -// run-pass -// Regression test for issue #10682 -// Nested `proc` usage can't use outer owned data - -// pretty-expanded FIXME #23616 - -fn work(_: Box) {} -fn foo(_: F) {} - -pub fn main() { - let a = Box::new(1); - foo(move|| { foo(move|| { work(a) }) }) -} diff --git a/tests/ui/issues/issue-12028.rs b/tests/ui/issues/issue-12028.rs deleted file mode 100644 index 7503766ff20..00000000000 --- a/tests/ui/issues/issue-12028.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Test an example where we fail to infer the type parameter H. This -// is because there is really nothing constraining it. At one time, we -// would infer based on the where clauses in scope, but that no longer -// works. - -trait Hash { - fn hash2(&self, hasher: &H) -> u64; -} - -trait Stream { - fn input(&mut self, bytes: &[u8]); - fn result(&self) -> u64; -} - -trait StreamHasher { - type S : Stream; - fn stream(&self) -> Self::S; -} - -trait StreamHash: Hash { - fn input_stream(&self, stream: &mut H::S); -} - -impl Hash for u8 { - fn hash2(&self, hasher: &H) -> u64 { - let mut stream = hasher.stream(); - self.input_stream(&mut stream); //~ ERROR type annotations needed - Stream::result(&stream) - } -} - -impl StreamHash for u8 { - fn input_stream(&self, stream: &mut H::S) { - Stream::input(stream, &[*self]); - } -} - -fn main() {} diff --git a/tests/ui/issues/issue-12028.stderr b/tests/ui/issues/issue-12028.stderr deleted file mode 100644 index 3d7fb13d447..00000000000 --- a/tests/ui/issues/issue-12028.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0284]: type annotations needed - --> $DIR/issue-12028.rs:27:14 - | -LL | self.input_stream(&mut stream); - | ^^^^^^^^^^^^ - | - = note: cannot satisfy `<_ as StreamHasher>::S == ::S` -help: try using a fully qualified path to specify the expected types - | -LL | >::input_stream(self, &mut stream); - | ++++++++++++++++++++++++++++++++++++ ~ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/issues/issue-18576.rs b/tests/ui/issues/issue-18576.rs deleted file mode 100644 index 389cf108b05..00000000000 --- a/tests/ui/issues/issue-18576.rs +++ /dev/null @@ -1,16 +0,0 @@ -// run-fail -// error-pattern:stop -// ignore-emscripten no processes - -// #18576 -// Make sure that calling an extern function pointer in an unreachable -// context doesn't cause an LLVM assertion - -#[allow(unreachable_code)] -fn main() { - panic!("stop"); - let pointer = other; - pointer(); -} - -extern "C" fn other() {} diff --git a/tests/ui/issues/issue-18819.rs b/tests/ui/issues/issue-18819.rs deleted file mode 100644 index e634c55f824..00000000000 --- a/tests/ui/issues/issue-18819.rs +++ /dev/null @@ -1,18 +0,0 @@ -trait Foo { - type Item; -} - -struct X; - -impl Foo for X { - type Item = bool; -} - -fn print_x(_: &dyn Foo, extra: &str) { - println!("{}", extra); -} - -fn main() { - print_x(X); - //~^ ERROR E0061 -} diff --git a/tests/ui/issues/issue-18819.stderr b/tests/ui/issues/issue-18819.stderr deleted file mode 100644 index b2cf0bad1df..00000000000 --- a/tests/ui/issues/issue-18819.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0061]: this function takes 2 arguments but 1 argument was supplied - --> $DIR/issue-18819.rs:16:5 - | -LL | print_x(X); - | ^^^^^^^--- an argument of type `&str` is missing - | -note: expected `&dyn Foo`, found `X` - --> $DIR/issue-18819.rs:16:13 - | -LL | print_x(X); - | ^ - = note: expected reference `&dyn Foo` - found struct `X` -note: function defined here - --> $DIR/issue-18819.rs:11:4 - | -LL | fn print_x(_: &dyn Foo, extra: &str) { - | ^^^^^^^ ---------------------- ----------- -help: consider borrowing here - | -LL | print_x(&X); - | + -help: provide the argument - | -LL | print_x(/* &dyn Foo */, /* &str */); - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/issues/issue-19102.rs b/tests/ui/issues/issue-19102.rs deleted file mode 100644 index 1f32d10b644..00000000000 --- a/tests/ui/issues/issue-19102.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass -#![allow(unused_imports)] -#![deny(unused_qualifications)] - -use self::A::B; - -#[derive(PartialEq)] -pub enum A { - B, -} - -fn main() {} diff --git a/tests/ui/issues/issue-19707.rs b/tests/ui/issues/issue-19707.rs deleted file mode 100644 index 6bc7132af3c..00000000000 --- a/tests/ui/issues/issue-19707.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![allow(dead_code)] - -type Foo = fn(&u8, &u8) -> &u8; //~ ERROR missing lifetime specifier - -fn bar &u8>(f: &F) {} //~ ERROR missing lifetime specifier - -fn main() {} diff --git a/tests/ui/issues/issue-19707.stderr b/tests/ui/issues/issue-19707.stderr deleted file mode 100644 index 3e1bb32c19b..00000000000 --- a/tests/ui/issues/issue-19707.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/issue-19707.rs:3:28 - | -LL | type Foo = fn(&u8, &u8) -> &u8; - | --- --- ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 - = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html -help: consider making the type lifetime-generic with a new `'a` lifetime - | -LL | type Foo = for<'a> fn(&'a u8, &'a u8) -> &'a u8; - | +++++++ ++ ++ ++ -help: consider introducing a named lifetime parameter - | -LL | type Foo<'a> = fn(&'a u8, &'a u8) -> &'a u8; - | ++++ ++ ++ ++ - -error[E0106]: missing lifetime specifier - --> $DIR/issue-19707.rs:5:27 - | -LL | fn bar &u8>(f: &F) {} - | --- --- ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 -help: consider making the bound lifetime-generic with a new `'a` lifetime - | -LL | fn bar Fn(&'a u8, &'a u8) -> &'a u8>(f: &F) {} - | +++++++ ++ ++ ++ -help: consider introducing a named lifetime parameter - | -LL | fn bar<'a, F: Fn(&'a u8, &'a u8) -> &'a u8>(f: &F) {} - | +++ ++ ++ ++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/tests/ui/issues/issue-23781.rs b/tests/ui/issues/issue-23781.rs deleted file mode 100644 index 220ebdb1872..00000000000 --- a/tests/ui/issues/issue-23781.rs +++ /dev/null @@ -1,29 +0,0 @@ -// run-pass -use std::fmt; - -struct Foo; -impl fmt::Debug for Foo { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - println!("::fmt()"); - - write!(fmt, "") - } -} - -fn test1() { - let foo_str = format!("{:?}", Foo); - - println!("{}", foo_str); -} - -fn test2() { - println!("{:?}", Foo); -} - -fn main() { - // This works fine - test1(); - - // This fails - test2(); -} diff --git a/tests/ui/issues/issue-29746.rs b/tests/ui/issues/issue-29746.rs deleted file mode 100644 index 3470a7e09ad..00000000000 --- a/tests/ui/issues/issue-29746.rs +++ /dev/null @@ -1,36 +0,0 @@ -// run-pass -// zip!(a1,a2,a3,a4) is equivalent to: -// a1.zip(a2).zip(a3).zip(a4).map(|(((x1,x2),x3),x4)| (x1,x2,x3,x4)) -macro_rules! zip { - // Entry point - ([$a:expr, $b:expr, $($rest:expr),*]) => { - zip!([$($rest),*], $a.zip($b), (x,y), [x,y]) - }; - - // Intermediate steps to build the zipped expression, the match pattern - // and the output tuple of the closure, using macro hygiene to repeatedly - // introduce new variables named 'x'. - ([$a:expr, $($rest:expr),*], $zip:expr, $pat:pat, [$($flat:expr),*]) => { - zip!([$($rest),*], $zip.zip($a), ($pat,x), [$($flat),*, x]) - }; - - // Final step - ([], $zip:expr, $pat:pat, [$($flat:expr),+]) => { - $zip.map(|$pat| ($($flat),+)) - }; - - // Comma - ([$a:expr], $zip:expr, $pat:pat, [$($flat:expr),*]) => { - zip!([$a,], $zip, $pat, [$($flat),*]) - }; -} - -fn main() { - let p1 = vec![1i32, 2].into_iter(); - let p2 = vec!["10", "20"].into_iter(); - let p3 = vec![100u16, 200].into_iter(); - let p4 = vec![1000i64, 2000].into_iter(); - - let e = zip!([p1,p2,p3,p4]).collect::>(); - assert_eq!(e[0], (1i32,"10",100u16,1000i64)); -} diff --git a/tests/ui/issues/issue-44255.rs b/tests/ui/issues/issue-44255.rs deleted file mode 100644 index 22450320432..00000000000 --- a/tests/ui/issues/issue-44255.rs +++ /dev/null @@ -1,29 +0,0 @@ -// 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; -} diff --git a/tests/ui/issues/issue-5008-borrowed-traitobject-method-call.rs b/tests/ui/issues/issue-5008-borrowed-traitobject-method-call.rs deleted file mode 100644 index fc869ae4fec..00000000000 --- a/tests/ui/issues/issue-5008-borrowed-traitobject-method-call.rs +++ /dev/null @@ -1,34 +0,0 @@ -// run-pass -/* - -#5008 cast to &Trait causes code to segfault on method call - -It fixes itself if the &Trait is changed to @Trait. -*/ - -trait Debuggable { - fn debug_name(&self) -> String; -} - -#[derive(Clone)] -struct Thing { - name: String, -} - -impl Thing { - fn new() -> Thing { Thing { name: "dummy".to_string() } } -} - -impl Debuggable for Thing { - fn debug_name(&self) -> String { self.name.clone() } -} - -fn print_name(x: &dyn Debuggable) -{ - println!("debug_name = {}", x.debug_name()); -} - -pub fn main() { - let thing = Thing::new(); - print_name(&thing as &dyn Debuggable); -} diff --git a/tests/ui/lifetimes/issue-19707.rs b/tests/ui/lifetimes/issue-19707.rs new file mode 100644 index 00000000000..6bc7132af3c --- /dev/null +++ b/tests/ui/lifetimes/issue-19707.rs @@ -0,0 +1,7 @@ +#![allow(dead_code)] + +type Foo = fn(&u8, &u8) -> &u8; //~ ERROR missing lifetime specifier + +fn bar &u8>(f: &F) {} //~ ERROR missing lifetime specifier + +fn main() {} diff --git a/tests/ui/lifetimes/issue-19707.stderr b/tests/ui/lifetimes/issue-19707.stderr new file mode 100644 index 00000000000..3e1bb32c19b --- /dev/null +++ b/tests/ui/lifetimes/issue-19707.stderr @@ -0,0 +1,36 @@ +error[E0106]: missing lifetime specifier + --> $DIR/issue-19707.rs:3:28 + | +LL | type Foo = fn(&u8, &u8) -> &u8; + | --- --- ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 + = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the type lifetime-generic with a new `'a` lifetime + | +LL | type Foo = for<'a> fn(&'a u8, &'a u8) -> &'a u8; + | +++++++ ++ ++ ++ +help: consider introducing a named lifetime parameter + | +LL | type Foo<'a> = fn(&'a u8, &'a u8) -> &'a u8; + | ++++ ++ ++ ++ + +error[E0106]: missing lifetime specifier + --> $DIR/issue-19707.rs:5:27 + | +LL | fn bar &u8>(f: &F) {} + | --- --- ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | fn bar Fn(&'a u8, &'a u8) -> &'a u8>(f: &F) {} + | +++++++ ++ ++ ++ +help: consider introducing a named lifetime parameter + | +LL | fn bar<'a, F: Fn(&'a u8, &'a u8) -> &'a u8>(f: &F) {} + | +++ ++ ++ ++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0106`. diff --git a/tests/ui/lint/issue-19102.rs b/tests/ui/lint/issue-19102.rs new file mode 100644 index 00000000000..1f32d10b644 --- /dev/null +++ b/tests/ui/lint/issue-19102.rs @@ -0,0 +1,12 @@ +// check-pass +#![allow(unused_imports)] +#![deny(unused_qualifications)] + +use self::A::B; + +#[derive(PartialEq)] +pub enum A { + B, +} + +fn main() {} diff --git a/tests/ui/traits/issue-5008-borrowed-traitobject-method-call.rs b/tests/ui/traits/issue-5008-borrowed-traitobject-method-call.rs new file mode 100644 index 00000000000..fc869ae4fec --- /dev/null +++ b/tests/ui/traits/issue-5008-borrowed-traitobject-method-call.rs @@ -0,0 +1,34 @@ +// run-pass +/* + +#5008 cast to &Trait causes code to segfault on method call + +It fixes itself if the &Trait is changed to @Trait. +*/ + +trait Debuggable { + fn debug_name(&self) -> String; +} + +#[derive(Clone)] +struct Thing { + name: String, +} + +impl Thing { + fn new() -> Thing { Thing { name: "dummy".to_string() } } +} + +impl Debuggable for Thing { + fn debug_name(&self) -> String { self.name.clone() } +} + +fn print_name(x: &dyn Debuggable) +{ + println!("debug_name = {}", x.debug_name()); +} + +pub fn main() { + let thing = Thing::new(); + print_name(&thing as &dyn Debuggable); +} -- cgit 1.4.1-3-g733a5