From 4feb5de34c1e41da0c10e149e243a25a6eafcd17 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Mon, 30 Jun 2025 00:03:28 +0500 Subject: moved tests --- tests/ui/auxiliary/noexporttypelib.rs | 2 - tests/ui/cast/non-primitive-cast-suggestion.fixed | 16 ++++++++ tests/ui/cast/non-primitive-cast-suggestion.rs | 16 ++++++++ tests/ui/cast/non-primitive-cast-suggestion.stderr | 15 +++++++ .../closure-clone-requires-captured-clone.rs | 13 ++++++ .../closure-clone-requires-captured-clone.stderr | 23 +++++++++++ tests/ui/consts/array-repeat-expr-not-const.rs | 8 ++++ tests/ui/consts/array-repeat-expr-not-const.stderr | 11 ++++++ tests/ui/cross-crate/auxiliary/noexporttypelib.rs | 2 + .../cross-crate/unexported-type-error-message.rs | 16 ++++++++ .../unexported-type-error-message.stderr | 18 +++++++++ tests/ui/drop/field-replace-in-struct-with-drop.rs | 46 ++++++++++++++++++++++ tests/ui/no-core-1.rs | 15 ------- tests/ui/no-core-2.rs | 20 ---------- tests/ui/no-send-res-ports.rs | 30 -------------- tests/ui/no-send-res-ports.stderr | 37 ----------------- tests/ui/no-warn-on-field-replace-issue-34101.rs | 46 ---------------------- tests/ui/no_std/no-core-edition2018-syntax.rs | 20 ++++++++++ tests/ui/no_std/no-core-with-explicit-std-core.rs | 15 +++++++ tests/ui/noexporttypeexe.rs | 16 -------- tests/ui/noexporttypeexe.stderr | 18 --------- tests/ui/non-constant-expr-for-arr-len.rs | 8 ---- tests/ui/non-constant-expr-for-arr-len.stderr | 11 ------ tests/ui/nonscalar-cast.fixed | 16 -------- tests/ui/nonscalar-cast.rs | 16 -------- tests/ui/nonscalar-cast.stderr | 15 ------- tests/ui/not-clone-closure.rs | 13 ------ tests/ui/not-clone-closure.stderr | 23 ----------- tests/ui/threads-sendsync/rc-is-not-send.rs | 30 ++++++++++++++ tests/ui/threads-sendsync/rc-is-not-send.stderr | 37 +++++++++++++++++ 30 files changed, 286 insertions(+), 286 deletions(-) delete mode 100644 tests/ui/auxiliary/noexporttypelib.rs create mode 100644 tests/ui/cast/non-primitive-cast-suggestion.fixed create mode 100644 tests/ui/cast/non-primitive-cast-suggestion.rs create mode 100644 tests/ui/cast/non-primitive-cast-suggestion.stderr create mode 100644 tests/ui/closures/closure-clone-requires-captured-clone.rs create mode 100644 tests/ui/closures/closure-clone-requires-captured-clone.stderr create mode 100644 tests/ui/consts/array-repeat-expr-not-const.rs create mode 100644 tests/ui/consts/array-repeat-expr-not-const.stderr create mode 100644 tests/ui/cross-crate/auxiliary/noexporttypelib.rs create mode 100644 tests/ui/cross-crate/unexported-type-error-message.rs create mode 100644 tests/ui/cross-crate/unexported-type-error-message.stderr create mode 100644 tests/ui/drop/field-replace-in-struct-with-drop.rs delete mode 100644 tests/ui/no-core-1.rs delete mode 100644 tests/ui/no-core-2.rs delete mode 100644 tests/ui/no-send-res-ports.rs delete mode 100644 tests/ui/no-send-res-ports.stderr delete mode 100644 tests/ui/no-warn-on-field-replace-issue-34101.rs create mode 100644 tests/ui/no_std/no-core-edition2018-syntax.rs create mode 100644 tests/ui/no_std/no-core-with-explicit-std-core.rs delete mode 100644 tests/ui/noexporttypeexe.rs delete mode 100644 tests/ui/noexporttypeexe.stderr delete mode 100644 tests/ui/non-constant-expr-for-arr-len.rs delete mode 100644 tests/ui/non-constant-expr-for-arr-len.stderr delete mode 100644 tests/ui/nonscalar-cast.fixed delete mode 100644 tests/ui/nonscalar-cast.rs delete mode 100644 tests/ui/nonscalar-cast.stderr delete mode 100644 tests/ui/not-clone-closure.rs delete mode 100644 tests/ui/not-clone-closure.stderr create mode 100644 tests/ui/threads-sendsync/rc-is-not-send.rs create mode 100644 tests/ui/threads-sendsync/rc-is-not-send.stderr diff --git a/tests/ui/auxiliary/noexporttypelib.rs b/tests/ui/auxiliary/noexporttypelib.rs deleted file mode 100644 index 67889cc5f65..00000000000 --- a/tests/ui/auxiliary/noexporttypelib.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub type oint = Option; -pub fn foo() -> oint { Some(3) } diff --git a/tests/ui/cast/non-primitive-cast-suggestion.fixed b/tests/ui/cast/non-primitive-cast-suggestion.fixed new file mode 100644 index 00000000000..cb5591dbb9d --- /dev/null +++ b/tests/ui/cast/non-primitive-cast-suggestion.fixed @@ -0,0 +1,16 @@ +//@ run-rustfix + +#[derive(Debug)] +struct Foo { + x: isize +} + +impl From for isize { + fn from(val: Foo) -> isize { + val.x + } +} + +fn main() { + println!("{}", isize::from(Foo { x: 1 })); //~ ERROR non-primitive cast: `Foo` as `isize` [E0605] +} diff --git a/tests/ui/cast/non-primitive-cast-suggestion.rs b/tests/ui/cast/non-primitive-cast-suggestion.rs new file mode 100644 index 00000000000..27429b44cd0 --- /dev/null +++ b/tests/ui/cast/non-primitive-cast-suggestion.rs @@ -0,0 +1,16 @@ +//@ run-rustfix + +#[derive(Debug)] +struct Foo { + x: isize +} + +impl From for isize { + fn from(val: Foo) -> isize { + val.x + } +} + +fn main() { + println!("{}", Foo { x: 1 } as isize); //~ ERROR non-primitive cast: `Foo` as `isize` [E0605] +} diff --git a/tests/ui/cast/non-primitive-cast-suggestion.stderr b/tests/ui/cast/non-primitive-cast-suggestion.stderr new file mode 100644 index 00000000000..834d4ea241c --- /dev/null +++ b/tests/ui/cast/non-primitive-cast-suggestion.stderr @@ -0,0 +1,15 @@ +error[E0605]: non-primitive cast: `Foo` as `isize` + --> $DIR/nonscalar-cast.rs:15:20 + | +LL | println!("{}", Foo { x: 1 } as isize); + | ^^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object + | +help: consider using the `From` trait instead + | +LL - println!("{}", Foo { x: 1 } as isize); +LL + println!("{}", isize::from(Foo { x: 1 })); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0605`. diff --git a/tests/ui/closures/closure-clone-requires-captured-clone.rs b/tests/ui/closures/closure-clone-requires-captured-clone.rs new file mode 100644 index 00000000000..976e3b9e81c --- /dev/null +++ b/tests/ui/closures/closure-clone-requires-captured-clone.rs @@ -0,0 +1,13 @@ +//@compile-flags: --diagnostic-width=300 +// Check that closures do not implement `Clone` if their environment is not `Clone`. + +struct S(i32); + +fn main() { + let a = S(5); + let hello = move || { + println!("Hello {}", a.0); + }; + + let hello = hello.clone(); //~ ERROR the trait bound `S: Clone` is not satisfied +} diff --git a/tests/ui/closures/closure-clone-requires-captured-clone.stderr b/tests/ui/closures/closure-clone-requires-captured-clone.stderr new file mode 100644 index 00000000000..0c95a99d0c0 --- /dev/null +++ b/tests/ui/closures/closure-clone-requires-captured-clone.stderr @@ -0,0 +1,23 @@ +error[E0277]: the trait bound `S: Clone` is not satisfied in `{closure@$DIR/not-clone-closure.rs:8:17: 8:24}` + --> $DIR/not-clone-closure.rs:12:23 + | +LL | let hello = move || { + | ------- within this `{closure@$DIR/not-clone-closure.rs:8:17: 8:24}` +... +LL | let hello = hello.clone(); + | ^^^^^ within `{closure@$DIR/not-clone-closure.rs:8:17: 8:24}`, the trait `Clone` is not implemented for `S` + | +note: required because it's used within this closure + --> $DIR/not-clone-closure.rs:8:17 + | +LL | let hello = move || { + | ^^^^^^^ +help: consider annotating `S` with `#[derive(Clone)]` + | +LL + #[derive(Clone)] +LL | struct S(i32); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/consts/array-repeat-expr-not-const.rs b/tests/ui/consts/array-repeat-expr-not-const.rs new file mode 100644 index 00000000000..1b101d3233f --- /dev/null +++ b/tests/ui/consts/array-repeat-expr-not-const.rs @@ -0,0 +1,8 @@ +// Check that non constant exprs fail for array repeat syntax + +fn main() { + fn bar(n: usize) { + let _x = [0; n]; + //~^ ERROR attempt to use a non-constant value in a constant [E0435] + } +} diff --git a/tests/ui/consts/array-repeat-expr-not-const.stderr b/tests/ui/consts/array-repeat-expr-not-const.stderr new file mode 100644 index 00000000000..c9f977fbaa4 --- /dev/null +++ b/tests/ui/consts/array-repeat-expr-not-const.stderr @@ -0,0 +1,11 @@ +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/non-constant-expr-for-arr-len.rs:5:22 + | +LL | fn bar(n: usize) { + | - this would need to be a `const` +LL | let _x = [0; n]; + | ^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0435`. diff --git a/tests/ui/cross-crate/auxiliary/noexporttypelib.rs b/tests/ui/cross-crate/auxiliary/noexporttypelib.rs new file mode 100644 index 00000000000..67889cc5f65 --- /dev/null +++ b/tests/ui/cross-crate/auxiliary/noexporttypelib.rs @@ -0,0 +1,2 @@ +pub type oint = Option; +pub fn foo() -> oint { Some(3) } diff --git a/tests/ui/cross-crate/unexported-type-error-message.rs b/tests/ui/cross-crate/unexported-type-error-message.rs new file mode 100644 index 00000000000..35257b20ccd --- /dev/null +++ b/tests/ui/cross-crate/unexported-type-error-message.rs @@ -0,0 +1,16 @@ +//@ aux-build:noexporttypelib.rs + +extern crate noexporttypelib; + +fn main() { + // Here, the type returned by foo() is not exported. + // This used to cause internal errors when serializing + // because the def_id associated with the type was + // not convertible to a path. + let x: isize = noexporttypelib::foo(); + //~^ ERROR mismatched types + //~| NOTE expected type `isize` + //~| NOTE found enum `Option` + //~| NOTE expected `isize`, found `Option` + //~| NOTE expected due to this +} diff --git a/tests/ui/cross-crate/unexported-type-error-message.stderr b/tests/ui/cross-crate/unexported-type-error-message.stderr new file mode 100644 index 00000000000..59759b696c7 --- /dev/null +++ b/tests/ui/cross-crate/unexported-type-error-message.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/noexporttypeexe.rs:10:18 + | +LL | let x: isize = noexporttypelib::foo(); + | ----- ^^^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `Option` + | | + | expected due to this + | + = note: expected type `isize` + found enum `Option` +help: consider using `Option::expect` to unwrap the `Option` value, panicking if the value is an `Option::None` + | +LL | let x: isize = noexporttypelib::foo().expect("REASON"); + | +++++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/drop/field-replace-in-struct-with-drop.rs b/tests/ui/drop/field-replace-in-struct-with-drop.rs new file mode 100644 index 00000000000..e1d5e9c5268 --- /dev/null +++ b/tests/ui/drop/field-replace-in-struct-with-drop.rs @@ -0,0 +1,46 @@ +// Issue 34101: Circa 2016-06-05, `fn inline` below issued an +// erroneous warning from the elaborate_drops pass about moving out of +// a field in `Foo`, which has a destructor (and thus cannot have +// content moved out of it). The reason that the warning is erroneous +// in this case is that we are doing a *replace*, not a move, of the +// content in question, and it is okay to replace fields within `Foo`. +// +// Another more subtle problem was that the elaborate_drops was +// creating a separate drop flag for that internally replaced content, +// even though the compiler should enforce an invariant that any drop +// flag for such subcontent of `Foo` will always have the same value +// as the drop flag for `Foo` itself. + + + + + + + + +//@ check-pass + +struct Foo(String); + +impl Drop for Foo { + fn drop(&mut self) {} +} + +fn inline() { + // (dummy variable so `f` gets assigned `var1` in MIR for both fn's) + let _s = (); + let mut f = Foo(String::from("foo")); + f.0 = String::from("bar"); +} + +fn outline() { + let _s = String::from("foo"); + let mut f = Foo(_s); + f.0 = String::from("bar"); +} + + +fn main() { + inline(); + outline(); +} diff --git a/tests/ui/no-core-1.rs b/tests/ui/no-core-1.rs deleted file mode 100644 index d6d2ba60445..00000000000 --- a/tests/ui/no-core-1.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ run-pass - -#![allow(stable_features)] -#![feature(no_core, core)] -#![no_core] - -extern crate std; -extern crate core; - -use std::option::Option::Some; - -fn main() { - let a = Some("foo"); - a.unwrap(); -} diff --git a/tests/ui/no-core-2.rs b/tests/ui/no-core-2.rs deleted file mode 100644 index 2f55365bdd0..00000000000 --- a/tests/ui/no-core-2.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ run-pass - -#![allow(dead_code, unused_imports)] -#![feature(no_core)] -#![no_core] -//@ edition:2018 - -extern crate std; -extern crate core; -use core::{prelude::v1::*, *}; - -fn foo() { - for _ in &[()] {} -} - -fn bar() -> Option<()> { - None? -} - -fn main() {} diff --git a/tests/ui/no-send-res-ports.rs b/tests/ui/no-send-res-ports.rs deleted file mode 100644 index 1bac5868e73..00000000000 --- a/tests/ui/no-send-res-ports.rs +++ /dev/null @@ -1,30 +0,0 @@ -use std::thread; -use std::rc::Rc; - -#[derive(Debug)] -struct Port(Rc); - -fn main() { - #[derive(Debug)] - struct Foo { - _x: Port<()>, - } - - impl Drop for Foo { - fn drop(&mut self) {} - } - - fn foo(x: Port<()>) -> Foo { - Foo { - _x: x - } - } - - let x = foo(Port(Rc::new(()))); - - thread::spawn(move|| { - //~^ ERROR `Rc<()>` cannot be sent between threads safely - let y = x; - println!("{:?}", y); - }); -} diff --git a/tests/ui/no-send-res-ports.stderr b/tests/ui/no-send-res-ports.stderr deleted file mode 100644 index 9c30261e5cb..00000000000 --- a/tests/ui/no-send-res-ports.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0277]: `Rc<()>` cannot be sent between threads safely - --> $DIR/no-send-res-ports.rs:25:19 - | -LL | thread::spawn(move|| { - | ------------- ^----- - | | | - | _____|_____________within this `{closure@$DIR/no-send-res-ports.rs:25:19: 25:25}` - | | | - | | required by a bound introduced by this call -LL | | -LL | | let y = x; -LL | | println!("{:?}", y); -LL | | }); - | |_____^ `Rc<()>` cannot be sent between threads safely - | - = help: within `{closure@$DIR/no-send-res-ports.rs:25:19: 25:25}`, the trait `Send` is not implemented for `Rc<()>` -note: required because it appears within the type `Port<()>` - --> $DIR/no-send-res-ports.rs:5:8 - | -LL | struct Port(Rc); - | ^^^^ -note: required because it appears within the type `Foo` - --> $DIR/no-send-res-ports.rs:9:12 - | -LL | struct Foo { - | ^^^ -note: required because it's used within this closure - --> $DIR/no-send-res-ports.rs:25:19 - | -LL | thread::spawn(move|| { - | ^^^^^^ -note: required by a bound in `spawn` - --> $SRC_DIR/std/src/thread/mod.rs:LL:COL - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/no-warn-on-field-replace-issue-34101.rs b/tests/ui/no-warn-on-field-replace-issue-34101.rs deleted file mode 100644 index e1d5e9c5268..00000000000 --- a/tests/ui/no-warn-on-field-replace-issue-34101.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Issue 34101: Circa 2016-06-05, `fn inline` below issued an -// erroneous warning from the elaborate_drops pass about moving out of -// a field in `Foo`, which has a destructor (and thus cannot have -// content moved out of it). The reason that the warning is erroneous -// in this case is that we are doing a *replace*, not a move, of the -// content in question, and it is okay to replace fields within `Foo`. -// -// Another more subtle problem was that the elaborate_drops was -// creating a separate drop flag for that internally replaced content, -// even though the compiler should enforce an invariant that any drop -// flag for such subcontent of `Foo` will always have the same value -// as the drop flag for `Foo` itself. - - - - - - - - -//@ check-pass - -struct Foo(String); - -impl Drop for Foo { - fn drop(&mut self) {} -} - -fn inline() { - // (dummy variable so `f` gets assigned `var1` in MIR for both fn's) - let _s = (); - let mut f = Foo(String::from("foo")); - f.0 = String::from("bar"); -} - -fn outline() { - let _s = String::from("foo"); - let mut f = Foo(_s); - f.0 = String::from("bar"); -} - - -fn main() { - inline(); - outline(); -} diff --git a/tests/ui/no_std/no-core-edition2018-syntax.rs b/tests/ui/no_std/no-core-edition2018-syntax.rs new file mode 100644 index 00000000000..2f55365bdd0 --- /dev/null +++ b/tests/ui/no_std/no-core-edition2018-syntax.rs @@ -0,0 +1,20 @@ +//@ run-pass + +#![allow(dead_code, unused_imports)] +#![feature(no_core)] +#![no_core] +//@ edition:2018 + +extern crate std; +extern crate core; +use core::{prelude::v1::*, *}; + +fn foo() { + for _ in &[()] {} +} + +fn bar() -> Option<()> { + None? +} + +fn main() {} diff --git a/tests/ui/no_std/no-core-with-explicit-std-core.rs b/tests/ui/no_std/no-core-with-explicit-std-core.rs new file mode 100644 index 00000000000..d6d2ba60445 --- /dev/null +++ b/tests/ui/no_std/no-core-with-explicit-std-core.rs @@ -0,0 +1,15 @@ +//@ run-pass + +#![allow(stable_features)] +#![feature(no_core, core)] +#![no_core] + +extern crate std; +extern crate core; + +use std::option::Option::Some; + +fn main() { + let a = Some("foo"); + a.unwrap(); +} diff --git a/tests/ui/noexporttypeexe.rs b/tests/ui/noexporttypeexe.rs deleted file mode 100644 index 35257b20ccd..00000000000 --- a/tests/ui/noexporttypeexe.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ aux-build:noexporttypelib.rs - -extern crate noexporttypelib; - -fn main() { - // Here, the type returned by foo() is not exported. - // This used to cause internal errors when serializing - // because the def_id associated with the type was - // not convertible to a path. - let x: isize = noexporttypelib::foo(); - //~^ ERROR mismatched types - //~| NOTE expected type `isize` - //~| NOTE found enum `Option` - //~| NOTE expected `isize`, found `Option` - //~| NOTE expected due to this -} diff --git a/tests/ui/noexporttypeexe.stderr b/tests/ui/noexporttypeexe.stderr deleted file mode 100644 index 59759b696c7..00000000000 --- a/tests/ui/noexporttypeexe.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/noexporttypeexe.rs:10:18 - | -LL | let x: isize = noexporttypelib::foo(); - | ----- ^^^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `Option` - | | - | expected due to this - | - = note: expected type `isize` - found enum `Option` -help: consider using `Option::expect` to unwrap the `Option` value, panicking if the value is an `Option::None` - | -LL | let x: isize = noexporttypelib::foo().expect("REASON"); - | +++++++++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/non-constant-expr-for-arr-len.rs b/tests/ui/non-constant-expr-for-arr-len.rs deleted file mode 100644 index 1b101d3233f..00000000000 --- a/tests/ui/non-constant-expr-for-arr-len.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Check that non constant exprs fail for array repeat syntax - -fn main() { - fn bar(n: usize) { - let _x = [0; n]; - //~^ ERROR attempt to use a non-constant value in a constant [E0435] - } -} diff --git a/tests/ui/non-constant-expr-for-arr-len.stderr b/tests/ui/non-constant-expr-for-arr-len.stderr deleted file mode 100644 index c9f977fbaa4..00000000000 --- a/tests/ui/non-constant-expr-for-arr-len.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/non-constant-expr-for-arr-len.rs:5:22 - | -LL | fn bar(n: usize) { - | - this would need to be a `const` -LL | let _x = [0; n]; - | ^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0435`. diff --git a/tests/ui/nonscalar-cast.fixed b/tests/ui/nonscalar-cast.fixed deleted file mode 100644 index cb5591dbb9d..00000000000 --- a/tests/ui/nonscalar-cast.fixed +++ /dev/null @@ -1,16 +0,0 @@ -//@ run-rustfix - -#[derive(Debug)] -struct Foo { - x: isize -} - -impl From for isize { - fn from(val: Foo) -> isize { - val.x - } -} - -fn main() { - println!("{}", isize::from(Foo { x: 1 })); //~ ERROR non-primitive cast: `Foo` as `isize` [E0605] -} diff --git a/tests/ui/nonscalar-cast.rs b/tests/ui/nonscalar-cast.rs deleted file mode 100644 index 27429b44cd0..00000000000 --- a/tests/ui/nonscalar-cast.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ run-rustfix - -#[derive(Debug)] -struct Foo { - x: isize -} - -impl From for isize { - fn from(val: Foo) -> isize { - val.x - } -} - -fn main() { - println!("{}", Foo { x: 1 } as isize); //~ ERROR non-primitive cast: `Foo` as `isize` [E0605] -} diff --git a/tests/ui/nonscalar-cast.stderr b/tests/ui/nonscalar-cast.stderr deleted file mode 100644 index 834d4ea241c..00000000000 --- a/tests/ui/nonscalar-cast.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0605]: non-primitive cast: `Foo` as `isize` - --> $DIR/nonscalar-cast.rs:15:20 - | -LL | println!("{}", Foo { x: 1 } as isize); - | ^^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object - | -help: consider using the `From` trait instead - | -LL - println!("{}", Foo { x: 1 } as isize); -LL + println!("{}", isize::from(Foo { x: 1 })); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0605`. diff --git a/tests/ui/not-clone-closure.rs b/tests/ui/not-clone-closure.rs deleted file mode 100644 index 976e3b9e81c..00000000000 --- a/tests/ui/not-clone-closure.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@compile-flags: --diagnostic-width=300 -// Check that closures do not implement `Clone` if their environment is not `Clone`. - -struct S(i32); - -fn main() { - let a = S(5); - let hello = move || { - println!("Hello {}", a.0); - }; - - let hello = hello.clone(); //~ ERROR the trait bound `S: Clone` is not satisfied -} diff --git a/tests/ui/not-clone-closure.stderr b/tests/ui/not-clone-closure.stderr deleted file mode 100644 index 0c95a99d0c0..00000000000 --- a/tests/ui/not-clone-closure.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0277]: the trait bound `S: Clone` is not satisfied in `{closure@$DIR/not-clone-closure.rs:8:17: 8:24}` - --> $DIR/not-clone-closure.rs:12:23 - | -LL | let hello = move || { - | ------- within this `{closure@$DIR/not-clone-closure.rs:8:17: 8:24}` -... -LL | let hello = hello.clone(); - | ^^^^^ within `{closure@$DIR/not-clone-closure.rs:8:17: 8:24}`, the trait `Clone` is not implemented for `S` - | -note: required because it's used within this closure - --> $DIR/not-clone-closure.rs:8:17 - | -LL | let hello = move || { - | ^^^^^^^ -help: consider annotating `S` with `#[derive(Clone)]` - | -LL + #[derive(Clone)] -LL | struct S(i32); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/threads-sendsync/rc-is-not-send.rs b/tests/ui/threads-sendsync/rc-is-not-send.rs new file mode 100644 index 00000000000..1bac5868e73 --- /dev/null +++ b/tests/ui/threads-sendsync/rc-is-not-send.rs @@ -0,0 +1,30 @@ +use std::thread; +use std::rc::Rc; + +#[derive(Debug)] +struct Port(Rc); + +fn main() { + #[derive(Debug)] + struct Foo { + _x: Port<()>, + } + + impl Drop for Foo { + fn drop(&mut self) {} + } + + fn foo(x: Port<()>) -> Foo { + Foo { + _x: x + } + } + + let x = foo(Port(Rc::new(()))); + + thread::spawn(move|| { + //~^ ERROR `Rc<()>` cannot be sent between threads safely + let y = x; + println!("{:?}", y); + }); +} diff --git a/tests/ui/threads-sendsync/rc-is-not-send.stderr b/tests/ui/threads-sendsync/rc-is-not-send.stderr new file mode 100644 index 00000000000..9c30261e5cb --- /dev/null +++ b/tests/ui/threads-sendsync/rc-is-not-send.stderr @@ -0,0 +1,37 @@ +error[E0277]: `Rc<()>` cannot be sent between threads safely + --> $DIR/no-send-res-ports.rs:25:19 + | +LL | thread::spawn(move|| { + | ------------- ^----- + | | | + | _____|_____________within this `{closure@$DIR/no-send-res-ports.rs:25:19: 25:25}` + | | | + | | required by a bound introduced by this call +LL | | +LL | | let y = x; +LL | | println!("{:?}", y); +LL | | }); + | |_____^ `Rc<()>` cannot be sent between threads safely + | + = help: within `{closure@$DIR/no-send-res-ports.rs:25:19: 25:25}`, the trait `Send` is not implemented for `Rc<()>` +note: required because it appears within the type `Port<()>` + --> $DIR/no-send-res-ports.rs:5:8 + | +LL | struct Port(Rc); + | ^^^^ +note: required because it appears within the type `Foo` + --> $DIR/no-send-res-ports.rs:9:12 + | +LL | struct Foo { + | ^^^ +note: required because it's used within this closure + --> $DIR/no-send-res-ports.rs:25:19 + | +LL | thread::spawn(move|| { + | ^^^^^^ +note: required by a bound in `spawn` + --> $SRC_DIR/std/src/thread/mod.rs:LL:COL + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. -- cgit 1.4.1-3-g733a5