Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(ui): add tuple-struct-where-clause-suggestion ui test for #91520 #138782

Merged
merged 1 commit into from
Mar 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/ui/suggestions/tuple-struct-where-clause-suggestion-91520.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Verify that the `where` clause suggestion is in the correct place
// Previously, the suggestion to add `where` clause was placed inside the derive
// like `#[derive(Clone where Inner<T>: Clone)]`
// instead of `struct Outer<T>(Inner<T>) where Inner<T>: Clone`

#![crate_type = "lib"]

struct Inner<T>(T);
//~^ HELP consider annotating `Inner<T>` with `#[derive(Clone)]`
impl Clone for Inner<()> {
fn clone(&self) -> Self { todo!() }
}

#[derive(Clone)]
struct Outer<T>(Inner<T>);
//~^ ERROR the trait bound `Inner<T>: Clone` is not satisfied [E0277]
//~| HELP consider introducing a `where` clause
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0277]: the trait bound `Inner<T>: Clone` is not satisfied
--> $DIR/tuple-struct-where-clause-suggestion-91520.rs:15:17
|
LL | #[derive(Clone)]
| ----- in this derive macro expansion
LL | struct Outer<T>(Inner<T>);
| ^^^^^^^^ the trait `Clone` is not implemented for `Inner<T>`
|
help: consider annotating `Inner<T>` with `#[derive(Clone)]`
|
LL + #[derive(Clone)]
LL | struct Inner<T>(T);
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | struct Outer<T>(Inner<T>) where Inner<T>: Clone;
| +++++++++++++++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
Loading