-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Rework "point at arg" suggestions to be more accurate #100654
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c005e76
Rework point-at-arg
compiler-errors d05fea6
Account for relative paths
compiler-errors c9cb19d
Skip mentioning lang item
compiler-errors 3a1aa3c
Do not favor projection type when pointing out arg causing fulfillmen…
compiler-errors 52e2065
Revert closure mismatch spans
compiler-errors 70b29f7
Note closure kind mismatch cause
compiler-errors c874676
Rework ambiguity errors
compiler-errors 24559ce
Prefer non-Self non-method types over Self, first
compiler-errors c0c6603
Deduplicate errors that come from places like normalization, sized
compiler-errors 292ab39
Point at struct field if possible
compiler-errors 6848ba2
Comment a bit, use find_ancestor_in_same_ctxt to suppress some weird …
compiler-errors 8917894
Targeted fixes addressing erroneous suggestions
compiler-errors 2a16a12
More docs
compiler-errors d2f54b1
Adjust messages, address some nits
compiler-errors 5212ac9
Make check for overlapping closure span more accurate
compiler-errors d577eb0
Bless tests after #100769
compiler-errors File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -860,8 +860,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { | |
} | ||
} | ||
|
||
err.emit(); | ||
return; | ||
err | ||
} | ||
|
||
ty::PredicateKind::WellFormed(ty) => { | ||
|
@@ -1564,6 +1563,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { | |
obligation.cause.code().peel_derives(), | ||
ObligationCauseCode::ItemObligation(_) | ||
| ObligationCauseCode::BindingObligation(_, _) | ||
| ObligationCauseCode::ExprItemObligation(..) | ||
| ObligationCauseCode::ExprBindingObligation(..) | ||
| ObligationCauseCode::ObjectCastObligation(..) | ||
| ObligationCauseCode::OpaqueType | ||
); | ||
|
@@ -2091,13 +2092,11 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { | |
} | ||
} | ||
|
||
if let ObligationCauseCode::ItemObligation(def_id) = *obligation.cause.code() { | ||
if let ObligationCauseCode::ItemObligation(def_id) | ObligationCauseCode::ExprItemObligation(def_id, ..) = *obligation.cause.code() { | ||
self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref.def_id()); | ||
} else if let ( | ||
Ok(ref snippet), | ||
&ObligationCauseCode::BindingObligation(def_id, _), | ||
) = | ||
(self.tcx.sess.source_map().span_to_snippet(span), obligation.cause.code()) | ||
} else if let Ok(snippet) = &self.tcx.sess.source_map().span_to_snippet(span) | ||
&& let ObligationCauseCode::BindingObligation(def_id, _) | ObligationCauseCode::ExprBindingObligation(def_id, ..) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seeing the proliferation of these kind of checks, we might want to start adding methods to the |
||
= *obligation.cause.code() | ||
{ | ||
let generics = self.tcx.generics_of(def_id); | ||
if generics.params.iter().any(|p| p.name != kw::SelfUpper) | ||
|
@@ -2520,15 +2519,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { | |
err: &mut Diagnostic, | ||
obligation: &PredicateObligation<'tcx>, | ||
) { | ||
let ( | ||
ty::PredicateKind::Trait(pred), | ||
&ObligationCauseCode::BindingObligation(item_def_id, span), | ||
) = ( | ||
obligation.predicate.kind().skip_binder(), | ||
obligation.cause.code().peel_derives(), | ||
) else { | ||
return; | ||
}; | ||
let ty::PredicateKind::Trait(pred) = obligation.predicate.kind().skip_binder() else { return; }; | ||
let (ObligationCauseCode::BindingObligation(item_def_id, span) | ||
| ObligationCauseCode::ExprBindingObligation(item_def_id, span, ..)) | ||
= *obligation.cause.code().peel_derives() else { return; }; | ||
debug!(?pred, ?item_def_id, ?span); | ||
|
||
let (Some(node), true) = ( | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.