-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Improve location reporting of trait placeholder error #124977
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -101,13 +101,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { | |||||
&mut self, | ||||||
// Keep this parameter for now, in case we start using | ||||||
// it in `ConstraintCategory` at some point. | ||||||
Comment on lines
102
to
103
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.
Suggested change
|
||||||
_def_id: DefId, | ||||||
def_id: DefId, | ||||||
instantiated_predicates: ty::InstantiatedPredicates<'tcx>, | ||||||
locations: Locations, | ||||||
) { | ||||||
for (predicate, span) in instantiated_predicates { | ||||||
debug!(?span, ?predicate); | ||||||
let category = ConstraintCategory::Predicate(span); | ||||||
let category = ConstraintCategory::Predicate(def_id, span); | ||||||
let predicate = self.normalize_with_category(predicate, locations, category); | ||||||
self.prove_predicate(predicate, locations, category); | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ use crate::traits::{ObligationCause, ObligationCauseCode}; | |
use rustc_data_structures::intern::Interned; | ||
use rustc_errors::{Diag, IntoDiagArg}; | ||
use rustc_hir::def::Namespace; | ||
use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; | ||
use rustc_hir::def_id::DefId; | ||
use rustc_middle::bug; | ||
use rustc_middle::ty::error::ExpectedFound; | ||
use rustc_middle::ty::print::{FmtPrinter, Print, PrintTraitRefExt as _, RegionHighlightMode}; | ||
|
@@ -240,21 +240,17 @@ impl<'tcx> NiceRegionError<'_, 'tcx> { | |
) -> Diag<'tcx> { | ||
let span = cause.span(); | ||
|
||
let (leading_ellipsis, satisfy_span, where_span, dup_span, def_id) = | ||
if let ObligationCauseCode::WhereClause(def_id, span) | ||
| ObligationCauseCode::WhereClauseInExpr(def_id, span, ..) = *cause.code() | ||
&& def_id != CRATE_DEF_ID.to_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. Why is this check removed? |
||
{ | ||
( | ||
true, | ||
Some(span), | ||
Some(self.tcx().def_span(def_id)), | ||
None, | ||
self.tcx().def_path_str(def_id), | ||
) | ||
} else { | ||
(false, None, None, Some(span), String::new()) | ||
}; | ||
let (leading_ellipsis, satisfy_span, where_span, dup_span, def_id) = match *cause.code() { | ||
ObligationCauseCode::WhereClause(def_id, pred_span) | ||
| ObligationCauseCode::WhereClauseInExpr(def_id, pred_span, ..) => ( | ||
true, | ||
Some(span), | ||
if pred_span.is_dummy() { Some(span) } else { Some(pred_span) }, | ||
None, | ||
self.tcx().def_path_str(def_id), | ||
), | ||
_ => (false, None, None, Some(span), String::new()), | ||
}; | ||
|
||
let expected_trait_ref = self.cx.resolve_vars_if_possible(ty::TraitRef::new_from_args( | ||
self.cx.tcx, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
error: implementation of `Coroutine` is not general enough | ||
--> $DIR/resume-arg-late-bound.rs:15:5 | ||
| | ||
LL | fn test(a: impl for<'a> Coroutine<&'a mut bool>) {} | ||
| ------------------------------- due to a where-clause on `test`... | ||
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. The terminology may be a bit surprising here. |
||
... | ||
LL | test(gen); | ||
| ^^^^^^^^^ implementation of `Coroutine` is not general enough | ||
| ^^^^^^^^^ doesn't satisfy where-clause | ||
| | ||
= note: `{coroutine@$DIR/resume-arg-late-bound.rs:11:28: 11:44}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... | ||
= note: ...`{coroutine@$DIR/resume-arg-late-bound.rs:11:28: 11:44}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... | ||
= note: ...but it actually implements `Coroutine<&'2 mut bool>`, for some specific lifetime `'2` | ||
|
||
error: aborting due to 1 previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,50 @@ | ||
error: implementation of `FnOnce` is not general enough | ||
--> $DIR/issue-71955.rs:45:5 | ||
| | ||
LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool | ||
| --------------------------------------- due to a where-clause on `foo`... | ||
... | ||
LL | foo(bar, "string", |s| s.len() == 5); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't satisfy where-clause | ||
| | ||
= note: closure with signature `for<'a> fn(&'a &'2 str) -> bool` must implement `FnOnce<(&&'1 str,)>`, for any lifetime `'1`... | ||
= note: ...closure with signature `for<'a> fn(&'a &'2 str) -> bool` must implement `FnOnce<(&&'1 str,)>`, for any lifetime `'1`... | ||
= note: ...but it actually implements `FnOnce<(&&'2 str,)>`, for some specific lifetime `'2` | ||
|
||
error: implementation of `FnOnce` is not general enough | ||
--> $DIR/issue-71955.rs:45:5 | ||
| | ||
LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool | ||
| ---- due to a where-clause on `foo`... | ||
... | ||
LL | foo(bar, "string", |s| s.len() == 5); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't satisfy where-clause | ||
| | ||
= note: closure with signature `for<'a> fn(&'a &'2 str) -> bool` must implement `FnOnce<(&&'1 str,)>`, for any lifetime `'1`... | ||
= note: ...closure with signature `for<'a> fn(&'a &'2 str) -> bool` must implement `FnOnce<(&&'1 str,)>`, for any lifetime `'1`... | ||
= note: ...but it actually implements `FnOnce<(&&'2 str,)>`, for some specific lifetime `'2` | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: implementation of `FnOnce` is not general enough | ||
--> $DIR/issue-71955.rs:48:5 | ||
| | ||
LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool | ||
| --------------------------------------- due to a where-clause on `foo`... | ||
... | ||
LL | foo(baz, "string", |s| s.0.len() == 5); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't satisfy where-clause | ||
| | ||
= note: closure with signature `for<'a> fn(&'a Wrapper<'2>) -> bool` must implement `FnOnce<(&Wrapper<'1>,)>`, for any lifetime `'1`... | ||
= note: ...closure with signature `for<'a> fn(&'a Wrapper<'2>) -> bool` must implement `FnOnce<(&Wrapper<'1>,)>`, for any lifetime `'1`... | ||
= note: ...but it actually implements `FnOnce<(&Wrapper<'2>,)>`, for some specific lifetime `'2` | ||
|
||
error: implementation of `FnOnce` is not general enough | ||
--> $DIR/issue-71955.rs:48:5 | ||
| | ||
LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool | ||
| ---- due to a where-clause on `foo`... | ||
... | ||
LL | foo(baz, "string", |s| s.0.len() == 5); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't satisfy where-clause | ||
| | ||
= note: closure with signature `for<'a> fn(&'a Wrapper<'2>) -> bool` must implement `FnOnce<(&Wrapper<'1>,)>`, for any lifetime `'1`... | ||
= note: ...closure with signature `for<'a> fn(&'a Wrapper<'2>) -> bool` must implement `FnOnce<(&Wrapper<'1>,)>`, for any lifetime `'1`... | ||
= note: ...but it actually implements `FnOnce<(&Wrapper<'2>,)>`, for some specific lifetime `'2` | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: aborting due to 4 previous errors | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or adjust accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL