-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Point out failing never obligation for DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK
#126367
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 |
---|---|---|
|
@@ -488,7 +488,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { | |
let remaining_errors_if_fallback_to = |fallback| { | ||
self.probe(|_| { | ||
let obligations = self.fulfillment_cx.borrow().pending_obligations(); | ||
let ocx = ObligationCtxt::new(&self.infcx); | ||
let ocx = ObligationCtxt::new_with_diagnostics(&self.infcx); | ||
ocx.register_obligations(obligations.iter().cloned()); | ||
|
||
for &diverging_vid in diverging_vids { | ||
|
@@ -506,14 +506,18 @@ impl<'tcx> FnCtxt<'_, 'tcx> { | |
// then this code will be broken by the never type fallback change.qba | ||
let unit_errors = remaining_errors_if_fallback_to(self.tcx.types.unit); | ||
if unit_errors.is_empty() | ||
&& let never_errors = remaining_errors_if_fallback_to(self.tcx.types.never) | ||
&& !never_errors.is_empty() | ||
&& let mut never_errors = remaining_errors_if_fallback_to(self.tcx.types.never) | ||
&& let [ref mut never_error, ..] = never_errors.as_mut_slice() | ||
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. Do you think we should lint individually on each failing obligation? Or maybe I should make it a subdiagnostic so we can have multiple of them? If we print out >1, I should probably do some deduplication like we do for real fulfillment errors 🤔 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. I think ideally we should print out all the errors, but maybe it will be too noisy, idk. This PR as is seems like a good first step/clear improvement. |
||
{ | ||
self.adjust_fulfillment_error_for_expr_obligation(never_error); | ||
compiler-errors marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.tcx.emit_node_span_lint( | ||
lint::builtin::DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK, | ||
self.tcx.local_def_id_to_hir_id(self.body_id), | ||
self.tcx.def_span(self.body_id), | ||
errors::DependencyOnUnitNeverTypeFallback {}, | ||
errors::DependencyOnUnitNeverTypeFallback { | ||
obligation_span: never_error.obligation.cause.span, | ||
obligation: never_error.obligation.predicate, | ||
}, | ||
) | ||
} | ||
} | ||
|
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.
maybe we can mention somehow that we plan to break this on all editions eventually?
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.
do you have an opinion on the wording?
seems awkward, and I have no idea what a better wording could be 🤔