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

feat: add quickfix for redundant_assoc_item diagnostic #16223

Merged
merged 3 commits into from
Jan 5, 2024

Conversation

Young-Flash
Copy link
Member

@Young-Flash Young-Flash commented Jan 1, 2024

Happy New Year 😊

follow up #15990, now it's time to close #15958, closes #16269

demo

EDIT: add a demo.gif would be more illustrated when making release change log.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 1, 2024
.unwrap_or(default_range),
format!("\n type {};", type_alias.name(ctx.sema.db).to_smol_str()),
)
}
};

Diagnostic::new(
DiagnosticCode::RustcHardError("E0407"),
format!("{redundant_item_name} is not a member of trait `{trait_name}`"),
FileRange { file_id: d.file_id.file_id().unwrap(), range: diagnostic_range },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I just realized I missed this on the review that added this diagnostic, but this unwrap is very bad 😅 We should be using adjusted_display_range_new to get the new range for this here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adjusted_display_range_new require a diag_ptr: InFile<AstPtr<N>>, regarding get diag_ptr from the current hir::AssocItem, we could use hir::AssocItem.source(db), which return an Option<InFile<Self::Ast>>, could we unwarp or expect directly? since hir::AssocItem.source(db) actually return Some(...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can also do something similar to adjusted_display_range_new since we are skipping the diag_ptr. And no unwrapping isn't an option here, the source fetching is technically fully infallible right now, but we might change things at some point where we allow loading libraries with missing sources at which point the unwrap would fail.

Copy link
Contributor

@saiintbrisson saiintbrisson Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't aware this was already discussed here. Opened an issue #16269.

@Veykril Veykril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 2, 2024
@Veykril
Copy link
Member

Veykril commented Jan 5, 2024

Thanks!
@bors +

@saiintbrisson
Copy link
Contributor

@Veykril I guess you forgot the r in r+

@lnicola
Copy link
Member

lnicola commented Jan 5, 2024

@bors r=Veykril

@bors
Copy link
Collaborator

bors commented Jan 5, 2024

📌 Commit c5c1360 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jan 5, 2024

⌛ Testing commit c5c1360 with merge 2980d54...

@bors
Copy link
Collaborator

bors commented Jan 5, 2024

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 2980d54 to master...

1 similar comment
@bors
Copy link
Collaborator

bors commented Jan 5, 2024

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 2980d54 to master...

@bors bors merged commit 2980d54 into rust-lang:master Jan 5, 2024
10 checks passed
@bors
Copy link
Collaborator

bors commented Jan 5, 2024

👀 Test was successful, but fast-forwarding failed: 422 Changes must be made through a pull request.

@Young-Flash Young-Flash deleted the quickfix_redundant_assoc_item branch January 9, 2024 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
6 participants