diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
commit | c23a457e72abe608715ac76f076f47dc42af07a5 (patch) | |
tree | 2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /tests/ui/traits/suggest-deferences | |
parent | Releasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip |
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/traits/suggest-deferences')
17 files changed, 0 insertions, 361 deletions
diff --git a/tests/ui/traits/suggest-deferences/issue-39029.fixed b/tests/ui/traits/suggest-deferences/issue-39029.fixed deleted file mode 100644 index a1abf668b..000000000 --- a/tests/ui/traits/suggest-deferences/issue-39029.fixed +++ /dev/null @@ -1,18 +0,0 @@ -// run-rustfix -use std::net::TcpListener; - -struct NoToSocketAddrs(String); - -impl std::ops::Deref for NoToSocketAddrs { - type Target = String; - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -fn main() { - let _works = TcpListener::bind("some string"); - let bad = NoToSocketAddrs("bad".to_owned()); - let _errors = TcpListener::bind(&*bad); - //~^ ERROR the trait bound `NoToSocketAddrs: ToSocketAddrs` is not satisfied -} diff --git a/tests/ui/traits/suggest-deferences/issue-39029.rs b/tests/ui/traits/suggest-deferences/issue-39029.rs deleted file mode 100644 index 90d097105..000000000 --- a/tests/ui/traits/suggest-deferences/issue-39029.rs +++ /dev/null @@ -1,18 +0,0 @@ -// run-rustfix -use std::net::TcpListener; - -struct NoToSocketAddrs(String); - -impl std::ops::Deref for NoToSocketAddrs { - type Target = String; - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -fn main() { - let _works = TcpListener::bind("some string"); - let bad = NoToSocketAddrs("bad".to_owned()); - let _errors = TcpListener::bind(&bad); - //~^ ERROR the trait bound `NoToSocketAddrs: ToSocketAddrs` is not satisfied -} diff --git a/tests/ui/traits/suggest-deferences/issue-39029.stderr b/tests/ui/traits/suggest-deferences/issue-39029.stderr deleted file mode 100644 index 49105de3d..000000000 --- a/tests/ui/traits/suggest-deferences/issue-39029.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0277]: the trait bound `NoToSocketAddrs: ToSocketAddrs` is not satisfied - --> $DIR/issue-39029.rs:16:38 - | -LL | let _errors = TcpListener::bind(&bad); - | ----------------- ^^^ the trait `ToSocketAddrs` is not implemented for `NoToSocketAddrs` - | | - | required by a bound introduced by this call - | - = note: required for `&NoToSocketAddrs` to implement `ToSocketAddrs` -note: required by a bound in `TcpListener::bind` - --> $SRC_DIR/std/src/net/tcp.rs:LL:COL -help: consider dereferencing here - | -LL | let _errors = TcpListener::bind(&*bad); - | + - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/suggest-deferences/issue-62530.fixed b/tests/ui/traits/suggest-deferences/issue-62530.fixed deleted file mode 100644 index 406caaa00..000000000 --- a/tests/ui/traits/suggest-deferences/issue-62530.fixed +++ /dev/null @@ -1,15 +0,0 @@ -// run-rustfix -fn takes_str(_x: &str) {} - -fn takes_type_parameter<T>(_x: T) where T: SomeTrait {} - -trait SomeTrait {} -impl SomeTrait for &'_ str {} -impl SomeTrait for char {} - -fn main() { - let string = String::new(); - takes_str(&string); // Ok - takes_type_parameter(&*string); // Error - //~^ ERROR the trait bound `&String: SomeTrait` is not satisfied -} diff --git a/tests/ui/traits/suggest-deferences/issue-62530.rs b/tests/ui/traits/suggest-deferences/issue-62530.rs deleted file mode 100644 index 53846be73..000000000 --- a/tests/ui/traits/suggest-deferences/issue-62530.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-rustfix -fn takes_str(_x: &str) {} - -fn takes_type_parameter<T>(_x: T) where T: SomeTrait {} - -trait SomeTrait {} -impl SomeTrait for &'_ str {} -impl SomeTrait for char {} - -fn main() { - let string = String::new(); - takes_str(&string); // Ok - takes_type_parameter(&string); // Error - //~^ ERROR the trait bound `&String: SomeTrait` is not satisfied -} diff --git a/tests/ui/traits/suggest-deferences/issue-62530.stderr b/tests/ui/traits/suggest-deferences/issue-62530.stderr deleted file mode 100644 index e47ae0b65..000000000 --- a/tests/ui/traits/suggest-deferences/issue-62530.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0277]: the trait bound `&String: SomeTrait` is not satisfied - --> $DIR/issue-62530.rs:13:26 - | -LL | takes_type_parameter(&string); // Error - | -------------------- ^^^^^^^ the trait `SomeTrait` is not implemented for `&String` - | | - | required by a bound introduced by this call - | -note: required by a bound in `takes_type_parameter` - --> $DIR/issue-62530.rs:4:44 - | -LL | fn takes_type_parameter<T>(_x: T) where T: SomeTrait {} - | ^^^^^^^^^ required by this bound in `takes_type_parameter` -help: consider dereferencing here - | -LL | takes_type_parameter(&*string); // Error - | + - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/suggest-deferences/multiple-0.fixed b/tests/ui/traits/suggest-deferences/multiple-0.fixed deleted file mode 100644 index b7160b75c..000000000 --- a/tests/ui/traits/suggest-deferences/multiple-0.fixed +++ /dev/null @@ -1,36 +0,0 @@ -// run-rustfix -use std::ops::Deref; - -trait Happy {} -struct LDM; -impl Happy for &LDM {} - -struct Foo(LDM); -struct Bar(Foo); -struct Baz(Bar); -impl Deref for Foo { - type Target = LDM; - fn deref(&self) -> &Self::Target { - &self.0 - } -} -impl Deref for Bar { - type Target = Foo; - fn deref(&self) -> &Self::Target { - &self.0 - } -} -impl Deref for Baz { - type Target = Bar; - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -fn foo<T>(_: T) where T: Happy {} - -fn main() { - let baz = Baz(Bar(Foo(LDM))); - foo(&***baz); - //~^ ERROR the trait bound `&Baz: Happy` is not satisfied -} diff --git a/tests/ui/traits/suggest-deferences/multiple-0.rs b/tests/ui/traits/suggest-deferences/multiple-0.rs deleted file mode 100644 index 9ac55177f..000000000 --- a/tests/ui/traits/suggest-deferences/multiple-0.rs +++ /dev/null @@ -1,36 +0,0 @@ -// run-rustfix -use std::ops::Deref; - -trait Happy {} -struct LDM; -impl Happy for &LDM {} - -struct Foo(LDM); -struct Bar(Foo); -struct Baz(Bar); -impl Deref for Foo { - type Target = LDM; - fn deref(&self) -> &Self::Target { - &self.0 - } -} -impl Deref for Bar { - type Target = Foo; - fn deref(&self) -> &Self::Target { - &self.0 - } -} -impl Deref for Baz { - type Target = Bar; - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -fn foo<T>(_: T) where T: Happy {} - -fn main() { - let baz = Baz(Bar(Foo(LDM))); - foo(&baz); - //~^ ERROR the trait bound `&Baz: Happy` is not satisfied -} diff --git a/tests/ui/traits/suggest-deferences/multiple-0.stderr b/tests/ui/traits/suggest-deferences/multiple-0.stderr deleted file mode 100644 index 6a4d4b8d5..000000000 --- a/tests/ui/traits/suggest-deferences/multiple-0.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0277]: the trait bound `&Baz: Happy` is not satisfied - --> $DIR/multiple-0.rs:34:9 - | -LL | foo(&baz); - | --- ^^^^ the trait `Happy` is not implemented for `&Baz` - | | - | required by a bound introduced by this call - | -note: required by a bound in `foo` - --> $DIR/multiple-0.rs:30:26 - | -LL | fn foo<T>(_: T) where T: Happy {} - | ^^^^^ required by this bound in `foo` -help: consider dereferencing here - | -LL | foo(&***baz); - | +++ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/suggest-deferences/multiple-1.rs b/tests/ui/traits/suggest-deferences/multiple-1.rs deleted file mode 100644 index 91c6c7924..000000000 --- a/tests/ui/traits/suggest-deferences/multiple-1.rs +++ /dev/null @@ -1,54 +0,0 @@ -use std::ops::{Deref, DerefMut}; - -trait Happy {} -struct LDM; -impl Happy for &mut LDM {} - -struct Foo(LDM); -struct Bar(Foo); -struct Baz(Bar); -impl Deref for Foo { - type Target = LDM; - fn deref(&self) -> &Self::Target { - &self.0 - } -} -impl Deref for Bar { - type Target = Foo; - fn deref(&self) -> &Self::Target { - &self.0 - } -} -impl Deref for Baz { - type Target = Bar; - fn deref(&self) -> &Self::Target { - &self.0 - } -} -impl DerefMut for Foo { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} -impl DerefMut for Bar { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} -impl DerefMut for Baz { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - - -fn foo<T>(_: T) where T: Happy {} - -fn main() { - // Currently the compiler doesn't try to suggest dereferences for situations - // where DerefMut involves. So this test is meant to ensure compiler doesn't - // generate incorrect help message. - let mut baz = Baz(Bar(Foo(LDM))); - foo(&mut baz); - //~^ ERROR the trait bound `&mut Baz: Happy` is not satisfied -} diff --git a/tests/ui/traits/suggest-deferences/multiple-1.stderr b/tests/ui/traits/suggest-deferences/multiple-1.stderr deleted file mode 100644 index 6e12321c2..000000000 --- a/tests/ui/traits/suggest-deferences/multiple-1.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: the trait bound `&mut Baz: Happy` is not satisfied - --> $DIR/multiple-1.rs:52:9 - | -LL | foo(&mut baz); - | --- ^^^^^^^^ the trait `Happy` is not implemented for `&mut Baz` - | | - | required by a bound introduced by this call - | - = help: the trait `Happy` is implemented for `&mut LDM` -note: required by a bound in `foo` - --> $DIR/multiple-1.rs:45:26 - | -LL | fn foo<T>(_: T) where T: Happy {} - | ^^^^^ required by this bound in `foo` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/suggest-deferences/root-obligation.fixed b/tests/ui/traits/suggest-deferences/root-obligation.fixed deleted file mode 100644 index 7a8433f90..000000000 --- a/tests/ui/traits/suggest-deferences/root-obligation.fixed +++ /dev/null @@ -1,13 +0,0 @@ -// run-rustfix - -fn get_vowel_count(string: &str) -> usize { - string - .chars() - .filter(|c| "aeiou".contains(*c)) - //~^ ERROR expected a `Fn<(char,)>` closure, found `char` - .count() -} - -fn main() { - let _ = get_vowel_count("asdf"); -} diff --git a/tests/ui/traits/suggest-deferences/root-obligation.rs b/tests/ui/traits/suggest-deferences/root-obligation.rs deleted file mode 100644 index 51bac2107..000000000 --- a/tests/ui/traits/suggest-deferences/root-obligation.rs +++ /dev/null @@ -1,13 +0,0 @@ -// run-rustfix - -fn get_vowel_count(string: &str) -> usize { - string - .chars() - .filter(|c| "aeiou".contains(c)) - //~^ ERROR expected a `Fn<(char,)>` closure, found `char` - .count() -} - -fn main() { - let _ = get_vowel_count("asdf"); -} diff --git a/tests/ui/traits/suggest-deferences/root-obligation.stderr b/tests/ui/traits/suggest-deferences/root-obligation.stderr deleted file mode 100644 index 1363fb8c4..000000000 --- a/tests/ui/traits/suggest-deferences/root-obligation.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0277]: expected a `Fn<(char,)>` closure, found `char` - --> $DIR/root-obligation.rs:6:38 - | -LL | .filter(|c| "aeiou".contains(c)) - | -------- ^ expected an `Fn<(char,)>` closure, found `char` - | | - | required by a bound introduced by this call - | - = help: the trait `Fn<(char,)>` is not implemented for `char` - = note: required for `&char` to implement `FnOnce<(char,)>` - = note: required for `&char` to implement `Pattern<'_>` -note: required by a bound in `core::str::<impl str>::contains` - --> $SRC_DIR/core/src/str/mod.rs:LL:COL -help: consider dereferencing here - | -LL | .filter(|c| "aeiou".contains(*c)) - | + - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/suggest-deferences/suggest-dereferencing-receiver-argument.fixed b/tests/ui/traits/suggest-deferences/suggest-dereferencing-receiver-argument.fixed deleted file mode 100644 index ea3d1bf85..000000000 --- a/tests/ui/traits/suggest-deferences/suggest-dereferencing-receiver-argument.fixed +++ /dev/null @@ -1,14 +0,0 @@ -// run-rustfix - -struct TargetStruct; - -impl From<usize> for TargetStruct { - fn from(_unchecked: usize) -> Self { - TargetStruct - } -} - -fn main() { - let a = &3; - let _b: TargetStruct = (*a).into(); //~ ERROR the trait bound `TargetStruct: From<&{integer}>` is not satisfied -} diff --git a/tests/ui/traits/suggest-deferences/suggest-dereferencing-receiver-argument.rs b/tests/ui/traits/suggest-deferences/suggest-dereferencing-receiver-argument.rs deleted file mode 100644 index 9eda68027..000000000 --- a/tests/ui/traits/suggest-deferences/suggest-dereferencing-receiver-argument.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-rustfix - -struct TargetStruct; - -impl From<usize> for TargetStruct { - fn from(_unchecked: usize) -> Self { - TargetStruct - } -} - -fn main() { - let a = &3; - let _b: TargetStruct = a.into(); //~ ERROR the trait bound `TargetStruct: From<&{integer}>` is not satisfied -} diff --git a/tests/ui/traits/suggest-deferences/suggest-dereferencing-receiver-argument.stderr b/tests/ui/traits/suggest-deferences/suggest-dereferencing-receiver-argument.stderr deleted file mode 100644 index ede31a2c7..000000000 --- a/tests/ui/traits/suggest-deferences/suggest-dereferencing-receiver-argument.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: the trait bound `TargetStruct: From<&{integer}>` is not satisfied - --> $DIR/suggest-dereferencing-receiver-argument.rs:13:30 - | -LL | let _b: TargetStruct = a.into(); - | ^^^^ the trait `From<&{integer}>` is not implemented for `TargetStruct` - | - = note: required for `&{integer}` to implement `Into<TargetStruct>` -help: consider dereferencing here - | -LL | let _b: TargetStruct = (*a).into(); - | ++ + - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. |