From 9f38ca97eab53ba2f431a48bec2343ef52335714 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Fri, 18 Jul 2025 22:00:30 +0500 Subject: move 28 tests --- tests/ui/array-slice-vec/array-pattern-matching.rs | 14 ++++ tests/ui/array-slice-vec/trait-object-arrays.rs | 84 ++++++++++++++++++++++ tests/ui/borrowck/closure-borrow-conflict.rs | 22 ++++++ tests/ui/cfg/conditional-compilation-struct.rs | 44 ++++++++++++ tests/ui/closures/fnonce-closure-call.rs | 10 +++ tests/ui/drop/conditional-drop-behavior.rs | 39 ++++++++++ tests/ui/drop/trait-object-drop-behavior.rs | 45 ++++++++++++ tests/ui/extern/extern-rust-fn-type-error.rs | 5 ++ tests/ui/extern/foreign-fn-pattern-error.rs | 16 +++++ tests/ui/fn/boxed-fn-pointer.rs | 7 ++ tests/ui/generics/generic-type-inference.rs | 11 +++ tests/ui/imports/empty-use-statements.rs | 38 ++++++++++ tests/ui/issues/issue-10228.rs | 19 ----- tests/ui/issues/issue-10291.rs | 8 --- tests/ui/issues/issue-102964.rs | 10 --- tests/ui/issues/issue-10396.rs | 14 ---- tests/ui/issues/issue-10412.rs | 26 ------- tests/ui/issues/issue-10436.rs | 11 --- tests/ui/issues/issue-10456.rs | 24 ------- tests/ui/issues/issue-10465.rs | 23 ------ tests/ui/issues/issue-10545.rs | 9 --- tests/ui/issues/issue-10638.rs | 10 --- tests/ui/issues/issue-106755.rs | 22 ------ tests/ui/issues/issue-10683.rs | 10 --- tests/ui/issues/issue-10718.rs | 10 --- tests/ui/issues/issue-10734.rs | 39 ---------- tests/ui/issues/issue-10764.rs | 5 -- tests/ui/issues/issue-10767.rs | 7 -- tests/ui/issues/issue-10802.rs | 45 ------------ tests/ui/issues/issue-10806.rs | 38 ---------- tests/ui/issues/issue-10853.rs | 14 ---- tests/ui/issues/issue-10877.rs | 16 ----- tests/ui/issues/issue-10902.rs | 20 ------ tests/ui/issues/issue-11004.rs | 27 ------- tests/ui/issues/issue-11047.rs | 26 ------- tests/ui/issues/issue-11085.rs | 44 ------------ tests/ui/issues/issue-11192.rs | 22 ------ tests/ui/issues/issue-11205.rs | 84 ---------------------- tests/ui/issues/issue-11267.rs | 19 ----- tests/ui/issues/issue-11374.rs | 28 -------- .../ui/lifetimes/closure-lifetime-bounds-error.rs | 8 +++ tests/ui/lifetimes/container-lifetime-error.rs | 28 ++++++++ tests/ui/lifetimes/enum-lifetime-container.rs | 19 +++++ tests/ui/lifetimes/keyword-self-lifetime-error.rs | 26 +++++++ tests/ui/lifetimes/trait-lifetime-bounds.rs | 20 ++++++ tests/ui/lint/inner-doc-attributes.rs | 14 ++++ tests/ui/parser/comment-parsing.rs | 10 +++ tests/ui/pattern/ascii-lowercase-match.rs | 10 +++ tests/ui/privacy/private-struct-access-error.rs | 9 +++ tests/ui/structs/mutable-unit-struct-borrow.rs | 19 +++++ tests/ui/traits/blanket-impl-trait-object.rs | 24 +++++++ tests/ui/traits/missing-trait-method-error.rs | 23 ++++++ tests/ui/traits/negative-positive-impl-conflict.rs | 22 ++++++ tests/ui/type-alias/mismatched-rc-foo-types.rs | 10 +++ tests/ui/type-alias/static-method-type-alias.rs | 26 +++++++ tests/ui/unsafe/raw-pointer-field-access-error.rs | 27 +++++++ 56 files changed, 630 insertions(+), 630 deletions(-) create mode 100644 tests/ui/array-slice-vec/array-pattern-matching.rs create mode 100644 tests/ui/array-slice-vec/trait-object-arrays.rs create mode 100644 tests/ui/borrowck/closure-borrow-conflict.rs create mode 100644 tests/ui/cfg/conditional-compilation-struct.rs create mode 100644 tests/ui/closures/fnonce-closure-call.rs create mode 100644 tests/ui/drop/conditional-drop-behavior.rs create mode 100644 tests/ui/drop/trait-object-drop-behavior.rs create mode 100644 tests/ui/extern/extern-rust-fn-type-error.rs create mode 100644 tests/ui/extern/foreign-fn-pattern-error.rs create mode 100644 tests/ui/fn/boxed-fn-pointer.rs create mode 100644 tests/ui/generics/generic-type-inference.rs create mode 100644 tests/ui/imports/empty-use-statements.rs delete mode 100644 tests/ui/issues/issue-10228.rs delete mode 100644 tests/ui/issues/issue-10291.rs delete mode 100644 tests/ui/issues/issue-102964.rs delete mode 100644 tests/ui/issues/issue-10396.rs delete mode 100644 tests/ui/issues/issue-10412.rs delete mode 100644 tests/ui/issues/issue-10436.rs delete mode 100644 tests/ui/issues/issue-10456.rs delete mode 100644 tests/ui/issues/issue-10465.rs delete mode 100644 tests/ui/issues/issue-10545.rs delete mode 100644 tests/ui/issues/issue-10638.rs delete mode 100644 tests/ui/issues/issue-106755.rs delete mode 100644 tests/ui/issues/issue-10683.rs delete mode 100644 tests/ui/issues/issue-10718.rs delete mode 100644 tests/ui/issues/issue-10734.rs delete mode 100644 tests/ui/issues/issue-10764.rs delete mode 100644 tests/ui/issues/issue-10767.rs delete mode 100644 tests/ui/issues/issue-10802.rs delete mode 100644 tests/ui/issues/issue-10806.rs delete mode 100644 tests/ui/issues/issue-10853.rs delete mode 100644 tests/ui/issues/issue-10877.rs delete mode 100644 tests/ui/issues/issue-10902.rs delete mode 100644 tests/ui/issues/issue-11004.rs delete mode 100644 tests/ui/issues/issue-11047.rs delete mode 100644 tests/ui/issues/issue-11085.rs delete mode 100644 tests/ui/issues/issue-11192.rs delete mode 100644 tests/ui/issues/issue-11205.rs delete mode 100644 tests/ui/issues/issue-11267.rs delete mode 100644 tests/ui/issues/issue-11374.rs create mode 100644 tests/ui/lifetimes/closure-lifetime-bounds-error.rs create mode 100644 tests/ui/lifetimes/container-lifetime-error.rs create mode 100644 tests/ui/lifetimes/enum-lifetime-container.rs create mode 100644 tests/ui/lifetimes/keyword-self-lifetime-error.rs create mode 100644 tests/ui/lifetimes/trait-lifetime-bounds.rs create mode 100644 tests/ui/lint/inner-doc-attributes.rs create mode 100644 tests/ui/parser/comment-parsing.rs create mode 100644 tests/ui/pattern/ascii-lowercase-match.rs create mode 100644 tests/ui/privacy/private-struct-access-error.rs create mode 100644 tests/ui/structs/mutable-unit-struct-borrow.rs create mode 100644 tests/ui/traits/blanket-impl-trait-object.rs create mode 100644 tests/ui/traits/missing-trait-method-error.rs create mode 100644 tests/ui/traits/negative-positive-impl-conflict.rs create mode 100644 tests/ui/type-alias/mismatched-rc-foo-types.rs create mode 100644 tests/ui/type-alias/static-method-type-alias.rs create mode 100644 tests/ui/unsafe/raw-pointer-field-access-error.rs diff --git a/tests/ui/array-slice-vec/array-pattern-matching.rs b/tests/ui/array-slice-vec/array-pattern-matching.rs new file mode 100644 index 00000000000..082216d557c --- /dev/null +++ b/tests/ui/array-slice-vec/array-pattern-matching.rs @@ -0,0 +1,14 @@ +//@ check-pass +#![allow(dead_code)] +#[derive(Debug)] +enum Foo<'s> { + V(&'s str) +} + +fn f(arr: &[&Foo]) { + for &f in arr { + println!("{:?}", f); + } +} + +fn main() {} diff --git a/tests/ui/array-slice-vec/trait-object-arrays.rs b/tests/ui/array-slice-vec/trait-object-arrays.rs new file mode 100644 index 00000000000..8530514f0ed --- /dev/null +++ b/tests/ui/array-slice-vec/trait-object-arrays.rs @@ -0,0 +1,84 @@ +//@ run-pass + +#![allow(dead_code)] + +trait Foo { fn dummy(&self) { } } +impl Foo for isize {} +fn foo(_: [&dyn Foo; 2]) {} +fn foos(_: &[&dyn Foo]) {} +fn foog(_: &[T], _: &[T]) {} + +fn bar(_: [Box; 2]) {} +fn bars(_: &[Box]) {} + +fn main() { + let x: [&dyn Foo; 2] = [&1, &2]; + foo(x); + foo([&1, &2]); + + let r = &1; + let x: [&dyn Foo; 2] = [r; 2]; + foo(x); + foo([&1; 2]); + + let x: &[&dyn Foo] = &[&1, &2]; + foos(x); + foos(&[&1, &2]); + + let x: &[&dyn Foo] = &[&1, &2]; + let r = &1; + foog(x, &[r]); + + let x: [Box; 2] = [Box::new(1), Box::new(2)]; + bar(x); + bar([Box::new(1), Box::new(2)]); + + let x: &[Box] = &[Box::new(1), Box::new(2)]; + bars(x); + bars(&[Box::new(1), Box::new(2)]); + + let x: &[Box] = &[Box::new(1), Box::new(2)]; + foog(x, &[Box::new(1)]); + + struct T<'a> { + t: [&'a (dyn Foo+'a); 2] + } + let _n = T { + t: [&1, &2] + }; + let r = &1; + let _n = T { + t: [r; 2] + }; + let x: [&dyn Foo; 2] = [&1, &2]; + let _n = T { + t: x + }; + + struct F<'b> { + t: &'b [&'b (dyn Foo+'b)] + } + let _n = F { + t: &[&1, &2] + }; + let r = &1; + let r: [&dyn Foo; 2] = [r; 2]; + let _n = F { + t: &r + }; + let x: [&dyn Foo; 2] = [&1, &2]; + let _n = F { + t: &x + }; + + struct M<'a> { + t: &'a [Box] + } + let _n = M { + t: &[Box::new(1), Box::new(2)] + }; + let x: [Box; 2] = [Box::new(1), Box::new(2)]; + let _n = M { + t: &x + }; +} diff --git a/tests/ui/borrowck/closure-borrow-conflict.rs b/tests/ui/borrowck/closure-borrow-conflict.rs new file mode 100644 index 00000000000..1a3d8c9fe58 --- /dev/null +++ b/tests/ui/borrowck/closure-borrow-conflict.rs @@ -0,0 +1,22 @@ +struct Foo { + x: isize +} + + +impl Drop for Foo { + fn drop(&mut self) { + println!("drop {}", self.x); + } +} + + +fn main() { + let mut ptr: Box<_> = Box::new(Foo { x: 0 }); + let mut test = |foo: &Foo| { + println!("access {}", foo.x); + ptr = Box::new(Foo { x: ptr.x + 1 }); + println!("access {}", foo.x); + }; + test(&*ptr); + //~^ ERROR: cannot borrow `*ptr` as immutable +} diff --git a/tests/ui/cfg/conditional-compilation-struct.rs b/tests/ui/cfg/conditional-compilation-struct.rs new file mode 100644 index 00000000000..c3f13199b30 --- /dev/null +++ b/tests/ui/cfg/conditional-compilation-struct.rs @@ -0,0 +1,44 @@ +//@ run-pass + +#![allow(dead_code)] + +struct Foo { + #[cfg(false)] + bar: baz, + foo: isize, +} + +struct Foo2 { + #[cfg(all())] + foo: isize, +} + +enum Bar1 { + Bar1_1, + #[cfg(false)] + Bar1_2(NotAType), +} + +enum Bar2 { + #[cfg(false)] + Bar2_1(NotAType), +} + +enum Bar3 { + Bar3_1 { + #[cfg(false)] + foo: isize, + bar: isize, + } +} + +pub fn main() { + let _f = Foo { foo: 3 }; + let _f = Foo2 { foo: 3 }; + + match Bar1::Bar1_1 { + Bar1::Bar1_1 => {} + } + + let _f = Bar3::Bar3_1 { bar: 3 }; +} diff --git a/tests/ui/closures/fnonce-closure-call.rs b/tests/ui/closures/fnonce-closure-call.rs new file mode 100644 index 00000000000..68ac0bbe49f --- /dev/null +++ b/tests/ui/closures/fnonce-closure-call.rs @@ -0,0 +1,10 @@ +//@ run-pass + +fn f(p: F) { + p(); +} + +pub fn main() { + let p = || (); + f(p); +} diff --git a/tests/ui/drop/conditional-drop-behavior.rs b/tests/ui/drop/conditional-drop-behavior.rs new file mode 100644 index 00000000000..6d815aeca07 --- /dev/null +++ b/tests/ui/drop/conditional-drop-behavior.rs @@ -0,0 +1,39 @@ +//@ run-pass +#![allow(non_upper_case_globals)] + +// FIXME(static_mut_refs): this could use an atomic +#![allow(static_mut_refs)] + +static mut drop_count: usize = 0; + +struct Foo { + dropped: bool +} + +impl Drop for Foo { + fn drop(&mut self) { + // Test to make sure we haven't dropped already + assert!(!self.dropped); + self.dropped = true; + // And record the fact that we dropped for verification later + unsafe { drop_count += 1; } + } +} + +pub fn main() { + // An `if true { expr }` statement should compile the same as `{ expr }`. + if true { + let _a = Foo{ dropped: false }; + } + // Check that we dropped already (as expected from a `{ expr }`). + unsafe { assert_eq!(drop_count, 1); } + + // An `if false {} else { expr }` statement should compile the same as `{ expr }`. + if false { + panic!(); + } else { + let _a = Foo{ dropped: false }; + } + // Check that we dropped already (as expected from a `{ expr }`). + unsafe { assert_eq!(drop_count, 2); } +} diff --git a/tests/ui/drop/trait-object-drop-behavior.rs b/tests/ui/drop/trait-object-drop-behavior.rs new file mode 100644 index 00000000000..eca701ce98c --- /dev/null +++ b/tests/ui/drop/trait-object-drop-behavior.rs @@ -0,0 +1,45 @@ +//@ run-pass +#![allow(dead_code)] + +struct DroppableStruct; +enum DroppableEnum { + DroppableVariant1, DroppableVariant2 +} + +static mut DROPPED: bool = false; + +impl Drop for DroppableStruct { + fn drop(&mut self) { + unsafe { DROPPED = true; } + } +} +impl Drop for DroppableEnum { + fn drop(&mut self) { + unsafe { DROPPED = true; } + } +} + +trait MyTrait { fn dummy(&self) { } } +impl MyTrait for Box {} +impl MyTrait for Box {} + +struct Whatever { w: Box } +impl Whatever { + fn new(w: Box) -> Whatever { + Whatever { w: w } + } +} + +fn main() { + { + let f: Box<_> = Box::new(DroppableStruct); + let _a = Whatever::new(Box::new(f) as Box); + } + assert!(unsafe { DROPPED }); + unsafe { DROPPED = false; } + { + let f: Box<_> = Box::new(DroppableEnum::DroppableVariant1); + let _a = Whatever::new(Box::new(f) as Box); + } + assert!(unsafe { DROPPED }); +} diff --git a/tests/ui/extern/extern-rust-fn-type-error.rs b/tests/ui/extern/extern-rust-fn-type-error.rs new file mode 100644 index 00000000000..bb915f58d9d --- /dev/null +++ b/tests/ui/extern/extern-rust-fn-type-error.rs @@ -0,0 +1,5 @@ +fn f(_: extern "Rust" fn()) {} +extern "C" fn bar() {} + +fn main() { f(bar) } +//~^ ERROR mismatched types diff --git a/tests/ui/extern/foreign-fn-pattern-error.rs b/tests/ui/extern/foreign-fn-pattern-error.rs new file mode 100644 index 00000000000..15a383175b9 --- /dev/null +++ b/tests/ui/extern/foreign-fn-pattern-error.rs @@ -0,0 +1,16 @@ +struct Foo { + x: isize, +} +extern "C" { + fn foo(1: ()); + //~^ ERROR: patterns aren't allowed in foreign function declarations + fn bar((): isize); + //~^ ERROR: patterns aren't allowed in foreign function declarations + fn baz(Foo { x }: isize); + //~^ ERROR: patterns aren't allowed in foreign function declarations + fn qux((x, y): ()); + //~^ ERROR: patterns aren't allowed in foreign function declarations + fn this_is_actually_ok(a: usize); + fn and_so_is_this(_: usize); +} +fn main() {} diff --git a/tests/ui/fn/boxed-fn-pointer.rs b/tests/ui/fn/boxed-fn-pointer.rs new file mode 100644 index 00000000000..2060d15b4c7 --- /dev/null +++ b/tests/ui/fn/boxed-fn-pointer.rs @@ -0,0 +1,7 @@ +//@ run-pass + +pub fn main() { + fn f() { + } + let _: Box = Box::new(f as fn()); +} diff --git a/tests/ui/generics/generic-type-inference.rs b/tests/ui/generics/generic-type-inference.rs new file mode 100644 index 00000000000..672aa2464dc --- /dev/null +++ b/tests/ui/generics/generic-type-inference.rs @@ -0,0 +1,11 @@ +//@ run-pass +fn works(x: T) -> Vec { vec![x] } + +fn also_works(x: T) -> Vec { vec![x] } + +fn main() { + let _: Vec = works(0); + let _: Vec = also_works(0); + let _ = works(0); + let _ = also_works(0); +} diff --git a/tests/ui/imports/empty-use-statements.rs b/tests/ui/imports/empty-use-statements.rs new file mode 100644 index 00000000000..31315dc7c93 --- /dev/null +++ b/tests/ui/imports/empty-use-statements.rs @@ -0,0 +1,38 @@ +//@ edition: 2015 +//@ run-pass +#![allow(unused_imports)] + + +pub fn foo() -> isize { + 3 +} +pub fn bar() -> isize { + 4 +} + +pub mod baz { + use {foo, bar}; + pub fn quux() -> isize { + foo() + bar() + } +} + +pub mod grault { + use {foo}; + pub fn garply() -> isize { + foo() + } +} + +pub mod waldo { + use {}; + pub fn plugh() -> isize { + 0 + } +} + +pub fn main() { + let _x = baz::quux(); + let _y = grault::garply(); + let _z = waldo::plugh(); +} diff --git a/tests/ui/issues/issue-10228.rs b/tests/ui/issues/issue-10228.rs deleted file mode 100644 index a59ccf926f9..00000000000 --- a/tests/ui/issues/issue-10228.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ run-pass -#![allow(dead_code)] -#![allow(unused_variables)] - -enum StdioContainer { - CreatePipe(bool) -} - -struct Test<'a> { - args: &'a [String], - io: &'a [StdioContainer] -} - -pub fn main() { - let test = Test { - args: &[], - io: &[StdioContainer::CreatePipe(true)] - }; -} diff --git a/tests/ui/issues/issue-10291.rs b/tests/ui/issues/issue-10291.rs deleted file mode 100644 index 31b9e124046..00000000000 --- a/tests/ui/issues/issue-10291.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn test<'x>(x: &'x isize) { - drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - x - //~^ ERROR lifetime may not live long enough - })); -} - -fn main() {} diff --git a/tests/ui/issues/issue-102964.rs b/tests/ui/issues/issue-102964.rs deleted file mode 100644 index 43ff2360076..00000000000 --- a/tests/ui/issues/issue-102964.rs +++ /dev/null @@ -1,10 +0,0 @@ -use std::rc::Rc; -type Foo<'a, T> = &'a dyn Fn(&T); -type RcFoo<'a, T> = Rc>; - -fn bar_function(function: Foo) -> RcFoo { - //~^ ERROR mismatched types - let rc = Rc::new(function); -} - -fn main() {} diff --git a/tests/ui/issues/issue-10396.rs b/tests/ui/issues/issue-10396.rs deleted file mode 100644 index 082216d557c..00000000000 --- a/tests/ui/issues/issue-10396.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ check-pass -#![allow(dead_code)] -#[derive(Debug)] -enum Foo<'s> { - V(&'s str) -} - -fn f(arr: &[&Foo]) { - for &f in arr { - println!("{:?}", f); - } -} - -fn main() {} diff --git a/tests/ui/issues/issue-10412.rs b/tests/ui/issues/issue-10412.rs deleted file mode 100644 index 68ce0c2ea3c..00000000000 --- a/tests/ui/issues/issue-10412.rs +++ /dev/null @@ -1,26 +0,0 @@ -trait Serializable<'self, T> { - //~^ ERROR lifetimes cannot use keyword names - fn serialize(val: &'self T) -> Vec; //~ ERROR lifetimes cannot use keyword names - fn deserialize(repr: &[u8]) -> &'self T; //~ ERROR lifetimes cannot use keyword names -} - -impl<'self> Serializable for &'self str { - //~^ ERROR lifetimes cannot use keyword names - //~| ERROR lifetimes cannot use keyword names - //~| ERROR implicit elided lifetime not allowed here - fn serialize(val: &'self str) -> Vec { - //~^ ERROR lifetimes cannot use keyword names - vec![1] - } - fn deserialize(repr: &[u8]) -> &'self str { - //~^ ERROR lifetimes cannot use keyword names - "hi" - } -} - -fn main() { - println!("hello"); - let x = "foo".to_string(); - let y = x; - println!("{}", y); -} diff --git a/tests/ui/issues/issue-10436.rs b/tests/ui/issues/issue-10436.rs deleted file mode 100644 index 672aa2464dc..00000000000 --- a/tests/ui/issues/issue-10436.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -fn works(x: T) -> Vec { vec![x] } - -fn also_works(x: T) -> Vec { vec![x] } - -fn main() { - let _: Vec = works(0); - let _: Vec = also_works(0); - let _ = works(0); - let _ = also_works(0); -} diff --git a/tests/ui/issues/issue-10456.rs b/tests/ui/issues/issue-10456.rs deleted file mode 100644 index 51c740fd729..00000000000 --- a/tests/ui/issues/issue-10456.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ check-pass - -pub struct Foo; - -pub trait Bar { - fn bar(&self); -} - -pub trait Baz { - fn baz(&self) { } -} - -impl Bar for T { - fn bar(&self) {} -} - -impl Baz for Foo {} - -pub fn foo(t: Box) { - t.bar(); // ~Foo doesn't implement Baz - (*t).bar(); // ok b/c Foo implements Baz -} - -fn main() {} diff --git a/tests/ui/issues/issue-10465.rs b/tests/ui/issues/issue-10465.rs deleted file mode 100644 index d899c3ffa91..00000000000 --- a/tests/ui/issues/issue-10465.rs +++ /dev/null @@ -1,23 +0,0 @@ -pub mod a { - pub trait A { - fn foo(&self); - } - -} -pub mod b { - use a::A; - - pub struct B; - impl A for B { fn foo(&self) {} } - - pub mod c { - use b::B; - - fn foo(b: &B) { - b.foo(); //~ ERROR: no method named `foo` found - } - } - -} - -fn main() {} diff --git a/tests/ui/issues/issue-10545.rs b/tests/ui/issues/issue-10545.rs deleted file mode 100644 index acd07149619..00000000000 --- a/tests/ui/issues/issue-10545.rs +++ /dev/null @@ -1,9 +0,0 @@ -mod a { - struct S; - impl S { } -} - -fn foo(_: a::S) { //~ ERROR: struct `S` is private -} - -fn main() {} diff --git a/tests/ui/issues/issue-10638.rs b/tests/ui/issues/issue-10638.rs deleted file mode 100644 index c6c6939bda5..00000000000 --- a/tests/ui/issues/issue-10638.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -pub fn main() { - //// I am not a doc comment! - ////////////////// still not a doc comment - /////**** nope, me neither */ - /*** And neither am I! */ - 5; - /*****! certainly not I */ -} diff --git a/tests/ui/issues/issue-106755.rs b/tests/ui/issues/issue-106755.rs deleted file mode 100644 index d7e7122ebda..00000000000 --- a/tests/ui/issues/issue-106755.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ compile-flags:-Ztranslate-lang=en_US - -#![feature(negative_impls)] -#![feature(marker_trait_attr)] - -#[marker] -trait MyTrait {} - -struct TestType(::std::marker::PhantomData); - -unsafe impl Send for TestType {} - -impl !Send for TestType {} -//~^ ERROR found both positive and negative implementation -//~| ERROR `!Send` impl requires `T: MyTrait` but the struct it is implemented for does not - -unsafe impl Send for TestType {} //~ ERROR conflicting implementations - -impl !Send for TestType {} -//~^ ERROR `!Send` impls cannot be specialized - -fn main() {} diff --git a/tests/ui/issues/issue-10683.rs b/tests/ui/issues/issue-10683.rs deleted file mode 100644 index 5657ec1864b..00000000000 --- a/tests/ui/issues/issue-10683.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -static NAME: &'static str = "hello world"; - -fn main() { - match &*NAME.to_ascii_lowercase() { - "foo" => {} - _ => {} - } -} diff --git a/tests/ui/issues/issue-10718.rs b/tests/ui/issues/issue-10718.rs deleted file mode 100644 index 68ac0bbe49f..00000000000 --- a/tests/ui/issues/issue-10718.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -fn f(p: F) { - p(); -} - -pub fn main() { - let p = || (); - f(p); -} diff --git a/tests/ui/issues/issue-10734.rs b/tests/ui/issues/issue-10734.rs deleted file mode 100644 index 6d815aeca07..00000000000 --- a/tests/ui/issues/issue-10734.rs +++ /dev/null @@ -1,39 +0,0 @@ -//@ run-pass -#![allow(non_upper_case_globals)] - -// FIXME(static_mut_refs): this could use an atomic -#![allow(static_mut_refs)] - -static mut drop_count: usize = 0; - -struct Foo { - dropped: bool -} - -impl Drop for Foo { - fn drop(&mut self) { - // Test to make sure we haven't dropped already - assert!(!self.dropped); - self.dropped = true; - // And record the fact that we dropped for verification later - unsafe { drop_count += 1; } - } -} - -pub fn main() { - // An `if true { expr }` statement should compile the same as `{ expr }`. - if true { - let _a = Foo{ dropped: false }; - } - // Check that we dropped already (as expected from a `{ expr }`). - unsafe { assert_eq!(drop_count, 1); } - - // An `if false {} else { expr }` statement should compile the same as `{ expr }`. - if false { - panic!(); - } else { - let _a = Foo{ dropped: false }; - } - // Check that we dropped already (as expected from a `{ expr }`). - unsafe { assert_eq!(drop_count, 2); } -} diff --git a/tests/ui/issues/issue-10764.rs b/tests/ui/issues/issue-10764.rs deleted file mode 100644 index bb915f58d9d..00000000000 --- a/tests/ui/issues/issue-10764.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn f(_: extern "Rust" fn()) {} -extern "C" fn bar() {} - -fn main() { f(bar) } -//~^ ERROR mismatched types diff --git a/tests/ui/issues/issue-10767.rs b/tests/ui/issues/issue-10767.rs deleted file mode 100644 index 2060d15b4c7..00000000000 --- a/tests/ui/issues/issue-10767.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass - -pub fn main() { - fn f() { - } - let _: Box = Box::new(f as fn()); -} diff --git a/tests/ui/issues/issue-10802.rs b/tests/ui/issues/issue-10802.rs deleted file mode 100644 index eca701ce98c..00000000000 --- a/tests/ui/issues/issue-10802.rs +++ /dev/null @@ -1,45 +0,0 @@ -//@ run-pass -#![allow(dead_code)] - -struct DroppableStruct; -enum DroppableEnum { - DroppableVariant1, DroppableVariant2 -} - -static mut DROPPED: bool = false; - -impl Drop for DroppableStruct { - fn drop(&mut self) { - unsafe { DROPPED = true; } - } -} -impl Drop for DroppableEnum { - fn drop(&mut self) { - unsafe { DROPPED = true; } - } -} - -trait MyTrait { fn dummy(&self) { } } -impl MyTrait for Box {} -impl MyTrait for Box {} - -struct Whatever { w: Box } -impl Whatever { - fn new(w: Box) -> Whatever { - Whatever { w: w } - } -} - -fn main() { - { - let f: Box<_> = Box::new(DroppableStruct); - let _a = Whatever::new(Box::new(f) as Box); - } - assert!(unsafe { DROPPED }); - unsafe { DROPPED = false; } - { - let f: Box<_> = Box::new(DroppableEnum::DroppableVariant1); - let _a = Whatever::new(Box::new(f) as Box); - } - assert!(unsafe { DROPPED }); -} diff --git a/tests/ui/issues/issue-10806.rs b/tests/ui/issues/issue-10806.rs deleted file mode 100644 index 31315dc7c93..00000000000 --- a/tests/ui/issues/issue-10806.rs +++ /dev/null @@ -1,38 +0,0 @@ -//@ edition: 2015 -//@ run-pass -#![allow(unused_imports)] - - -pub fn foo() -> isize { - 3 -} -pub fn bar() -> isize { - 4 -} - -pub mod baz { - use {foo, bar}; - pub fn quux() -> isize { - foo() + bar() - } -} - -pub mod grault { - use {foo}; - pub fn garply() -> isize { - foo() - } -} - -pub mod waldo { - use {}; - pub fn plugh() -> isize { - 0 - } -} - -pub fn main() { - let _x = baz::quux(); - let _y = grault::garply(); - let _z = waldo::plugh(); -} diff --git a/tests/ui/issues/issue-10853.rs b/tests/ui/issues/issue-10853.rs deleted file mode 100644 index 4c22393d9c0..00000000000 --- a/tests/ui/issues/issue-10853.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ check-pass - -#![deny(missing_docs)] -#![doc="module"] - -#[doc="struct"] -pub struct Foo; - -pub fn foo() { - #![doc="fn"] -} - -#[doc="main"] -pub fn main() {} diff --git a/tests/ui/issues/issue-10877.rs b/tests/ui/issues/issue-10877.rs deleted file mode 100644 index 15a383175b9..00000000000 --- a/tests/ui/issues/issue-10877.rs +++ /dev/null @@ -1,16 +0,0 @@ -struct Foo { - x: isize, -} -extern "C" { - fn foo(1: ()); - //~^ ERROR: patterns aren't allowed in foreign function declarations - fn bar((): isize); - //~^ ERROR: patterns aren't allowed in foreign function declarations - fn baz(Foo { x }: isize); - //~^ ERROR: patterns aren't allowed in foreign function declarations - fn qux((x, y): ()); - //~^ ERROR: patterns aren't allowed in foreign function declarations - fn this_is_actually_ok(a: usize); - fn and_so_is_this(_: usize); -} -fn main() {} diff --git a/tests/ui/issues/issue-10902.rs b/tests/ui/issues/issue-10902.rs deleted file mode 100644 index 7cdf8808aa0..00000000000 --- a/tests/ui/issues/issue-10902.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ check-pass -#![allow(dead_code)] - -pub mod two_tuple { - pub trait T { fn dummy(&self) { } } - pub struct P<'a>(&'a (dyn T + 'a), &'a (dyn T + 'a)); - pub fn f<'a>(car: &'a dyn T, cdr: &'a dyn T) -> P<'a> { - P(car, cdr) - } -} - -pub mod two_fields { - pub trait T { fn dummy(&self) { } } - pub struct P<'a> { car: &'a (dyn T + 'a), cdr: &'a (dyn T + 'a) } - pub fn f<'a>(car: &'a dyn T, cdr: &'a dyn T) -> P<'a> { - P{ car: car, cdr: cdr } - } -} - -fn main() {} diff --git a/tests/ui/issues/issue-11004.rs b/tests/ui/issues/issue-11004.rs deleted file mode 100644 index 0c34554c12d..00000000000 --- a/tests/ui/issues/issue-11004.rs +++ /dev/null @@ -1,27 +0,0 @@ -use std::mem; - -struct A { x: i32, y: f64 } - -#[cfg(not(FALSE))] -unsafe fn access(n:*mut A) -> (i32, f64) { - let x : i32 = n.x; //~ ERROR no field `x` on type `*mut A` - let y : f64 = n.y; //~ ERROR no field `y` on type `*mut A` - (x, y) -} - -#[cfg(false)] -unsafe fn access(n:*mut A) -> (i32, f64) { - let x : i32 = (*n).x; - let y : f64 = (*n).y; - (x, y) -} - -fn main() { - let a : A = A { x: 3, y: 3.14 }; - let p : &A = &a; - let (x,y) = unsafe { - let n : *mut A = mem::transmute(p); - access(n) - }; - println!("x: {}, y: {}", x, y); -} diff --git a/tests/ui/issues/issue-11047.rs b/tests/ui/issues/issue-11047.rs deleted file mode 100644 index 6e1b2856afc..00000000000 --- a/tests/ui/issues/issue-11047.rs +++ /dev/null @@ -1,26 +0,0 @@ -//@ run-pass -// Test that static methods can be invoked on `type` aliases - -#![allow(unused_variables)] - -pub mod foo { - pub mod bar { - pub mod baz { - pub struct Qux; - - impl Qux { - pub fn new() {} - } - } - } -} - -fn main() { - - type Ham = foo::bar::baz::Qux; - let foo: () = foo::bar::baz::Qux::new(); // invoke directly - let bar: () = Ham::new(); // invoke via type alias - - type StringVec = Vec; - let sv = StringVec::new(); -} diff --git a/tests/ui/issues/issue-11085.rs b/tests/ui/issues/issue-11085.rs deleted file mode 100644 index c3f13199b30..00000000000 --- a/tests/ui/issues/issue-11085.rs +++ /dev/null @@ -1,44 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] - -struct Foo { - #[cfg(false)] - bar: baz, - foo: isize, -} - -struct Foo2 { - #[cfg(all())] - foo: isize, -} - -enum Bar1 { - Bar1_1, - #[cfg(false)] - Bar1_2(NotAType), -} - -enum Bar2 { - #[cfg(false)] - Bar2_1(NotAType), -} - -enum Bar3 { - Bar3_1 { - #[cfg(false)] - foo: isize, - bar: isize, - } -} - -pub fn main() { - let _f = Foo { foo: 3 }; - let _f = Foo2 { foo: 3 }; - - match Bar1::Bar1_1 { - Bar1::Bar1_1 => {} - } - - let _f = Bar3::Bar3_1 { bar: 3 }; -} diff --git a/tests/ui/issues/issue-11192.rs b/tests/ui/issues/issue-11192.rs deleted file mode 100644 index 1a3d8c9fe58..00000000000 --- a/tests/ui/issues/issue-11192.rs +++ /dev/null @@ -1,22 +0,0 @@ -struct Foo { - x: isize -} - - -impl Drop for Foo { - fn drop(&mut self) { - println!("drop {}", self.x); - } -} - - -fn main() { - let mut ptr: Box<_> = Box::new(Foo { x: 0 }); - let mut test = |foo: &Foo| { - println!("access {}", foo.x); - ptr = Box::new(Foo { x: ptr.x + 1 }); - println!("access {}", foo.x); - }; - test(&*ptr); - //~^ ERROR: cannot borrow `*ptr` as immutable -} diff --git a/tests/ui/issues/issue-11205.rs b/tests/ui/issues/issue-11205.rs deleted file mode 100644 index 8530514f0ed..00000000000 --- a/tests/ui/issues/issue-11205.rs +++ /dev/null @@ -1,84 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] - -trait Foo { fn dummy(&self) { } } -impl Foo for isize {} -fn foo(_: [&dyn Foo; 2]) {} -fn foos(_: &[&dyn Foo]) {} -fn foog(_: &[T], _: &[T]) {} - -fn bar(_: [Box; 2]) {} -fn bars(_: &[Box]) {} - -fn main() { - let x: [&dyn Foo; 2] = [&1, &2]; - foo(x); - foo([&1, &2]); - - let r = &1; - let x: [&dyn Foo; 2] = [r; 2]; - foo(x); - foo([&1; 2]); - - let x: &[&dyn Foo] = &[&1, &2]; - foos(x); - foos(&[&1, &2]); - - let x: &[&dyn Foo] = &[&1, &2]; - let r = &1; - foog(x, &[r]); - - let x: [Box; 2] = [Box::new(1), Box::new(2)]; - bar(x); - bar([Box::new(1), Box::new(2)]); - - let x: &[Box] = &[Box::new(1), Box::new(2)]; - bars(x); - bars(&[Box::new(1), Box::new(2)]); - - let x: &[Box] = &[Box::new(1), Box::new(2)]; - foog(x, &[Box::new(1)]); - - struct T<'a> { - t: [&'a (dyn Foo+'a); 2] - } - let _n = T { - t: [&1, &2] - }; - let r = &1; - let _n = T { - t: [r; 2] - }; - let x: [&dyn Foo; 2] = [&1, &2]; - let _n = T { - t: x - }; - - struct F<'b> { - t: &'b [&'b (dyn Foo+'b)] - } - let _n = F { - t: &[&1, &2] - }; - let r = &1; - let r: [&dyn Foo; 2] = [r; 2]; - let _n = F { - t: &r - }; - let x: [&dyn Foo; 2] = [&1, &2]; - let _n = F { - t: &x - }; - - struct M<'a> { - t: &'a [Box] - } - let _n = M { - t: &[Box::new(1), Box::new(2)] - }; - let x: [Box; 2] = [Box::new(1), Box::new(2)]; - let _n = M { - t: &x - }; -} diff --git a/tests/ui/issues/issue-11267.rs b/tests/ui/issues/issue-11267.rs deleted file mode 100644 index 036ad1d54ed..00000000000 --- a/tests/ui/issues/issue-11267.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ run-pass -// Tests that unary structs can be mutably borrowed. - -struct Empty; - -trait T { - fn next(&mut self) -> Option; -} -impl T for Empty { - fn next(&mut self) -> Option { None } -} - -fn do_something_with(a : &mut dyn T) { - println!("{:?}", a.next()) -} - -pub fn main() { - do_something_with(&mut Empty); -} diff --git a/tests/ui/issues/issue-11374.rs b/tests/ui/issues/issue-11374.rs deleted file mode 100644 index 60ee256c65a..00000000000 --- a/tests/ui/issues/issue-11374.rs +++ /dev/null @@ -1,28 +0,0 @@ -use std::io::{self, Read}; -use std::vec; - -pub struct Container<'a> { - reader: &'a mut dyn Read -} - -impl<'a> Container<'a> { - pub fn wrap<'s>(reader: &'s mut dyn io::Read) -> Container<'s> { - Container { reader: reader } - } - - pub fn read_to(&mut self, vec: &mut [u8]) { - self.reader.read(vec); - } -} - -pub fn for_stdin<'a>() -> Container<'a> { - let mut r = io::stdin(); - Container::wrap(&mut r as &mut dyn io::Read) - //~^ ERROR cannot return value referencing local variable -} - -fn main() { - let mut c = for_stdin(); - let mut v = Vec::new(); - c.read_to(v); //~ ERROR E0308 -} diff --git a/tests/ui/lifetimes/closure-lifetime-bounds-error.rs b/tests/ui/lifetimes/closure-lifetime-bounds-error.rs new file mode 100644 index 00000000000..31b9e124046 --- /dev/null +++ b/tests/ui/lifetimes/closure-lifetime-bounds-error.rs @@ -0,0 +1,8 @@ +fn test<'x>(x: &'x isize) { + drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + x + //~^ ERROR lifetime may not live long enough + })); +} + +fn main() {} diff --git a/tests/ui/lifetimes/container-lifetime-error.rs b/tests/ui/lifetimes/container-lifetime-error.rs new file mode 100644 index 00000000000..60ee256c65a --- /dev/null +++ b/tests/ui/lifetimes/container-lifetime-error.rs @@ -0,0 +1,28 @@ +use std::io::{self, Read}; +use std::vec; + +pub struct Container<'a> { + reader: &'a mut dyn Read +} + +impl<'a> Container<'a> { + pub fn wrap<'s>(reader: &'s mut dyn io::Read) -> Container<'s> { + Container { reader: reader } + } + + pub fn read_to(&mut self, vec: &mut [u8]) { + self.reader.read(vec); + } +} + +pub fn for_stdin<'a>() -> Container<'a> { + let mut r = io::stdin(); + Container::wrap(&mut r as &mut dyn io::Read) + //~^ ERROR cannot return value referencing local variable +} + +fn main() { + let mut c = for_stdin(); + let mut v = Vec::new(); + c.read_to(v); //~ ERROR E0308 +} diff --git a/tests/ui/lifetimes/enum-lifetime-container.rs b/tests/ui/lifetimes/enum-lifetime-container.rs new file mode 100644 index 00000000000..a59ccf926f9 --- /dev/null +++ b/tests/ui/lifetimes/enum-lifetime-container.rs @@ -0,0 +1,19 @@ +//@ run-pass +#![allow(dead_code)] +#![allow(unused_variables)] + +enum StdioContainer { + CreatePipe(bool) +} + +struct Test<'a> { + args: &'a [String], + io: &'a [StdioContainer] +} + +pub fn main() { + let test = Test { + args: &[], + io: &[StdioContainer::CreatePipe(true)] + }; +} diff --git a/tests/ui/lifetimes/keyword-self-lifetime-error.rs b/tests/ui/lifetimes/keyword-self-lifetime-error.rs new file mode 100644 index 00000000000..68ce0c2ea3c --- /dev/null +++ b/tests/ui/lifetimes/keyword-self-lifetime-error.rs @@ -0,0 +1,26 @@ +trait Serializable<'self, T> { + //~^ ERROR lifetimes cannot use keyword names + fn serialize(val: &'self T) -> Vec; //~ ERROR lifetimes cannot use keyword names + fn deserialize(repr: &[u8]) -> &'self T; //~ ERROR lifetimes cannot use keyword names +} + +impl<'self> Serializable for &'self str { + //~^ ERROR lifetimes cannot use keyword names + //~| ERROR lifetimes cannot use keyword names + //~| ERROR implicit elided lifetime not allowed here + fn serialize(val: &'self str) -> Vec { + //~^ ERROR lifetimes cannot use keyword names + vec![1] + } + fn deserialize(repr: &[u8]) -> &'self str { + //~^ ERROR lifetimes cannot use keyword names + "hi" + } +} + +fn main() { + println!("hello"); + let x = "foo".to_string(); + let y = x; + println!("{}", y); +} diff --git a/tests/ui/lifetimes/trait-lifetime-bounds.rs b/tests/ui/lifetimes/trait-lifetime-bounds.rs new file mode 100644 index 00000000000..7cdf8808aa0 --- /dev/null +++ b/tests/ui/lifetimes/trait-lifetime-bounds.rs @@ -0,0 +1,20 @@ +//@ check-pass +#![allow(dead_code)] + +pub mod two_tuple { + pub trait T { fn dummy(&self) { } } + pub struct P<'a>(&'a (dyn T + 'a), &'a (dyn T + 'a)); + pub fn f<'a>(car: &'a dyn T, cdr: &'a dyn T) -> P<'a> { + P(car, cdr) + } +} + +pub mod two_fields { + pub trait T { fn dummy(&self) { } } + pub struct P<'a> { car: &'a (dyn T + 'a), cdr: &'a (dyn T + 'a) } + pub fn f<'a>(car: &'a dyn T, cdr: &'a dyn T) -> P<'a> { + P{ car: car, cdr: cdr } + } +} + +fn main() {} diff --git a/tests/ui/lint/inner-doc-attributes.rs b/tests/ui/lint/inner-doc-attributes.rs new file mode 100644 index 00000000000..4c22393d9c0 --- /dev/null +++ b/tests/ui/lint/inner-doc-attributes.rs @@ -0,0 +1,14 @@ +//@ check-pass + +#![deny(missing_docs)] +#![doc="module"] + +#[doc="struct"] +pub struct Foo; + +pub fn foo() { + #![doc="fn"] +} + +#[doc="main"] +pub fn main() {} diff --git a/tests/ui/parser/comment-parsing.rs b/tests/ui/parser/comment-parsing.rs new file mode 100644 index 00000000000..c6c6939bda5 --- /dev/null +++ b/tests/ui/parser/comment-parsing.rs @@ -0,0 +1,10 @@ +//@ run-pass + +pub fn main() { + //// I am not a doc comment! + ////////////////// still not a doc comment + /////**** nope, me neither */ + /*** And neither am I! */ + 5; + /*****! certainly not I */ +} diff --git a/tests/ui/pattern/ascii-lowercase-match.rs b/tests/ui/pattern/ascii-lowercase-match.rs new file mode 100644 index 00000000000..5657ec1864b --- /dev/null +++ b/tests/ui/pattern/ascii-lowercase-match.rs @@ -0,0 +1,10 @@ +//@ run-pass + +static NAME: &'static str = "hello world"; + +fn main() { + match &*NAME.to_ascii_lowercase() { + "foo" => {} + _ => {} + } +} diff --git a/tests/ui/privacy/private-struct-access-error.rs b/tests/ui/privacy/private-struct-access-error.rs new file mode 100644 index 00000000000..acd07149619 --- /dev/null +++ b/tests/ui/privacy/private-struct-access-error.rs @@ -0,0 +1,9 @@ +mod a { + struct S; + impl S { } +} + +fn foo(_: a::S) { //~ ERROR: struct `S` is private +} + +fn main() {} diff --git a/tests/ui/structs/mutable-unit-struct-borrow.rs b/tests/ui/structs/mutable-unit-struct-borrow.rs new file mode 100644 index 00000000000..036ad1d54ed --- /dev/null +++ b/tests/ui/structs/mutable-unit-struct-borrow.rs @@ -0,0 +1,19 @@ +//@ run-pass +// Tests that unary structs can be mutably borrowed. + +struct Empty; + +trait T { + fn next(&mut self) -> Option; +} +impl T for Empty { + fn next(&mut self) -> Option { None } +} + +fn do_something_with(a : &mut dyn T) { + println!("{:?}", a.next()) +} + +pub fn main() { + do_something_with(&mut Empty); +} diff --git a/tests/ui/traits/blanket-impl-trait-object.rs b/tests/ui/traits/blanket-impl-trait-object.rs new file mode 100644 index 00000000000..51c740fd729 --- /dev/null +++ b/tests/ui/traits/blanket-impl-trait-object.rs @@ -0,0 +1,24 @@ +//@ check-pass + +pub struct Foo; + +pub trait Bar { + fn bar(&self); +} + +pub trait Baz { + fn baz(&self) { } +} + +impl Bar for T { + fn bar(&self) {} +} + +impl Baz for Foo {} + +pub fn foo(t: Box) { + t.bar(); // ~Foo doesn't implement Baz + (*t).bar(); // ok b/c Foo implements Baz +} + +fn main() {} diff --git a/tests/ui/traits/missing-trait-method-error.rs b/tests/ui/traits/missing-trait-method-error.rs new file mode 100644 index 00000000000..d899c3ffa91 --- /dev/null +++ b/tests/ui/traits/missing-trait-method-error.rs @@ -0,0 +1,23 @@ +pub mod a { + pub trait A { + fn foo(&self); + } + +} +pub mod b { + use a::A; + + pub struct B; + impl A for B { fn foo(&self) {} } + + pub mod c { + use b::B; + + fn foo(b: &B) { + b.foo(); //~ ERROR: no method named `foo` found + } + } + +} + +fn main() {} diff --git a/tests/ui/traits/negative-positive-impl-conflict.rs b/tests/ui/traits/negative-positive-impl-conflict.rs new file mode 100644 index 00000000000..d7e7122ebda --- /dev/null +++ b/tests/ui/traits/negative-positive-impl-conflict.rs @@ -0,0 +1,22 @@ +//@ compile-flags:-Ztranslate-lang=en_US + +#![feature(negative_impls)] +#![feature(marker_trait_attr)] + +#[marker] +trait MyTrait {} + +struct TestType(::std::marker::PhantomData); + +unsafe impl Send for TestType {} + +impl !Send for TestType {} +//~^ ERROR found both positive and negative implementation +//~| ERROR `!Send` impl requires `T: MyTrait` but the struct it is implemented for does not + +unsafe impl Send for TestType {} //~ ERROR conflicting implementations + +impl !Send for TestType {} +//~^ ERROR `!Send` impls cannot be specialized + +fn main() {} diff --git a/tests/ui/type-alias/mismatched-rc-foo-types.rs b/tests/ui/type-alias/mismatched-rc-foo-types.rs new file mode 100644 index 00000000000..43ff2360076 --- /dev/null +++ b/tests/ui/type-alias/mismatched-rc-foo-types.rs @@ -0,0 +1,10 @@ +use std::rc::Rc; +type Foo<'a, T> = &'a dyn Fn(&T); +type RcFoo<'a, T> = Rc>; + +fn bar_function(function: Foo) -> RcFoo { + //~^ ERROR mismatched types + let rc = Rc::new(function); +} + +fn main() {} diff --git a/tests/ui/type-alias/static-method-type-alias.rs b/tests/ui/type-alias/static-method-type-alias.rs new file mode 100644 index 00000000000..6e1b2856afc --- /dev/null +++ b/tests/ui/type-alias/static-method-type-alias.rs @@ -0,0 +1,26 @@ +//@ run-pass +// Test that static methods can be invoked on `type` aliases + +#![allow(unused_variables)] + +pub mod foo { + pub mod bar { + pub mod baz { + pub struct Qux; + + impl Qux { + pub fn new() {} + } + } + } +} + +fn main() { + + type Ham = foo::bar::baz::Qux; + let foo: () = foo::bar::baz::Qux::new(); // invoke directly + let bar: () = Ham::new(); // invoke via type alias + + type StringVec = Vec; + let sv = StringVec::new(); +} diff --git a/tests/ui/unsafe/raw-pointer-field-access-error.rs b/tests/ui/unsafe/raw-pointer-field-access-error.rs new file mode 100644 index 00000000000..0c34554c12d --- /dev/null +++ b/tests/ui/unsafe/raw-pointer-field-access-error.rs @@ -0,0 +1,27 @@ +use std::mem; + +struct A { x: i32, y: f64 } + +#[cfg(not(FALSE))] +unsafe fn access(n:*mut A) -> (i32, f64) { + let x : i32 = n.x; //~ ERROR no field `x` on type `*mut A` + let y : f64 = n.y; //~ ERROR no field `y` on type `*mut A` + (x, y) +} + +#[cfg(false)] +unsafe fn access(n:*mut A) -> (i32, f64) { + let x : i32 = (*n).x; + let y : f64 = (*n).y; + (x, y) +} + +fn main() { + let a : A = A { x: 3, y: 3.14 }; + let p : &A = &a; + let (x,y) = unsafe { + let n : *mut A = mem::transmute(p); + access(n) + }; + println!("x: {}, y: {}", x, y); +} -- cgit 1.4.1-3-g733a5 From e9959aa74e23eb340d6c9e9a4eab807be03b028f Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Fri, 18 Jul 2025 22:06:07 +0500 Subject: comments --- tests/ui/README.md | 4 + tests/ui/array-slice-vec/array-pattern-matching.rs | 14 ---- tests/ui/array-slice-vec/trait-object-arrays.rs | 84 --------------------- tests/ui/borrowck/closure-borrow-conflict-11192.rs | 24 ++++++ .../borrowck/closure-borrow-conflict-11192.stderr | 17 +++++ tests/ui/borrowck/closure-borrow-conflict.rs | 22 ------ .../ui/cfg/conditional-compilation-struct-11085.rs | 46 ++++++++++++ tests/ui/cfg/conditional-compilation-struct.rs | 44 ----------- tests/ui/closures/fnonce-closure-call.rs | 10 --- tests/ui/coercion/trait-object-arrays-11205.rs | 86 ++++++++++++++++++++++ .../primary-fluent-bundle-missing.rs | 24 ++++++ .../primary-fluent-bundle-missing.stderr | 47 ++++++++++++ tests/ui/drop/conditional-drop-10734.rs | 41 +++++++++++ tests/ui/drop/conditional-drop-behavior.rs | 39 ---------- tests/ui/drop/trait-object-drop-10802.rs | 47 ++++++++++++ tests/ui/drop/trait-object-drop-behavior.rs | 45 ----------- tests/ui/extern/extern-rust-fn-type-error-10764.rs | 7 ++ .../extern/extern-rust-fn-type-error-10764.stderr | 19 +++++ tests/ui/extern/extern-rust-fn-type-error.rs | 5 -- tests/ui/extern/foreign-fn-pattern-error-10877.rs | 18 +++++ .../extern/foreign-fn-pattern-error-10877.stderr | 27 +++++++ tests/ui/extern/foreign-fn-pattern-error.rs | 16 ---- tests/ui/fn/boxed-fn-pointer.rs | 7 -- tests/ui/generics/generic-type-inference.rs | 11 --- tests/ui/imports/empty-use-statements.rs | 38 ---------- .../use-declaration-no-path-segment-prefix.rs | 40 ++++++++++ tests/ui/inference/fnonce-closure-call.rs | 12 +++ tests/ui/inference/generic-type-inference-10436.rs | 13 ++++ tests/ui/issues/issue-10291.stderr | 11 --- tests/ui/issues/issue-102964.stderr | 19 ----- tests/ui/issues/issue-10412.stderr | 56 -------------- tests/ui/issues/issue-10465.stderr | 15 ---- tests/ui/issues/issue-10545.stderr | 15 ---- tests/ui/issues/issue-106755.stderr | 47 ------------ tests/ui/issues/issue-10764.stderr | 19 ----- tests/ui/issues/issue-10877.stderr | 27 ------- tests/ui/issues/issue-11004.stderr | 25 ------- tests/ui/issues/issue-11192.stderr | 17 ----- tests/ui/issues/issue-11374.stderr | 33 --------- tests/ui/lifetimes/array-pattern-matching-10396.rs | 16 ++++ .../ui/lifetimes/closure-lifetime-bounds-10291.rs | 10 +++ .../lifetimes/closure-lifetime-bounds-10291.stderr | 11 +++ .../ui/lifetimes/closure-lifetime-bounds-error.rs | 8 -- .../ui/lifetimes/container-lifetime-error-11374.rs | 30 ++++++++ .../container-lifetime-error-11374.stderr | 33 +++++++++ tests/ui/lifetimes/container-lifetime-error.rs | 28 ------- .../ui/lifetimes/enum-lifetime-container-10228.rs | 21 ++++++ tests/ui/lifetimes/enum-lifetime-container.rs | 19 ----- .../lifetimes/keyword-self-lifetime-error-10412.rs | 28 +++++++ .../keyword-self-lifetime-error-10412.stderr | 56 ++++++++++++++ tests/ui/lifetimes/keyword-self-lifetime-error.rs | 26 ------- tests/ui/lifetimes/trait-lifetime-bounds.rs | 20 ----- ...-struct-vs-struct-with-fields-borrowck-10902.rs | 22 ++++++ tests/ui/lint/inner-doc-attributes.rs | 14 ---- .../ui/lint/missing-doc-unsugard-doc-attr-10853.rs | 16 ++++ tests/ui/parser/comment-parsing.rs | 10 --- tests/ui/parser/doc-comment-parsing.rs | 12 +++ tests/ui/pattern/ascii-lowercase-match.rs | 10 --- ...emature-match-scrutinee-temporary-drop-10683.rs | 12 +++ tests/ui/privacy/private-struct-access-error.rs | 9 --- .../privacy/struct-field-and-impl-expose-10545.rs | 11 +++ .../struct-field-and-impl-expose-10545.stderr | 15 ++++ .../ui/structs/mutable-unit-struct-borrow-11267.rs | 21 ++++++ tests/ui/structs/mutable-unit-struct-borrow.rs | 19 ----- tests/ui/traits/blanket-impl-trait-object-10456.rs | 26 +++++++ tests/ui/traits/blanket-impl-trait-object.rs | 24 ------ tests/ui/traits/missing-trait-method-error.rs | 23 ------ tests/ui/traits/negative-positive-impl-conflict.rs | 22 ------ .../nested-mod-trait-method-lookup-leak-10465.rs | 25 +++++++ ...ested-mod-trait-method-lookup-leak-10465.stderr | 15 ++++ tests/ui/type-alias/dummy-binder-102964.rs | 12 +++ tests/ui/type-alias/dummy-binder-102964.stderr | 19 +++++ tests/ui/type-alias/mismatched-rc-foo-types.rs | 10 --- .../type-alias/static-method-type-alias-11047.rs | 28 +++++++ tests/ui/type-alias/static-method-type-alias.rs | 26 ------- tests/ui/unsafe/raw-pointer-field-access-error.rs | 2 + .../unsafe/raw-pointer-field-access-error.stderr | 25 +++++++ 77 files changed, 938 insertions(+), 887 deletions(-) delete mode 100644 tests/ui/array-slice-vec/array-pattern-matching.rs delete mode 100644 tests/ui/array-slice-vec/trait-object-arrays.rs create mode 100644 tests/ui/borrowck/closure-borrow-conflict-11192.rs create mode 100644 tests/ui/borrowck/closure-borrow-conflict-11192.stderr delete mode 100644 tests/ui/borrowck/closure-borrow-conflict.rs create mode 100644 tests/ui/cfg/conditional-compilation-struct-11085.rs delete mode 100644 tests/ui/cfg/conditional-compilation-struct.rs delete mode 100644 tests/ui/closures/fnonce-closure-call.rs create mode 100644 tests/ui/coercion/trait-object-arrays-11205.rs create mode 100644 tests/ui/diagnostics-infra/primary-fluent-bundle-missing.rs create mode 100644 tests/ui/diagnostics-infra/primary-fluent-bundle-missing.stderr create mode 100644 tests/ui/drop/conditional-drop-10734.rs delete mode 100644 tests/ui/drop/conditional-drop-behavior.rs create mode 100644 tests/ui/drop/trait-object-drop-10802.rs delete mode 100644 tests/ui/drop/trait-object-drop-behavior.rs create mode 100644 tests/ui/extern/extern-rust-fn-type-error-10764.rs create mode 100644 tests/ui/extern/extern-rust-fn-type-error-10764.stderr delete mode 100644 tests/ui/extern/extern-rust-fn-type-error.rs create mode 100644 tests/ui/extern/foreign-fn-pattern-error-10877.rs create mode 100644 tests/ui/extern/foreign-fn-pattern-error-10877.stderr delete mode 100644 tests/ui/extern/foreign-fn-pattern-error.rs delete mode 100644 tests/ui/fn/boxed-fn-pointer.rs delete mode 100644 tests/ui/generics/generic-type-inference.rs delete mode 100644 tests/ui/imports/empty-use-statements.rs create mode 100644 tests/ui/imports/use-declaration-no-path-segment-prefix.rs create mode 100644 tests/ui/inference/fnonce-closure-call.rs create mode 100644 tests/ui/inference/generic-type-inference-10436.rs delete mode 100644 tests/ui/issues/issue-10291.stderr delete mode 100644 tests/ui/issues/issue-102964.stderr delete mode 100644 tests/ui/issues/issue-10412.stderr delete mode 100644 tests/ui/issues/issue-10465.stderr delete mode 100644 tests/ui/issues/issue-10545.stderr delete mode 100644 tests/ui/issues/issue-106755.stderr delete mode 100644 tests/ui/issues/issue-10764.stderr delete mode 100644 tests/ui/issues/issue-10877.stderr delete mode 100644 tests/ui/issues/issue-11004.stderr delete mode 100644 tests/ui/issues/issue-11192.stderr delete mode 100644 tests/ui/issues/issue-11374.stderr create mode 100644 tests/ui/lifetimes/array-pattern-matching-10396.rs create mode 100644 tests/ui/lifetimes/closure-lifetime-bounds-10291.rs create mode 100644 tests/ui/lifetimes/closure-lifetime-bounds-10291.stderr delete mode 100644 tests/ui/lifetimes/closure-lifetime-bounds-error.rs create mode 100644 tests/ui/lifetimes/container-lifetime-error-11374.rs create mode 100644 tests/ui/lifetimes/container-lifetime-error-11374.stderr delete mode 100644 tests/ui/lifetimes/container-lifetime-error.rs create mode 100644 tests/ui/lifetimes/enum-lifetime-container-10228.rs delete mode 100644 tests/ui/lifetimes/enum-lifetime-container.rs create mode 100644 tests/ui/lifetimes/keyword-self-lifetime-error-10412.rs create mode 100644 tests/ui/lifetimes/keyword-self-lifetime-error-10412.stderr delete mode 100644 tests/ui/lifetimes/keyword-self-lifetime-error.rs delete mode 100644 tests/ui/lifetimes/trait-lifetime-bounds.rs create mode 100644 tests/ui/lifetimes/tuple-struct-vs-struct-with-fields-borrowck-10902.rs delete mode 100644 tests/ui/lint/inner-doc-attributes.rs create mode 100644 tests/ui/lint/missing-doc-unsugard-doc-attr-10853.rs delete mode 100644 tests/ui/parser/comment-parsing.rs create mode 100644 tests/ui/parser/doc-comment-parsing.rs delete mode 100644 tests/ui/pattern/ascii-lowercase-match.rs create mode 100644 tests/ui/pattern/premature-match-scrutinee-temporary-drop-10683.rs delete mode 100644 tests/ui/privacy/private-struct-access-error.rs create mode 100644 tests/ui/privacy/struct-field-and-impl-expose-10545.rs create mode 100644 tests/ui/privacy/struct-field-and-impl-expose-10545.stderr create mode 100644 tests/ui/structs/mutable-unit-struct-borrow-11267.rs delete mode 100644 tests/ui/structs/mutable-unit-struct-borrow.rs create mode 100644 tests/ui/traits/blanket-impl-trait-object-10456.rs delete mode 100644 tests/ui/traits/blanket-impl-trait-object.rs delete mode 100644 tests/ui/traits/missing-trait-method-error.rs delete mode 100644 tests/ui/traits/negative-positive-impl-conflict.rs create mode 100644 tests/ui/traits/nested-mod-trait-method-lookup-leak-10465.rs create mode 100644 tests/ui/traits/nested-mod-trait-method-lookup-leak-10465.stderr create mode 100644 tests/ui/type-alias/dummy-binder-102964.rs create mode 100644 tests/ui/type-alias/dummy-binder-102964.stderr delete mode 100644 tests/ui/type-alias/mismatched-rc-foo-types.rs create mode 100644 tests/ui/type-alias/static-method-type-alias-11047.rs delete mode 100644 tests/ui/type-alias/static-method-type-alias.rs create mode 100644 tests/ui/unsafe/raw-pointer-field-access-error.stderr diff --git a/tests/ui/README.md b/tests/ui/README.md index b635b6326fc..3630ce9285d 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -412,6 +412,10 @@ These tests revolve around command-line flags which change the way error/warning Exercises `#[diagnostic::*]` namespaced attributes. See [RFC 3368 Diagnostic attribute namespace](https://github.com/rust-lang/rfcs/blob/master/text/3368-diagnostic-attribute-namespace.md). +## `tests/ui/diagnostics-infra` + +This directory contains tests and infrastructure related to the diagnostics system, including support for translatable diagnostics + ## `tests/ui/diagnostic-width/`: `--diagnostic-width` Everything to do with `--diagnostic-width`. diff --git a/tests/ui/array-slice-vec/array-pattern-matching.rs b/tests/ui/array-slice-vec/array-pattern-matching.rs deleted file mode 100644 index 082216d557c..00000000000 --- a/tests/ui/array-slice-vec/array-pattern-matching.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ check-pass -#![allow(dead_code)] -#[derive(Debug)] -enum Foo<'s> { - V(&'s str) -} - -fn f(arr: &[&Foo]) { - for &f in arr { - println!("{:?}", f); - } -} - -fn main() {} diff --git a/tests/ui/array-slice-vec/trait-object-arrays.rs b/tests/ui/array-slice-vec/trait-object-arrays.rs deleted file mode 100644 index 8530514f0ed..00000000000 --- a/tests/ui/array-slice-vec/trait-object-arrays.rs +++ /dev/null @@ -1,84 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] - -trait Foo { fn dummy(&self) { } } -impl Foo for isize {} -fn foo(_: [&dyn Foo; 2]) {} -fn foos(_: &[&dyn Foo]) {} -fn foog(_: &[T], _: &[T]) {} - -fn bar(_: [Box; 2]) {} -fn bars(_: &[Box]) {} - -fn main() { - let x: [&dyn Foo; 2] = [&1, &2]; - foo(x); - foo([&1, &2]); - - let r = &1; - let x: [&dyn Foo; 2] = [r; 2]; - foo(x); - foo([&1; 2]); - - let x: &[&dyn Foo] = &[&1, &2]; - foos(x); - foos(&[&1, &2]); - - let x: &[&dyn Foo] = &[&1, &2]; - let r = &1; - foog(x, &[r]); - - let x: [Box; 2] = [Box::new(1), Box::new(2)]; - bar(x); - bar([Box::new(1), Box::new(2)]); - - let x: &[Box] = &[Box::new(1), Box::new(2)]; - bars(x); - bars(&[Box::new(1), Box::new(2)]); - - let x: &[Box] = &[Box::new(1), Box::new(2)]; - foog(x, &[Box::new(1)]); - - struct T<'a> { - t: [&'a (dyn Foo+'a); 2] - } - let _n = T { - t: [&1, &2] - }; - let r = &1; - let _n = T { - t: [r; 2] - }; - let x: [&dyn Foo; 2] = [&1, &2]; - let _n = T { - t: x - }; - - struct F<'b> { - t: &'b [&'b (dyn Foo+'b)] - } - let _n = F { - t: &[&1, &2] - }; - let r = &1; - let r: [&dyn Foo; 2] = [r; 2]; - let _n = F { - t: &r - }; - let x: [&dyn Foo; 2] = [&1, &2]; - let _n = F { - t: &x - }; - - struct M<'a> { - t: &'a [Box] - } - let _n = M { - t: &[Box::new(1), Box::new(2)] - }; - let x: [Box; 2] = [Box::new(1), Box::new(2)]; - let _n = M { - t: &x - }; -} diff --git a/tests/ui/borrowck/closure-borrow-conflict-11192.rs b/tests/ui/borrowck/closure-borrow-conflict-11192.rs new file mode 100644 index 00000000000..dff70d62d6f --- /dev/null +++ b/tests/ui/borrowck/closure-borrow-conflict-11192.rs @@ -0,0 +1,24 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11192 + +struct Foo { + x: isize +} + + +impl Drop for Foo { + fn drop(&mut self) { + println!("drop {}", self.x); + } +} + + +fn main() { + let mut ptr: Box<_> = Box::new(Foo { x: 0 }); + let mut test = |foo: &Foo| { + println!("access {}", foo.x); + ptr = Box::new(Foo { x: ptr.x + 1 }); + println!("access {}", foo.x); + }; + test(&*ptr); + //~^ ERROR: cannot borrow `*ptr` as immutable +} diff --git a/tests/ui/borrowck/closure-borrow-conflict-11192.stderr b/tests/ui/borrowck/closure-borrow-conflict-11192.stderr new file mode 100644 index 00000000000..f1df635276b --- /dev/null +++ b/tests/ui/borrowck/closure-borrow-conflict-11192.stderr @@ -0,0 +1,17 @@ +error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as mutable + --> $DIR/closure-borrow-conflict-11192.rs:22:10 + | +LL | let mut test = |foo: &Foo| { + | ----------- mutable borrow occurs here +LL | println!("access {}", foo.x); +LL | ptr = Box::new(Foo { x: ptr.x + 1 }); + | --- first borrow occurs due to use of `ptr` in closure +... +LL | test(&*ptr); + | ---- ^^^^^ immutable borrow occurs here + | | + | mutable borrow later used by call + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/tests/ui/borrowck/closure-borrow-conflict.rs b/tests/ui/borrowck/closure-borrow-conflict.rs deleted file mode 100644 index 1a3d8c9fe58..00000000000 --- a/tests/ui/borrowck/closure-borrow-conflict.rs +++ /dev/null @@ -1,22 +0,0 @@ -struct Foo { - x: isize -} - - -impl Drop for Foo { - fn drop(&mut self) { - println!("drop {}", self.x); - } -} - - -fn main() { - let mut ptr: Box<_> = Box::new(Foo { x: 0 }); - let mut test = |foo: &Foo| { - println!("access {}", foo.x); - ptr = Box::new(Foo { x: ptr.x + 1 }); - println!("access {}", foo.x); - }; - test(&*ptr); - //~^ ERROR: cannot borrow `*ptr` as immutable -} diff --git a/tests/ui/cfg/conditional-compilation-struct-11085.rs b/tests/ui/cfg/conditional-compilation-struct-11085.rs new file mode 100644 index 00000000000..cd6dded54d3 --- /dev/null +++ b/tests/ui/cfg/conditional-compilation-struct-11085.rs @@ -0,0 +1,46 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11085 + +//@ run-pass + +#![allow(dead_code)] + +struct Foo { + #[cfg(false)] + bar: baz, + foo: isize, +} + +struct Foo2 { + #[cfg(all())] + foo: isize, +} + +enum Bar1 { + Bar1_1, + #[cfg(false)] + Bar1_2(NotAType), +} + +enum Bar2 { + #[cfg(false)] + Bar2_1(NotAType), +} + +enum Bar3 { + Bar3_1 { + #[cfg(false)] + foo: isize, + bar: isize, + } +} + +pub fn main() { + let _f = Foo { foo: 3 }; + let _f = Foo2 { foo: 3 }; + + match Bar1::Bar1_1 { + Bar1::Bar1_1 => {} + } + + let _f = Bar3::Bar3_1 { bar: 3 }; +} diff --git a/tests/ui/cfg/conditional-compilation-struct.rs b/tests/ui/cfg/conditional-compilation-struct.rs deleted file mode 100644 index c3f13199b30..00000000000 --- a/tests/ui/cfg/conditional-compilation-struct.rs +++ /dev/null @@ -1,44 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] - -struct Foo { - #[cfg(false)] - bar: baz, - foo: isize, -} - -struct Foo2 { - #[cfg(all())] - foo: isize, -} - -enum Bar1 { - Bar1_1, - #[cfg(false)] - Bar1_2(NotAType), -} - -enum Bar2 { - #[cfg(false)] - Bar2_1(NotAType), -} - -enum Bar3 { - Bar3_1 { - #[cfg(false)] - foo: isize, - bar: isize, - } -} - -pub fn main() { - let _f = Foo { foo: 3 }; - let _f = Foo2 { foo: 3 }; - - match Bar1::Bar1_1 { - Bar1::Bar1_1 => {} - } - - let _f = Bar3::Bar3_1 { bar: 3 }; -} diff --git a/tests/ui/closures/fnonce-closure-call.rs b/tests/ui/closures/fnonce-closure-call.rs deleted file mode 100644 index 68ac0bbe49f..00000000000 --- a/tests/ui/closures/fnonce-closure-call.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -fn f(p: F) { - p(); -} - -pub fn main() { - let p = || (); - f(p); -} diff --git a/tests/ui/coercion/trait-object-arrays-11205.rs b/tests/ui/coercion/trait-object-arrays-11205.rs new file mode 100644 index 00000000000..45d69dce323 --- /dev/null +++ b/tests/ui/coercion/trait-object-arrays-11205.rs @@ -0,0 +1,86 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11205 + +//@ run-pass + +#![allow(dead_code)] + +trait Foo { fn dummy(&self) { } } +impl Foo for isize {} +fn foo(_: [&dyn Foo; 2]) {} +fn foos(_: &[&dyn Foo]) {} +fn foog(_: &[T], _: &[T]) {} + +fn bar(_: [Box; 2]) {} +fn bars(_: &[Box]) {} + +fn main() { + let x: [&dyn Foo; 2] = [&1, &2]; + foo(x); + foo([&1, &2]); + + let r = &1; + let x: [&dyn Foo; 2] = [r; 2]; + foo(x); + foo([&1; 2]); + + let x: &[&dyn Foo] = &[&1, &2]; + foos(x); + foos(&[&1, &2]); + + let x: &[&dyn Foo] = &[&1, &2]; + let r = &1; + foog(x, &[r]); + + let x: [Box; 2] = [Box::new(1), Box::new(2)]; + bar(x); + bar([Box::new(1), Box::new(2)]); + + let x: &[Box] = &[Box::new(1), Box::new(2)]; + bars(x); + bars(&[Box::new(1), Box::new(2)]); + + let x: &[Box] = &[Box::new(1), Box::new(2)]; + foog(x, &[Box::new(1)]); + + struct T<'a> { + t: [&'a (dyn Foo+'a); 2] + } + let _n = T { + t: [&1, &2] + }; + let r = &1; + let _n = T { + t: [r; 2] + }; + let x: [&dyn Foo; 2] = [&1, &2]; + let _n = T { + t: x + }; + + struct F<'b> { + t: &'b [&'b (dyn Foo+'b)] + } + let _n = F { + t: &[&1, &2] + }; + let r = &1; + let r: [&dyn Foo; 2] = [r; 2]; + let _n = F { + t: &r + }; + let x: [&dyn Foo; 2] = [&1, &2]; + let _n = F { + t: &x + }; + + struct M<'a> { + t: &'a [Box] + } + let _n = M { + t: &[Box::new(1), Box::new(2)] + }; + let x: [Box; 2] = [Box::new(1), Box::new(2)]; + let _n = M { + t: &x + }; +} diff --git a/tests/ui/diagnostics-infra/primary-fluent-bundle-missing.rs b/tests/ui/diagnostics-infra/primary-fluent-bundle-missing.rs new file mode 100644 index 00000000000..f2965778431 --- /dev/null +++ b/tests/ui/diagnostics-infra/primary-fluent-bundle-missing.rs @@ -0,0 +1,24 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/106755 + +//@ compile-flags:-Ztranslate-lang=en_US + +#![feature(negative_impls)] +#![feature(marker_trait_attr)] + +#[marker] +trait MyTrait {} + +struct TestType(::std::marker::PhantomData); + +unsafe impl Send for TestType {} + +impl !Send for TestType {} +//~^ ERROR found both positive and negative implementation +//~| ERROR `!Send` impl requires `T: MyTrait` but the struct it is implemented for does not + +unsafe impl Send for TestType {} //~ ERROR conflicting implementations + +impl !Send for TestType {} +//~^ ERROR `!Send` impls cannot be specialized + +fn main() {} diff --git a/tests/ui/diagnostics-infra/primary-fluent-bundle-missing.stderr b/tests/ui/diagnostics-infra/primary-fluent-bundle-missing.stderr new file mode 100644 index 00000000000..1dc31e161a7 --- /dev/null +++ b/tests/ui/diagnostics-infra/primary-fluent-bundle-missing.stderr @@ -0,0 +1,47 @@ +error[E0751]: found both positive and negative implementation of trait `Send` for type `TestType<_>`: + --> $DIR/primary-fluent-bundle-missing.rs:15:1 + | +LL | unsafe impl Send for TestType {} + | ------------------------------------------------------ positive implementation here +LL | +LL | impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ negative implementation here + +error[E0119]: conflicting implementations of trait `Send` for type `TestType<_>` + --> $DIR/primary-fluent-bundle-missing.rs:19:1 + | +LL | unsafe impl Send for TestType {} + | ------------------------------------------------------ first implementation here +... +LL | unsafe impl Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` + +error[E0367]: `!Send` impl requires `T: MyTrait` but the struct it is implemented for does not + --> $DIR/primary-fluent-bundle-missing.rs:15:9 + | +LL | impl !Send for TestType {} + | ^^^^^^^ + | +note: the implementor must specify the same requirement + --> $DIR/primary-fluent-bundle-missing.rs:11:1 + | +LL | struct TestType(::std::marker::PhantomData); + | ^^^^^^^^^^^^^^^^^^ + +error[E0366]: `!Send` impls cannot be specialized + --> $DIR/primary-fluent-bundle-missing.rs:21:1 + | +LL | impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `i32` is not a generic parameter +note: use the same sequence of generic lifetime, type and const parameters as the struct definition + --> $DIR/primary-fluent-bundle-missing.rs:11:1 + | +LL | struct TestType(::std::marker::PhantomData); + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0119, E0366, E0367, E0751. +For more information about an error, try `rustc --explain E0119`. diff --git a/tests/ui/drop/conditional-drop-10734.rs b/tests/ui/drop/conditional-drop-10734.rs new file mode 100644 index 00000000000..25f492bf9e0 --- /dev/null +++ b/tests/ui/drop/conditional-drop-10734.rs @@ -0,0 +1,41 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10734 + +//@ run-pass +#![allow(non_upper_case_globals)] + +// FIXME(static_mut_refs): this could use an atomic +#![allow(static_mut_refs)] + +static mut drop_count: usize = 0; + +struct Foo { + dropped: bool +} + +impl Drop for Foo { + fn drop(&mut self) { + // Test to make sure we haven't dropped already + assert!(!self.dropped); + self.dropped = true; + // And record the fact that we dropped for verification later + unsafe { drop_count += 1; } + } +} + +pub fn main() { + // An `if true { expr }` statement should compile the same as `{ expr }`. + if true { + let _a = Foo{ dropped: false }; + } + // Check that we dropped already (as expected from a `{ expr }`). + unsafe { assert_eq!(drop_count, 1); } + + // An `if false {} else { expr }` statement should compile the same as `{ expr }`. + if false { + panic!(); + } else { + let _a = Foo{ dropped: false }; + } + // Check that we dropped already (as expected from a `{ expr }`). + unsafe { assert_eq!(drop_count, 2); } +} diff --git a/tests/ui/drop/conditional-drop-behavior.rs b/tests/ui/drop/conditional-drop-behavior.rs deleted file mode 100644 index 6d815aeca07..00000000000 --- a/tests/ui/drop/conditional-drop-behavior.rs +++ /dev/null @@ -1,39 +0,0 @@ -//@ run-pass -#![allow(non_upper_case_globals)] - -// FIXME(static_mut_refs): this could use an atomic -#![allow(static_mut_refs)] - -static mut drop_count: usize = 0; - -struct Foo { - dropped: bool -} - -impl Drop for Foo { - fn drop(&mut self) { - // Test to make sure we haven't dropped already - assert!(!self.dropped); - self.dropped = true; - // And record the fact that we dropped for verification later - unsafe { drop_count += 1; } - } -} - -pub fn main() { - // An `if true { expr }` statement should compile the same as `{ expr }`. - if true { - let _a = Foo{ dropped: false }; - } - // Check that we dropped already (as expected from a `{ expr }`). - unsafe { assert_eq!(drop_count, 1); } - - // An `if false {} else { expr }` statement should compile the same as `{ expr }`. - if false { - panic!(); - } else { - let _a = Foo{ dropped: false }; - } - // Check that we dropped already (as expected from a `{ expr }`). - unsafe { assert_eq!(drop_count, 2); } -} diff --git a/tests/ui/drop/trait-object-drop-10802.rs b/tests/ui/drop/trait-object-drop-10802.rs new file mode 100644 index 00000000000..a8a955ad833 --- /dev/null +++ b/tests/ui/drop/trait-object-drop-10802.rs @@ -0,0 +1,47 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10802 + +//@ run-pass +#![allow(dead_code)] + +struct DroppableStruct; +enum DroppableEnum { + DroppableVariant1, DroppableVariant2 +} + +static mut DROPPED: bool = false; + +impl Drop for DroppableStruct { + fn drop(&mut self) { + unsafe { DROPPED = true; } + } +} +impl Drop for DroppableEnum { + fn drop(&mut self) { + unsafe { DROPPED = true; } + } +} + +trait MyTrait { fn dummy(&self) { } } +impl MyTrait for Box {} +impl MyTrait for Box {} + +struct Whatever { w: Box } +impl Whatever { + fn new(w: Box) -> Whatever { + Whatever { w: w } + } +} + +fn main() { + { + let f: Box<_> = Box::new(DroppableStruct); + let _a = Whatever::new(Box::new(f) as Box); + } + assert!(unsafe { DROPPED }); + unsafe { DROPPED = false; } + { + let f: Box<_> = Box::new(DroppableEnum::DroppableVariant1); + let _a = Whatever::new(Box::new(f) as Box); + } + assert!(unsafe { DROPPED }); +} diff --git a/tests/ui/drop/trait-object-drop-behavior.rs b/tests/ui/drop/trait-object-drop-behavior.rs deleted file mode 100644 index eca701ce98c..00000000000 --- a/tests/ui/drop/trait-object-drop-behavior.rs +++ /dev/null @@ -1,45 +0,0 @@ -//@ run-pass -#![allow(dead_code)] - -struct DroppableStruct; -enum DroppableEnum { - DroppableVariant1, DroppableVariant2 -} - -static mut DROPPED: bool = false; - -impl Drop for DroppableStruct { - fn drop(&mut self) { - unsafe { DROPPED = true; } - } -} -impl Drop for DroppableEnum { - fn drop(&mut self) { - unsafe { DROPPED = true; } - } -} - -trait MyTrait { fn dummy(&self) { } } -impl MyTrait for Box {} -impl MyTrait for Box {} - -struct Whatever { w: Box } -impl Whatever { - fn new(w: Box) -> Whatever { - Whatever { w: w } - } -} - -fn main() { - { - let f: Box<_> = Box::new(DroppableStruct); - let _a = Whatever::new(Box::new(f) as Box); - } - assert!(unsafe { DROPPED }); - unsafe { DROPPED = false; } - { - let f: Box<_> = Box::new(DroppableEnum::DroppableVariant1); - let _a = Whatever::new(Box::new(f) as Box); - } - assert!(unsafe { DROPPED }); -} diff --git a/tests/ui/extern/extern-rust-fn-type-error-10764.rs b/tests/ui/extern/extern-rust-fn-type-error-10764.rs new file mode 100644 index 00000000000..f172f6e6b7d --- /dev/null +++ b/tests/ui/extern/extern-rust-fn-type-error-10764.rs @@ -0,0 +1,7 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10764 + +fn f(_: extern "Rust" fn()) {} +extern "C" fn bar() {} + +fn main() { f(bar) } +//~^ ERROR mismatched types diff --git a/tests/ui/extern/extern-rust-fn-type-error-10764.stderr b/tests/ui/extern/extern-rust-fn-type-error-10764.stderr new file mode 100644 index 00000000000..fa72d7dd6b2 --- /dev/null +++ b/tests/ui/extern/extern-rust-fn-type-error-10764.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/extern-rust-fn-type-error-10764.rs:6:15 + | +LL | fn main() { f(bar) } + | - ^^^ expected "Rust" fn, found "C" fn + | | + | arguments to this function are incorrect + | + = note: expected fn pointer `fn()` + found fn item `extern "C" fn() {bar}` +note: function defined here + --> $DIR/extern-rust-fn-type-error-10764.rs:3:4 + | +LL | fn f(_: extern "Rust" fn()) {} + | ^ --------------------- + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/extern/extern-rust-fn-type-error.rs b/tests/ui/extern/extern-rust-fn-type-error.rs deleted file mode 100644 index bb915f58d9d..00000000000 --- a/tests/ui/extern/extern-rust-fn-type-error.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn f(_: extern "Rust" fn()) {} -extern "C" fn bar() {} - -fn main() { f(bar) } -//~^ ERROR mismatched types diff --git a/tests/ui/extern/foreign-fn-pattern-error-10877.rs b/tests/ui/extern/foreign-fn-pattern-error-10877.rs new file mode 100644 index 00000000000..9a047d4f34e --- /dev/null +++ b/tests/ui/extern/foreign-fn-pattern-error-10877.rs @@ -0,0 +1,18 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10877 + +struct Foo { + x: isize, +} +extern "C" { + fn foo(1: ()); + //~^ ERROR: patterns aren't allowed in foreign function declarations + fn bar((): isize); + //~^ ERROR: patterns aren't allowed in foreign function declarations + fn baz(Foo { x }: isize); + //~^ ERROR: patterns aren't allowed in foreign function declarations + fn qux((x, y): ()); + //~^ ERROR: patterns aren't allowed in foreign function declarations + fn this_is_actually_ok(a: usize); + fn and_so_is_this(_: usize); +} +fn main() {} diff --git a/tests/ui/extern/foreign-fn-pattern-error-10877.stderr b/tests/ui/extern/foreign-fn-pattern-error-10877.stderr new file mode 100644 index 00000000000..cab7b6ab06b --- /dev/null +++ b/tests/ui/extern/foreign-fn-pattern-error-10877.stderr @@ -0,0 +1,27 @@ +error[E0130]: patterns aren't allowed in foreign function declarations + --> $DIR/foreign-fn-pattern-error-10877.rs:7:12 + | +LL | fn foo(1: ()); + | ^ pattern not allowed in foreign function + +error[E0130]: patterns aren't allowed in foreign function declarations + --> $DIR/foreign-fn-pattern-error-10877.rs:9:12 + | +LL | fn bar((): isize); + | ^^ pattern not allowed in foreign function + +error[E0130]: patterns aren't allowed in foreign function declarations + --> $DIR/foreign-fn-pattern-error-10877.rs:11:12 + | +LL | fn baz(Foo { x }: isize); + | ^^^^^^^^^ pattern not allowed in foreign function + +error[E0130]: patterns aren't allowed in foreign function declarations + --> $DIR/foreign-fn-pattern-error-10877.rs:13:12 + | +LL | fn qux((x, y): ()); + | ^^^^^^ pattern not allowed in foreign function + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0130`. diff --git a/tests/ui/extern/foreign-fn-pattern-error.rs b/tests/ui/extern/foreign-fn-pattern-error.rs deleted file mode 100644 index 15a383175b9..00000000000 --- a/tests/ui/extern/foreign-fn-pattern-error.rs +++ /dev/null @@ -1,16 +0,0 @@ -struct Foo { - x: isize, -} -extern "C" { - fn foo(1: ()); - //~^ ERROR: patterns aren't allowed in foreign function declarations - fn bar((): isize); - //~^ ERROR: patterns aren't allowed in foreign function declarations - fn baz(Foo { x }: isize); - //~^ ERROR: patterns aren't allowed in foreign function declarations - fn qux((x, y): ()); - //~^ ERROR: patterns aren't allowed in foreign function declarations - fn this_is_actually_ok(a: usize); - fn and_so_is_this(_: usize); -} -fn main() {} diff --git a/tests/ui/fn/boxed-fn-pointer.rs b/tests/ui/fn/boxed-fn-pointer.rs deleted file mode 100644 index 2060d15b4c7..00000000000 --- a/tests/ui/fn/boxed-fn-pointer.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass - -pub fn main() { - fn f() { - } - let _: Box = Box::new(f as fn()); -} diff --git a/tests/ui/generics/generic-type-inference.rs b/tests/ui/generics/generic-type-inference.rs deleted file mode 100644 index 672aa2464dc..00000000000 --- a/tests/ui/generics/generic-type-inference.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -fn works(x: T) -> Vec { vec![x] } - -fn also_works(x: T) -> Vec { vec![x] } - -fn main() { - let _: Vec = works(0); - let _: Vec = also_works(0); - let _ = works(0); - let _ = also_works(0); -} diff --git a/tests/ui/imports/empty-use-statements.rs b/tests/ui/imports/empty-use-statements.rs deleted file mode 100644 index 31315dc7c93..00000000000 --- a/tests/ui/imports/empty-use-statements.rs +++ /dev/null @@ -1,38 +0,0 @@ -//@ edition: 2015 -//@ run-pass -#![allow(unused_imports)] - - -pub fn foo() -> isize { - 3 -} -pub fn bar() -> isize { - 4 -} - -pub mod baz { - use {foo, bar}; - pub fn quux() -> isize { - foo() + bar() - } -} - -pub mod grault { - use {foo}; - pub fn garply() -> isize { - foo() - } -} - -pub mod waldo { - use {}; - pub fn plugh() -> isize { - 0 - } -} - -pub fn main() { - let _x = baz::quux(); - let _y = grault::garply(); - let _z = waldo::plugh(); -} diff --git a/tests/ui/imports/use-declaration-no-path-segment-prefix.rs b/tests/ui/imports/use-declaration-no-path-segment-prefix.rs new file mode 100644 index 00000000000..f7fbc084ebf --- /dev/null +++ b/tests/ui/imports/use-declaration-no-path-segment-prefix.rs @@ -0,0 +1,40 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10806 + +//@ edition: 2015 +//@ run-pass +#![allow(unused_imports)] + + +pub fn foo() -> isize { + 3 +} +pub fn bar() -> isize { + 4 +} + +pub mod baz { + use {foo, bar}; + pub fn quux() -> isize { + foo() + bar() + } +} + +pub mod grault { + use {foo}; + pub fn garply() -> isize { + foo() + } +} + +pub mod waldo { + use {}; + pub fn plugh() -> isize { + 0 + } +} + +pub fn main() { + let _x = baz::quux(); + let _y = grault::garply(); + let _z = waldo::plugh(); +} diff --git a/tests/ui/inference/fnonce-closure-call.rs b/tests/ui/inference/fnonce-closure-call.rs new file mode 100644 index 00000000000..262a193609f --- /dev/null +++ b/tests/ui/inference/fnonce-closure-call.rs @@ -0,0 +1,12 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10718 + +//@ run-pass + +fn f(p: F) { + p(); +} + +pub fn main() { + let p = || (); + f(p); +} diff --git a/tests/ui/inference/generic-type-inference-10436.rs b/tests/ui/inference/generic-type-inference-10436.rs new file mode 100644 index 00000000000..456a9b86c34 --- /dev/null +++ b/tests/ui/inference/generic-type-inference-10436.rs @@ -0,0 +1,13 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10436 + +//@ run-pass +fn works(x: T) -> Vec { vec![x] } + +fn also_works(x: T) -> Vec { vec![x] } + +fn main() { + let _: Vec = works(0); + let _: Vec = also_works(0); + let _ = works(0); + let _ = also_works(0); +} diff --git a/tests/ui/issues/issue-10291.stderr b/tests/ui/issues/issue-10291.stderr deleted file mode 100644 index 68ed9a0de5d..00000000000 --- a/tests/ui/issues/issue-10291.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: lifetime may not live long enough - --> $DIR/issue-10291.rs:3:9 - | -LL | fn test<'x>(x: &'x isize) { - | -- lifetime `'x` defined here -LL | drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { -LL | x - | ^ returning this value requires that `'x` must outlive `'static` - -error: aborting due to 1 previous error - diff --git a/tests/ui/issues/issue-102964.stderr b/tests/ui/issues/issue-102964.stderr deleted file mode 100644 index 0e2761f3f57..00000000000 --- a/tests/ui/issues/issue-102964.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-102964.rs:5:41 - | -LL | fn bar_function(function: Foo) -> RcFoo { - | ------------ ^^^^^^^^ expected `Rc<&dyn Fn(&T)>`, found `()` - | | - | implicitly returns `()` as its body has no tail or `return` expression - | - = note: expected struct `Rc<&dyn for<'a> Fn(&'a T)>` - found unit type `()` -help: consider returning the local binding `rc` - | -LL ~ let rc = Rc::new(function); -LL + rc - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-10412.stderr b/tests/ui/issues/issue-10412.stderr deleted file mode 100644 index c74ba1306cc..00000000000 --- a/tests/ui/issues/issue-10412.stderr +++ /dev/null @@ -1,56 +0,0 @@ -error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:1:20 - | -LL | trait Serializable<'self, T> { - | ^^^^^ - -error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:3:24 - | -LL | fn serialize(val: &'self T) -> Vec; - | ^^^^^ - -error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:4:37 - | -LL | fn deserialize(repr: &[u8]) -> &'self T; - | ^^^^^ - -error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:7:6 - | -LL | impl<'self> Serializable for &'self str { - | ^^^^^ - -error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:7:36 - | -LL | impl<'self> Serializable for &'self str { - | ^^^^^ - -error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:11:24 - | -LL | fn serialize(val: &'self str) -> Vec { - | ^^^^^ - -error: lifetimes cannot use keyword names - --> $DIR/issue-10412.rs:15:37 - | -LL | fn deserialize(repr: &[u8]) -> &'self str { - | ^^^^^ - -error[E0726]: implicit elided lifetime not allowed here - --> $DIR/issue-10412.rs:7:13 - | -LL | impl<'self> Serializable for &'self str { - | ^^^^^^^^^^^^^^^^^ expected lifetime parameter - | -help: indicate the anonymous lifetime - | -LL | impl<'self> Serializable<'_, str> for &'self str { - | +++ - -error: aborting due to 8 previous errors - -For more information about this error, try `rustc --explain E0726`. diff --git a/tests/ui/issues/issue-10465.stderr b/tests/ui/issues/issue-10465.stderr deleted file mode 100644 index 0f46ebe505a..00000000000 --- a/tests/ui/issues/issue-10465.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0599]: no method named `foo` found for reference `&B` in the current scope - --> $DIR/issue-10465.rs:17:15 - | -LL | b.foo(); - | ^^^ method not found in `&B` - | - = help: items from traits can only be used if the trait is in scope -help: trait `A` which provides `foo` is implemented but not in scope; perhaps you want to import it - | -LL + use a::A; - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/issues/issue-10545.stderr b/tests/ui/issues/issue-10545.stderr deleted file mode 100644 index 9aa04217174..00000000000 --- a/tests/ui/issues/issue-10545.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0603]: struct `S` is private - --> $DIR/issue-10545.rs:6:14 - | -LL | fn foo(_: a::S) { - | ^ private struct - | -note: the struct `S` is defined here - --> $DIR/issue-10545.rs:2:5 - | -LL | struct S; - | ^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/issues/issue-106755.stderr b/tests/ui/issues/issue-106755.stderr deleted file mode 100644 index da6b8c5c563..00000000000 --- a/tests/ui/issues/issue-106755.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error[E0751]: found both positive and negative implementation of trait `Send` for type `TestType<_>`: - --> $DIR/issue-106755.rs:13:1 - | -LL | unsafe impl Send for TestType {} - | ------------------------------------------------------ positive implementation here -LL | -LL | impl !Send for TestType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ negative implementation here - -error[E0119]: conflicting implementations of trait `Send` for type `TestType<_>` - --> $DIR/issue-106755.rs:17:1 - | -LL | unsafe impl Send for TestType {} - | ------------------------------------------------------ first implementation here -... -LL | unsafe impl Send for TestType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` - -error[E0367]: `!Send` impl requires `T: MyTrait` but the struct it is implemented for does not - --> $DIR/issue-106755.rs:13:9 - | -LL | impl !Send for TestType {} - | ^^^^^^^ - | -note: the implementor must specify the same requirement - --> $DIR/issue-106755.rs:9:1 - | -LL | struct TestType(::std::marker::PhantomData); - | ^^^^^^^^^^^^^^^^^^ - -error[E0366]: `!Send` impls cannot be specialized - --> $DIR/issue-106755.rs:19:1 - | -LL | impl !Send for TestType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `i32` is not a generic parameter -note: use the same sequence of generic lifetime, type and const parameters as the struct definition - --> $DIR/issue-106755.rs:9:1 - | -LL | struct TestType(::std::marker::PhantomData); - | ^^^^^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0119, E0366, E0367, E0751. -For more information about an error, try `rustc --explain E0119`. diff --git a/tests/ui/issues/issue-10764.stderr b/tests/ui/issues/issue-10764.stderr deleted file mode 100644 index f3bd0100a72..00000000000 --- a/tests/ui/issues/issue-10764.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-10764.rs:4:15 - | -LL | fn main() { f(bar) } - | - ^^^ expected "Rust" fn, found "C" fn - | | - | arguments to this function are incorrect - | - = note: expected fn pointer `fn()` - found fn item `extern "C" fn() {bar}` -note: function defined here - --> $DIR/issue-10764.rs:1:4 - | -LL | fn f(_: extern "Rust" fn()) {} - | ^ --------------------- - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-10877.stderr b/tests/ui/issues/issue-10877.stderr deleted file mode 100644 index bd3797cba55..00000000000 --- a/tests/ui/issues/issue-10877.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0130]: patterns aren't allowed in foreign function declarations - --> $DIR/issue-10877.rs:5:12 - | -LL | fn foo(1: ()); - | ^ pattern not allowed in foreign function - -error[E0130]: patterns aren't allowed in foreign function declarations - --> $DIR/issue-10877.rs:7:12 - | -LL | fn bar((): isize); - | ^^ pattern not allowed in foreign function - -error[E0130]: patterns aren't allowed in foreign function declarations - --> $DIR/issue-10877.rs:9:12 - | -LL | fn baz(Foo { x }: isize); - | ^^^^^^^^^ pattern not allowed in foreign function - -error[E0130]: patterns aren't allowed in foreign function declarations - --> $DIR/issue-10877.rs:11:12 - | -LL | fn qux((x, y): ()); - | ^^^^^^ pattern not allowed in foreign function - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0130`. diff --git a/tests/ui/issues/issue-11004.stderr b/tests/ui/issues/issue-11004.stderr deleted file mode 100644 index 6d157c91130..00000000000 --- a/tests/ui/issues/issue-11004.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0609]: no field `x` on type `*mut A` - --> $DIR/issue-11004.rs:7:21 - | -LL | let x : i32 = n.x; - | ^ unknown field - | -help: `n` is a raw pointer; try dereferencing it - | -LL | let x : i32 = (*n).x; - | ++ + - -error[E0609]: no field `y` on type `*mut A` - --> $DIR/issue-11004.rs:8:21 - | -LL | let y : f64 = n.y; - | ^ unknown field - | -help: `n` is a raw pointer; try dereferencing it - | -LL | let y : f64 = (*n).y; - | ++ + - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/issues/issue-11192.stderr b/tests/ui/issues/issue-11192.stderr deleted file mode 100644 index a8a18c49549..00000000000 --- a/tests/ui/issues/issue-11192.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as mutable - --> $DIR/issue-11192.rs:20:10 - | -LL | let mut test = |foo: &Foo| { - | ----------- mutable borrow occurs here -LL | println!("access {}", foo.x); -LL | ptr = Box::new(Foo { x: ptr.x + 1 }); - | --- first borrow occurs due to use of `ptr` in closure -... -LL | test(&*ptr); - | ---- ^^^^^ immutable borrow occurs here - | | - | mutable borrow later used by call - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/tests/ui/issues/issue-11374.stderr b/tests/ui/issues/issue-11374.stderr deleted file mode 100644 index 3ae5cfc79f8..00000000000 --- a/tests/ui/issues/issue-11374.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-11374.rs:27:15 - | -LL | c.read_to(v); - | ------- ^ expected `&mut [u8]`, found `Vec<_>` - | | - | arguments to this method are incorrect - | - = note: expected mutable reference `&mut [u8]` - found struct `Vec<_>` -note: method defined here - --> $DIR/issue-11374.rs:13:12 - | -LL | pub fn read_to(&mut self, vec: &mut [u8]) { - | ^^^^^^^ -------------- -help: consider mutably borrowing here - | -LL | c.read_to(&mut v); - | ++++ - -error[E0515]: cannot return value referencing local variable `r` - --> $DIR/issue-11374.rs:20:5 - | -LL | Container::wrap(&mut r as &mut dyn io::Read) - | ^^^^^^^^^^^^^^^^------^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | `r` is borrowed here - | returns a value referencing data owned by the current function - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0308, E0515. -For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/lifetimes/array-pattern-matching-10396.rs b/tests/ui/lifetimes/array-pattern-matching-10396.rs new file mode 100644 index 00000000000..5fc141bc460 --- /dev/null +++ b/tests/ui/lifetimes/array-pattern-matching-10396.rs @@ -0,0 +1,16 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10396 + +//@ check-pass +#![allow(dead_code)] +#[derive(Debug)] +enum Foo<'s> { + V(&'s str) +} + +fn f(arr: &[&Foo]) { + for &f in arr { + println!("{:?}", f); + } +} + +fn main() {} diff --git a/tests/ui/lifetimes/closure-lifetime-bounds-10291.rs b/tests/ui/lifetimes/closure-lifetime-bounds-10291.rs new file mode 100644 index 00000000000..42dc6c2cafa --- /dev/null +++ b/tests/ui/lifetimes/closure-lifetime-bounds-10291.rs @@ -0,0 +1,10 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10291 + +fn test<'x>(x: &'x isize) { + drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + x + //~^ ERROR lifetime may not live long enough + })); +} + +fn main() {} diff --git a/tests/ui/lifetimes/closure-lifetime-bounds-10291.stderr b/tests/ui/lifetimes/closure-lifetime-bounds-10291.stderr new file mode 100644 index 00000000000..34f8ca40871 --- /dev/null +++ b/tests/ui/lifetimes/closure-lifetime-bounds-10291.stderr @@ -0,0 +1,11 @@ +error: lifetime may not live long enough + --> $DIR/closure-lifetime-bounds-10291.rs:5:9 + | +LL | fn test<'x>(x: &'x isize) { + | -- lifetime `'x` defined here +LL | drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { +LL | x + | ^ returning this value requires that `'x` must outlive `'static` + +error: aborting due to 1 previous error + diff --git a/tests/ui/lifetimes/closure-lifetime-bounds-error.rs b/tests/ui/lifetimes/closure-lifetime-bounds-error.rs deleted file mode 100644 index 31b9e124046..00000000000 --- a/tests/ui/lifetimes/closure-lifetime-bounds-error.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn test<'x>(x: &'x isize) { - drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - x - //~^ ERROR lifetime may not live long enough - })); -} - -fn main() {} diff --git a/tests/ui/lifetimes/container-lifetime-error-11374.rs b/tests/ui/lifetimes/container-lifetime-error-11374.rs new file mode 100644 index 00000000000..59d13d04e46 --- /dev/null +++ b/tests/ui/lifetimes/container-lifetime-error-11374.rs @@ -0,0 +1,30 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11374 + +use std::io::{self, Read}; +use std::vec; + +pub struct Container<'a> { + reader: &'a mut dyn Read +} + +impl<'a> Container<'a> { + pub fn wrap<'s>(reader: &'s mut dyn io::Read) -> Container<'s> { + Container { reader: reader } + } + + pub fn read_to(&mut self, vec: &mut [u8]) { + self.reader.read(vec); + } +} + +pub fn for_stdin<'a>() -> Container<'a> { + let mut r = io::stdin(); + Container::wrap(&mut r as &mut dyn io::Read) + //~^ ERROR cannot return value referencing local variable +} + +fn main() { + let mut c = for_stdin(); + let mut v = Vec::new(); + c.read_to(v); //~ ERROR E0308 +} diff --git a/tests/ui/lifetimes/container-lifetime-error-11374.stderr b/tests/ui/lifetimes/container-lifetime-error-11374.stderr new file mode 100644 index 00000000000..a29b5ae137c --- /dev/null +++ b/tests/ui/lifetimes/container-lifetime-error-11374.stderr @@ -0,0 +1,33 @@ +error[E0308]: mismatched types + --> $DIR/container-lifetime-error-11374.rs:29:15 + | +LL | c.read_to(v); + | ------- ^ expected `&mut [u8]`, found `Vec<_>` + | | + | arguments to this method are incorrect + | + = note: expected mutable reference `&mut [u8]` + found struct `Vec<_>` +note: method defined here + --> $DIR/container-lifetime-error-11374.rs:15:12 + | +LL | pub fn read_to(&mut self, vec: &mut [u8]) { + | ^^^^^^^ -------------- +help: consider mutably borrowing here + | +LL | c.read_to(&mut v); + | ++++ + +error[E0515]: cannot return value referencing local variable `r` + --> $DIR/container-lifetime-error-11374.rs:22:5 + | +LL | Container::wrap(&mut r as &mut dyn io::Read) + | ^^^^^^^^^^^^^^^^------^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | `r` is borrowed here + | returns a value referencing data owned by the current function + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0308, E0515. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/lifetimes/container-lifetime-error.rs b/tests/ui/lifetimes/container-lifetime-error.rs deleted file mode 100644 index 60ee256c65a..00000000000 --- a/tests/ui/lifetimes/container-lifetime-error.rs +++ /dev/null @@ -1,28 +0,0 @@ -use std::io::{self, Read}; -use std::vec; - -pub struct Container<'a> { - reader: &'a mut dyn Read -} - -impl<'a> Container<'a> { - pub fn wrap<'s>(reader: &'s mut dyn io::Read) -> Container<'s> { - Container { reader: reader } - } - - pub fn read_to(&mut self, vec: &mut [u8]) { - self.reader.read(vec); - } -} - -pub fn for_stdin<'a>() -> Container<'a> { - let mut r = io::stdin(); - Container::wrap(&mut r as &mut dyn io::Read) - //~^ ERROR cannot return value referencing local variable -} - -fn main() { - let mut c = for_stdin(); - let mut v = Vec::new(); - c.read_to(v); //~ ERROR E0308 -} diff --git a/tests/ui/lifetimes/enum-lifetime-container-10228.rs b/tests/ui/lifetimes/enum-lifetime-container-10228.rs new file mode 100644 index 00000000000..ebbefb619c6 --- /dev/null +++ b/tests/ui/lifetimes/enum-lifetime-container-10228.rs @@ -0,0 +1,21 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10228 + +//@ run-pass +#![allow(dead_code)] +#![allow(unused_variables)] + +enum StdioContainer { + CreatePipe(bool) +} + +struct Test<'a> { + args: &'a [String], + io: &'a [StdioContainer] +} + +pub fn main() { + let test = Test { + args: &[], + io: &[StdioContainer::CreatePipe(true)] + }; +} diff --git a/tests/ui/lifetimes/enum-lifetime-container.rs b/tests/ui/lifetimes/enum-lifetime-container.rs deleted file mode 100644 index a59ccf926f9..00000000000 --- a/tests/ui/lifetimes/enum-lifetime-container.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ run-pass -#![allow(dead_code)] -#![allow(unused_variables)] - -enum StdioContainer { - CreatePipe(bool) -} - -struct Test<'a> { - args: &'a [String], - io: &'a [StdioContainer] -} - -pub fn main() { - let test = Test { - args: &[], - io: &[StdioContainer::CreatePipe(true)] - }; -} diff --git a/tests/ui/lifetimes/keyword-self-lifetime-error-10412.rs b/tests/ui/lifetimes/keyword-self-lifetime-error-10412.rs new file mode 100644 index 00000000000..a5b303df2fd --- /dev/null +++ b/tests/ui/lifetimes/keyword-self-lifetime-error-10412.rs @@ -0,0 +1,28 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10412 + +trait Serializable<'self, T> { + //~^ ERROR lifetimes cannot use keyword names + fn serialize(val: &'self T) -> Vec; //~ ERROR lifetimes cannot use keyword names + fn deserialize(repr: &[u8]) -> &'self T; //~ ERROR lifetimes cannot use keyword names +} + +impl<'self> Serializable for &'self str { + //~^ ERROR lifetimes cannot use keyword names + //~| ERROR lifetimes cannot use keyword names + //~| ERROR implicit elided lifetime not allowed here + fn serialize(val: &'self str) -> Vec { + //~^ ERROR lifetimes cannot use keyword names + vec![1] + } + fn deserialize(repr: &[u8]) -> &'self str { + //~^ ERROR lifetimes cannot use keyword names + "hi" + } +} + +fn main() { + println!("hello"); + let x = "foo".to_string(); + let y = x; + println!("{}", y); +} diff --git a/tests/ui/lifetimes/keyword-self-lifetime-error-10412.stderr b/tests/ui/lifetimes/keyword-self-lifetime-error-10412.stderr new file mode 100644 index 00000000000..236bdf1ac85 --- /dev/null +++ b/tests/ui/lifetimes/keyword-self-lifetime-error-10412.stderr @@ -0,0 +1,56 @@ +error: lifetimes cannot use keyword names + --> $DIR/keyword-self-lifetime-error-10412.rs:3:20 + | +LL | trait Serializable<'self, T> { + | ^^^^^ + +error: lifetimes cannot use keyword names + --> $DIR/keyword-self-lifetime-error-10412.rs:5:24 + | +LL | fn serialize(val: &'self T) -> Vec; + | ^^^^^ + +error: lifetimes cannot use keyword names + --> $DIR/keyword-self-lifetime-error-10412.rs:6:37 + | +LL | fn deserialize(repr: &[u8]) -> &'self T; + | ^^^^^ + +error: lifetimes cannot use keyword names + --> $DIR/keyword-self-lifetime-error-10412.rs:9:6 + | +LL | impl<'self> Serializable for &'self str { + | ^^^^^ + +error: lifetimes cannot use keyword names + --> $DIR/keyword-self-lifetime-error-10412.rs:9:36 + | +LL | impl<'self> Serializable for &'self str { + | ^^^^^ + +error: lifetimes cannot use keyword names + --> $DIR/keyword-self-lifetime-error-10412.rs:13:24 + | +LL | fn serialize(val: &'self str) -> Vec { + | ^^^^^ + +error: lifetimes cannot use keyword names + --> $DIR/keyword-self-lifetime-error-10412.rs:17:37 + | +LL | fn deserialize(repr: &[u8]) -> &'self str { + | ^^^^^ + +error[E0726]: implicit elided lifetime not allowed here + --> $DIR/keyword-self-lifetime-error-10412.rs:9:13 + | +LL | impl<'self> Serializable for &'self str { + | ^^^^^^^^^^^^^^^^^ expected lifetime parameter + | +help: indicate the anonymous lifetime + | +LL | impl<'self> Serializable<'_, str> for &'self str { + | +++ + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0726`. diff --git a/tests/ui/lifetimes/keyword-self-lifetime-error.rs b/tests/ui/lifetimes/keyword-self-lifetime-error.rs deleted file mode 100644 index 68ce0c2ea3c..00000000000 --- a/tests/ui/lifetimes/keyword-self-lifetime-error.rs +++ /dev/null @@ -1,26 +0,0 @@ -trait Serializable<'self, T> { - //~^ ERROR lifetimes cannot use keyword names - fn serialize(val: &'self T) -> Vec; //~ ERROR lifetimes cannot use keyword names - fn deserialize(repr: &[u8]) -> &'self T; //~ ERROR lifetimes cannot use keyword names -} - -impl<'self> Serializable for &'self str { - //~^ ERROR lifetimes cannot use keyword names - //~| ERROR lifetimes cannot use keyword names - //~| ERROR implicit elided lifetime not allowed here - fn serialize(val: &'self str) -> Vec { - //~^ ERROR lifetimes cannot use keyword names - vec![1] - } - fn deserialize(repr: &[u8]) -> &'self str { - //~^ ERROR lifetimes cannot use keyword names - "hi" - } -} - -fn main() { - println!("hello"); - let x = "foo".to_string(); - let y = x; - println!("{}", y); -} diff --git a/tests/ui/lifetimes/trait-lifetime-bounds.rs b/tests/ui/lifetimes/trait-lifetime-bounds.rs deleted file mode 100644 index 7cdf8808aa0..00000000000 --- a/tests/ui/lifetimes/trait-lifetime-bounds.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ check-pass -#![allow(dead_code)] - -pub mod two_tuple { - pub trait T { fn dummy(&self) { } } - pub struct P<'a>(&'a (dyn T + 'a), &'a (dyn T + 'a)); - pub fn f<'a>(car: &'a dyn T, cdr: &'a dyn T) -> P<'a> { - P(car, cdr) - } -} - -pub mod two_fields { - pub trait T { fn dummy(&self) { } } - pub struct P<'a> { car: &'a (dyn T + 'a), cdr: &'a (dyn T + 'a) } - pub fn f<'a>(car: &'a dyn T, cdr: &'a dyn T) -> P<'a> { - P{ car: car, cdr: cdr } - } -} - -fn main() {} diff --git a/tests/ui/lifetimes/tuple-struct-vs-struct-with-fields-borrowck-10902.rs b/tests/ui/lifetimes/tuple-struct-vs-struct-with-fields-borrowck-10902.rs new file mode 100644 index 00000000000..97c0d0bf554 --- /dev/null +++ b/tests/ui/lifetimes/tuple-struct-vs-struct-with-fields-borrowck-10902.rs @@ -0,0 +1,22 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10902 + +//@ check-pass +#![allow(dead_code)] + +pub mod two_tuple { + pub trait T { fn dummy(&self) { } } + pub struct P<'a>(&'a (dyn T + 'a), &'a (dyn T + 'a)); + pub fn f<'a>(car: &'a dyn T, cdr: &'a dyn T) -> P<'a> { + P(car, cdr) + } +} + +pub mod two_fields { + pub trait T { fn dummy(&self) { } } + pub struct P<'a> { car: &'a (dyn T + 'a), cdr: &'a (dyn T + 'a) } + pub fn f<'a>(car: &'a dyn T, cdr: &'a dyn T) -> P<'a> { + P{ car: car, cdr: cdr } + } +} + +fn main() {} diff --git a/tests/ui/lint/inner-doc-attributes.rs b/tests/ui/lint/inner-doc-attributes.rs deleted file mode 100644 index 4c22393d9c0..00000000000 --- a/tests/ui/lint/inner-doc-attributes.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ check-pass - -#![deny(missing_docs)] -#![doc="module"] - -#[doc="struct"] -pub struct Foo; - -pub fn foo() { - #![doc="fn"] -} - -#[doc="main"] -pub fn main() {} diff --git a/tests/ui/lint/missing-doc-unsugard-doc-attr-10853.rs b/tests/ui/lint/missing-doc-unsugard-doc-attr-10853.rs new file mode 100644 index 00000000000..ec13ae99787 --- /dev/null +++ b/tests/ui/lint/missing-doc-unsugard-doc-attr-10853.rs @@ -0,0 +1,16 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10853 + +//@ check-pass + +#![deny(missing_docs)] +#![doc="module"] + +#[doc="struct"] +pub struct Foo; + +pub fn foo() { + #![doc="fn"] +} + +#[doc="main"] +pub fn main() {} diff --git a/tests/ui/parser/comment-parsing.rs b/tests/ui/parser/comment-parsing.rs deleted file mode 100644 index c6c6939bda5..00000000000 --- a/tests/ui/parser/comment-parsing.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -pub fn main() { - //// I am not a doc comment! - ////////////////// still not a doc comment - /////**** nope, me neither */ - /*** And neither am I! */ - 5; - /*****! certainly not I */ -} diff --git a/tests/ui/parser/doc-comment-parsing.rs b/tests/ui/parser/doc-comment-parsing.rs new file mode 100644 index 00000000000..00f6b0e09a8 --- /dev/null +++ b/tests/ui/parser/doc-comment-parsing.rs @@ -0,0 +1,12 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10638 + +//@ run-pass + +pub fn main() { + //// I am not a doc comment! + ////////////////// still not a doc comment + /////**** nope, me neither */ + /*** And neither am I! */ + 5; + /*****! certainly not I */ +} diff --git a/tests/ui/pattern/ascii-lowercase-match.rs b/tests/ui/pattern/ascii-lowercase-match.rs deleted file mode 100644 index 5657ec1864b..00000000000 --- a/tests/ui/pattern/ascii-lowercase-match.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -static NAME: &'static str = "hello world"; - -fn main() { - match &*NAME.to_ascii_lowercase() { - "foo" => {} - _ => {} - } -} diff --git a/tests/ui/pattern/premature-match-scrutinee-temporary-drop-10683.rs b/tests/ui/pattern/premature-match-scrutinee-temporary-drop-10683.rs new file mode 100644 index 00000000000..a4dfa56117c --- /dev/null +++ b/tests/ui/pattern/premature-match-scrutinee-temporary-drop-10683.rs @@ -0,0 +1,12 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10683 + +//@ run-pass + +static NAME: &'static str = "hello world"; + +fn main() { + match &*NAME.to_ascii_lowercase() { + "foo" => {} + _ => {} + } +} diff --git a/tests/ui/privacy/private-struct-access-error.rs b/tests/ui/privacy/private-struct-access-error.rs deleted file mode 100644 index acd07149619..00000000000 --- a/tests/ui/privacy/private-struct-access-error.rs +++ /dev/null @@ -1,9 +0,0 @@ -mod a { - struct S; - impl S { } -} - -fn foo(_: a::S) { //~ ERROR: struct `S` is private -} - -fn main() {} diff --git a/tests/ui/privacy/struct-field-and-impl-expose-10545.rs b/tests/ui/privacy/struct-field-and-impl-expose-10545.rs new file mode 100644 index 00000000000..8a8c8240c2d --- /dev/null +++ b/tests/ui/privacy/struct-field-and-impl-expose-10545.rs @@ -0,0 +1,11 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10545 + +mod a { + struct S; + impl S { } +} + +fn foo(_: a::S) { //~ ERROR: struct `S` is private +} + +fn main() {} diff --git a/tests/ui/privacy/struct-field-and-impl-expose-10545.stderr b/tests/ui/privacy/struct-field-and-impl-expose-10545.stderr new file mode 100644 index 00000000000..ddf87d1d23a --- /dev/null +++ b/tests/ui/privacy/struct-field-and-impl-expose-10545.stderr @@ -0,0 +1,15 @@ +error[E0603]: struct `S` is private + --> $DIR/struct-field-and-impl-expose-10545.rs:8:14 + | +LL | fn foo(_: a::S) { + | ^ private struct + | +note: the struct `S` is defined here + --> $DIR/struct-field-and-impl-expose-10545.rs:4:5 + | +LL | struct S; + | ^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/structs/mutable-unit-struct-borrow-11267.rs b/tests/ui/structs/mutable-unit-struct-borrow-11267.rs new file mode 100644 index 00000000000..d96c4a4e79b --- /dev/null +++ b/tests/ui/structs/mutable-unit-struct-borrow-11267.rs @@ -0,0 +1,21 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11267 + +//@ run-pass +// Tests that unary structs can be mutably borrowed. + +struct Empty; + +trait T { + fn next(&mut self) -> Option; +} +impl T for Empty { + fn next(&mut self) -> Option { None } +} + +fn do_something_with(a : &mut dyn T) { + println!("{:?}", a.next()) +} + +pub fn main() { + do_something_with(&mut Empty); +} diff --git a/tests/ui/structs/mutable-unit-struct-borrow.rs b/tests/ui/structs/mutable-unit-struct-borrow.rs deleted file mode 100644 index 036ad1d54ed..00000000000 --- a/tests/ui/structs/mutable-unit-struct-borrow.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ run-pass -// Tests that unary structs can be mutably borrowed. - -struct Empty; - -trait T { - fn next(&mut self) -> Option; -} -impl T for Empty { - fn next(&mut self) -> Option { None } -} - -fn do_something_with(a : &mut dyn T) { - println!("{:?}", a.next()) -} - -pub fn main() { - do_something_with(&mut Empty); -} diff --git a/tests/ui/traits/blanket-impl-trait-object-10456.rs b/tests/ui/traits/blanket-impl-trait-object-10456.rs new file mode 100644 index 00000000000..f8421431774 --- /dev/null +++ b/tests/ui/traits/blanket-impl-trait-object-10456.rs @@ -0,0 +1,26 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10456 + +//@ check-pass + +pub struct Foo; + +pub trait Bar { + fn bar(&self); +} + +pub trait Baz { + fn baz(&self) { } +} + +impl Bar for T { + fn bar(&self) {} +} + +impl Baz for Foo {} + +pub fn foo(t: Box) { + t.bar(); // ~Foo doesn't implement Baz + (*t).bar(); // ok b/c Foo implements Baz +} + +fn main() {} diff --git a/tests/ui/traits/blanket-impl-trait-object.rs b/tests/ui/traits/blanket-impl-trait-object.rs deleted file mode 100644 index 51c740fd729..00000000000 --- a/tests/ui/traits/blanket-impl-trait-object.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ check-pass - -pub struct Foo; - -pub trait Bar { - fn bar(&self); -} - -pub trait Baz { - fn baz(&self) { } -} - -impl Bar for T { - fn bar(&self) {} -} - -impl Baz for Foo {} - -pub fn foo(t: Box) { - t.bar(); // ~Foo doesn't implement Baz - (*t).bar(); // ok b/c Foo implements Baz -} - -fn main() {} diff --git a/tests/ui/traits/missing-trait-method-error.rs b/tests/ui/traits/missing-trait-method-error.rs deleted file mode 100644 index d899c3ffa91..00000000000 --- a/tests/ui/traits/missing-trait-method-error.rs +++ /dev/null @@ -1,23 +0,0 @@ -pub mod a { - pub trait A { - fn foo(&self); - } - -} -pub mod b { - use a::A; - - pub struct B; - impl A for B { fn foo(&self) {} } - - pub mod c { - use b::B; - - fn foo(b: &B) { - b.foo(); //~ ERROR: no method named `foo` found - } - } - -} - -fn main() {} diff --git a/tests/ui/traits/negative-positive-impl-conflict.rs b/tests/ui/traits/negative-positive-impl-conflict.rs deleted file mode 100644 index d7e7122ebda..00000000000 --- a/tests/ui/traits/negative-positive-impl-conflict.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ compile-flags:-Ztranslate-lang=en_US - -#![feature(negative_impls)] -#![feature(marker_trait_attr)] - -#[marker] -trait MyTrait {} - -struct TestType(::std::marker::PhantomData); - -unsafe impl Send for TestType {} - -impl !Send for TestType {} -//~^ ERROR found both positive and negative implementation -//~| ERROR `!Send` impl requires `T: MyTrait` but the struct it is implemented for does not - -unsafe impl Send for TestType {} //~ ERROR conflicting implementations - -impl !Send for TestType {} -//~^ ERROR `!Send` impls cannot be specialized - -fn main() {} diff --git a/tests/ui/traits/nested-mod-trait-method-lookup-leak-10465.rs b/tests/ui/traits/nested-mod-trait-method-lookup-leak-10465.rs new file mode 100644 index 00000000000..d5a500900ff --- /dev/null +++ b/tests/ui/traits/nested-mod-trait-method-lookup-leak-10465.rs @@ -0,0 +1,25 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/10465 + +pub mod a { + pub trait A { + fn foo(&self); + } + +} +pub mod b { + use a::A; + + pub struct B; + impl A for B { fn foo(&self) {} } + + pub mod c { + use b::B; + + fn foo(b: &B) { + b.foo(); //~ ERROR: no method named `foo` found + } + } + +} + +fn main() {} diff --git a/tests/ui/traits/nested-mod-trait-method-lookup-leak-10465.stderr b/tests/ui/traits/nested-mod-trait-method-lookup-leak-10465.stderr new file mode 100644 index 00000000000..ffd8fd39250 --- /dev/null +++ b/tests/ui/traits/nested-mod-trait-method-lookup-leak-10465.stderr @@ -0,0 +1,15 @@ +error[E0599]: no method named `foo` found for reference `&B` in the current scope + --> $DIR/nested-mod-trait-method-lookup-leak-10465.rs:19:15 + | +LL | b.foo(); + | ^^^ method not found in `&B` + | + = help: items from traits can only be used if the trait is in scope +help: trait `A` which provides `foo` is implemented but not in scope; perhaps you want to import it + | +LL + use a::A; + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/type-alias/dummy-binder-102964.rs b/tests/ui/type-alias/dummy-binder-102964.rs new file mode 100644 index 00000000000..6b6fa3ed5e3 --- /dev/null +++ b/tests/ui/type-alias/dummy-binder-102964.rs @@ -0,0 +1,12 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/102964 + +use std::rc::Rc; +type Foo<'a, T> = &'a dyn Fn(&T); +type RcFoo<'a, T> = Rc>; + +fn bar_function(function: Foo) -> RcFoo { + //~^ ERROR mismatched types + let rc = Rc::new(function); +} + +fn main() {} diff --git a/tests/ui/type-alias/dummy-binder-102964.stderr b/tests/ui/type-alias/dummy-binder-102964.stderr new file mode 100644 index 00000000000..fc32cabaf71 --- /dev/null +++ b/tests/ui/type-alias/dummy-binder-102964.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/dummy-binder-102964.rs:7:41 + | +LL | fn bar_function(function: Foo) -> RcFoo { + | ------------ ^^^^^^^^ expected `Rc<&dyn Fn(&T)>`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + | + = note: expected struct `Rc<&dyn for<'a> Fn(&'a T)>` + found unit type `()` +help: consider returning the local binding `rc` + | +LL ~ let rc = Rc::new(function); +LL + rc + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type-alias/mismatched-rc-foo-types.rs b/tests/ui/type-alias/mismatched-rc-foo-types.rs deleted file mode 100644 index 43ff2360076..00000000000 --- a/tests/ui/type-alias/mismatched-rc-foo-types.rs +++ /dev/null @@ -1,10 +0,0 @@ -use std::rc::Rc; -type Foo<'a, T> = &'a dyn Fn(&T); -type RcFoo<'a, T> = Rc>; - -fn bar_function(function: Foo) -> RcFoo { - //~^ ERROR mismatched types - let rc = Rc::new(function); -} - -fn main() {} diff --git a/tests/ui/type-alias/static-method-type-alias-11047.rs b/tests/ui/type-alias/static-method-type-alias-11047.rs new file mode 100644 index 00000000000..efb336fb4f7 --- /dev/null +++ b/tests/ui/type-alias/static-method-type-alias-11047.rs @@ -0,0 +1,28 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11047 + +//@ run-pass +// Test that static methods can be invoked on `type` aliases + +#![allow(unused_variables)] + +pub mod foo { + pub mod bar { + pub mod baz { + pub struct Qux; + + impl Qux { + pub fn new() {} + } + } + } +} + +fn main() { + + type Ham = foo::bar::baz::Qux; + let foo: () = foo::bar::baz::Qux::new(); // invoke directly + let bar: () = Ham::new(); // invoke via type alias + + type StringVec = Vec; + let sv = StringVec::new(); +} diff --git a/tests/ui/type-alias/static-method-type-alias.rs b/tests/ui/type-alias/static-method-type-alias.rs deleted file mode 100644 index 6e1b2856afc..00000000000 --- a/tests/ui/type-alias/static-method-type-alias.rs +++ /dev/null @@ -1,26 +0,0 @@ -//@ run-pass -// Test that static methods can be invoked on `type` aliases - -#![allow(unused_variables)] - -pub mod foo { - pub mod bar { - pub mod baz { - pub struct Qux; - - impl Qux { - pub fn new() {} - } - } - } -} - -fn main() { - - type Ham = foo::bar::baz::Qux; - let foo: () = foo::bar::baz::Qux::new(); // invoke directly - let bar: () = Ham::new(); // invoke via type alias - - type StringVec = Vec; - let sv = StringVec::new(); -} diff --git a/tests/ui/unsafe/raw-pointer-field-access-error.rs b/tests/ui/unsafe/raw-pointer-field-access-error.rs index 0c34554c12d..04b45b2d3c6 100644 --- a/tests/ui/unsafe/raw-pointer-field-access-error.rs +++ b/tests/ui/unsafe/raw-pointer-field-access-error.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11004 + use std::mem; struct A { x: i32, y: f64 } diff --git a/tests/ui/unsafe/raw-pointer-field-access-error.stderr b/tests/ui/unsafe/raw-pointer-field-access-error.stderr new file mode 100644 index 00000000000..e9a205a5fa6 --- /dev/null +++ b/tests/ui/unsafe/raw-pointer-field-access-error.stderr @@ -0,0 +1,25 @@ +error[E0609]: no field `x` on type `*mut A` + --> $DIR/raw-pointer-field-access-error.rs:9:21 + | +LL | let x : i32 = n.x; + | ^ unknown field + | +help: `n` is a raw pointer; try dereferencing it + | +LL | let x : i32 = (*n).x; + | ++ + + +error[E0609]: no field `y` on type `*mut A` + --> $DIR/raw-pointer-field-access-error.rs:10:21 + | +LL | let y : f64 = n.y; + | ^ unknown field + | +help: `n` is a raw pointer; try dereferencing it + | +LL | let y : f64 = (*n).y; + | ++ + + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0609`. -- cgit 1.4.1-3-g733a5