-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
where clause for tuple structs recommended at wrong place causing syntax errors #91520
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
struct Inner<T>(T);
impl Clone for Inner<()> {
fn clone(&self) -> Self { todo!() }
}
#[derive(Clone)]
struct Outer<T>(Inner<T>); leads to a nonsensical suggestion on stable:
Seems to be fixed on nightly though. |
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Mar 16, 2023
Do not provide suggestions when the spans come from expanded code that doesn't point at user code Hide invalid proc-macro suggestions and track spans coming from proc-macros pointing at attribute. Effectively, unless the proc-macro keeps user spans, suggestions will not be produced for the code they produce. r? `@ghost` Fix rust-lang#107113, fix rust-lang#107976, fix rust-lang#107977, fix rust-lang#108748, fix rust-lang#106720, fix rust-lang#90557. Could potentially address rust-lang#50141, rust-lang#67373, rust-lang#55146, rust-lang#78862, rust-lang#74043, rust-lang#88514, rust-lang#83320, rust-lang#91520, rust-lang#104071. CC rust-lang#50122, rust-lang#76360.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Mar 17, 2023
Do not provide suggestions when the spans come from expanded code that doesn't point at user code Hide invalid proc-macro suggestions and track spans coming from proc-macros pointing at attribute. Effectively, unless the proc-macro keeps user spans, suggestions will not be produced for the code they produce. r? ``@ghost`` Fix rust-lang#107113, fix rust-lang#107976, fix rust-lang#107977, fix rust-lang#108748, fix rust-lang#106720, fix rust-lang#90557. Could potentially address rust-lang#50141, rust-lang#67373, rust-lang#55146, rust-lang#78862, rust-lang#74043, rust-lang#88514, rust-lang#83320, rust-lang#91520, rust-lang#104071. CC rust-lang#50122, rust-lang#76360.
Can be closed by adding a test. |
@rustbot claim |
matthiaskrgr
pushed a commit
to matthiaskrgr/rust
that referenced
this issue
Mar 22, 2025
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Mar 22, 2025
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#138609 (Add stack overflow handler for cygwin) - rust-lang#138639 (Clean UI tests 2 of n) - rust-lang#138773 (catch_unwind intrinsic: document return value) - rust-lang#138782 (test(ui): add tuple-struct-where-clause-suggestion ui test for rust-lang#91520) - rust-lang#138794 (expand: Do not report `cfg_attr` traces on macros as unused attributes) - rust-lang#138801 (triagebot: add autolabel rules for D-* and L-*) - rust-lang#138804 (Allow inlining for `Atomic*::from_ptr`) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
Mar 22, 2025
Rollup merge of rust-lang#138782 - karolzwolak:where-test-91520, r=compiler-errors test(ui): add tuple-struct-where-clause-suggestion ui test for rust-lang#91520 Fixes rust-lang#91520 I tried to also make it a .fixed test, but I failed to accomplish that. That's because of the 'consider annotating `Inner<T>` with `#[derive(Clone)]`' suggestion does not compile (conflicting Clone implementations), and I can't isolate them with `rustfix-only-machine-applicable` as both suggestions are not marked as `MachineApplicable`. Instead I just test that the where clause suggestion is applied to the correct line.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Me Newbie. I had this issue while trying to create a new type to abstract over a HashMap, went to rust discord where i got the fix. then, as i got the suggestion as a quickfix from vscode, i thought it was a Rust analyzer bug, rust-lang/rust-analyzer#10923 . but this is a rust bug it seems.
Reproduce error:
derive_more
andhalfbrown
as dependencies. //hashbrown will probably work toohalfbrown::HashMap
as its only field.UOMap<K,V>(halfbrown::HashMap<K,V>)
IntoIterator
using derive_more with the #[derive(IntoIterator)] and vscode gives this error.cargo check output:
8 | pub struct UOMap<K: std::hash::Hash,V> where halfbrown::HashMap<K, V>: IntoIterator(HashMap<K, V>);
with where clause between the struct name and the parenthesis which declare the fields, is wrong and introduces a whole new class of errorscargo output:
The Fix:
changing
pub struct UOMap<K: std::hash::Hash,V> where halfbrown::HashMap<K, V>: std::iter::IntoIterator(HashMap<K, V>);
to
pub struct UOMap<K: std::hash::Hash,V>(HashMap<K, V>) where halfbrown::HashMap<K, V>: std::iter::IntoIterator;
basically, insert the where clause AFTER the closing parenthesis.
from what i was told on the discord, where clause needs to come just before the first
{
, but idk how it will be dealt with in regards to tuple struct.rustc version: rustc 1.57.0 (f1edd04 2021-11-29)
The text was updated successfully, but these errors were encountered: