6

diagnostics: do not suggest type name tweaks on type-inferred closure args by no...

 1 year ago
source link: https://github.com/rust-lang/rust/pull/112325
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Conversation

Contributor

Fixes #111932

Collaborator

r? @eholk

(rustbot has picked a reviewer for you, use r? to override)

rustbot

added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

labels

Jun 5, 2023

This comment has been minimized.

Collaborator

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Member

@compiler-errors compiler-errors

left a comment

edited

Does this need to be such a heavy hammer? It really looks like we should just not be applying suggestions to closure arguments that have no type span -- that seemed to me to be the real issue with #111932.

We can still keep suggestions for closure args that do, like |x: dyn Trait| or whatever.

Or better yet, we apply them but make sure to apply them correctly...

fcx.require_type_is_sized(

param_ty,

param.pat.span,

traits::SizedArgumentType(ty_span.filter(|_| !tcx.is_closure(fn_def_id.into()))),

Can you make this into an if like below? Easier to read that way IMO

Contributor

Author

Does this need to be such a heavy hammer? It really looks like we should just not be applying suggestions to closure arguments that have no type span

It's complicated because hir::Param::ty_span isn't an Option, so it's not clear how to tell if a closure argument has a type ascription or not.

Would you rather HIR be changed to make ty_span an Option, and have it filled in as None when a closure argument doesn't have one?

That's one way of doing it. If you don't want to do that much work though, you can check if the ty_span is equal to the binding's span, perhaps like how dc2977e does it...

notriddle

changed the title diagnostics: do not suggest type name tweaks on closure args

diagnostics: do not suggest type name tweaks on type-inferred closure args

Jun 6, 2023

Contributor

Author

That makes sense. I've pushed a new commit that does that.

Member

@compiler-errors compiler-errors

left a comment

r=me when green

This comment has been minimized.

Contributor

Author

@bors r=compiler-errors

Contributor

pushpin Commit 467bc9f has been approved by compiler-errors

It is now in the queue for this repository.

bors

added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

labels

Jun 6, 2023

bors

merged commit 38c92cc into

rust-lang:master

Jun 6, 2023

11 checks passed

rust-timer

added a commit to rust-lang-ci/rust that referenced this pull request

Jun 6, 2023

rustbot

added this to the 1.72.0 milestone

Jun 6, 2023

notriddle

deleted the notriddle/issue-111932 branch

June 6, 2023 21:48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

compiler-errors

compiler-errors approved these changes
Assignees

eholk

Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects

None yet

Milestone

1.72.0

Development

Successfully merging this pull request may close these issues.

E0277 shows invalid help in closures

6 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK