Feed ErrorGuaranteed from early lifetime resolution errors through to bound variable resolution#152076
Feed ErrorGuaranteed from early lifetime resolution errors through to bound variable resolution#152076eggyal wants to merge 2 commits intorust-lang:mainfrom
ErrorGuaranteed from early lifetime resolution errors through to bound variable resolution#152076Conversation
Undeclared lifetimes that appear in user code always give rise to an error (E0261) early in name resolution. This patch adds such undeclared lifetimes to the relevant context's bound vars, so that they resolve to regions with `RegionKind::Error(ErrorGuaranteed)`, in order to suppress some ensuing diagnostics (that might be resolved if the lifetime becomes properly declared).
|
Changes to the size of AST and/or HIR nodes. cc @nnethercote |
|
|
There was a problem hiding this comment.
Thanks for working on this! I won't be able to review this tonight but I'd like to note that thanks to your changes we should now be able to get rid of the minor hack in HIR ty lowering as I've mentioned in the issue:
rust/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs
Lines 454 to 464 in f60a0f1
(by replacing that whole snippet with just RegionInferReason::ObjectLifetimeDefault)
No worries !
Ah, good point! I forgot about that. I'll take a look and push an update if it can be removed cleanly. |
|
Preliminary sanity perf check due to size changes. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Bind undeclared lifetimes as erroneous bound vars
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (e81e54f): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 3.1%, secondary -0.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 472.721s -> 472.345s (-0.08%) |
|
HIR ty lowering was modified cc @fmease |
| let span = *entry.get(); | ||
| let err = ResolutionError::NameAlreadyUsedInParameterList(ident, span); | ||
| self.report_error(param.ident.span, err); | ||
| let guar = self.r.report_error(param.ident.span, err); |
There was a problem hiding this comment.
This will unconditionally emit an error, whereas before it was suppressed in rustdoc; however I'm not sure that such suppression was correct here anyway—see the comments on Self::should_report_error, which don't appear to apply:
rust/compiler/rustc_resolve/src/late.rs
Lines 4718 to 4720 in a531436
In any event, this change doesn't appear to be breaking any tests...
There was a problem hiding this comment.
Okay, it wasn't breaking x test locally, but clearly it's broken one in CI.
@rustbot author
e7d86b7 to
a531436
Compare
There was a problem hiding this comment.
Whereas in 08ed1a1 I was only feeding ErrorGuaranteed through to RBV in the specific case of undeclared named lifetimes, in a531436 I've extended the logic to feed through such an ErrorGuaranteed for every early lifetime resolution error. This enables the aforementioned "hack" to be removed without giving rise to new instances of E0228 ("the lifetime bound for this object type cannot be deduced from context"), however it does also suppress a few other errors that previously were emitted—see updates to test outputs.
View changes since this review
I didn't squash (yet) in case you had begun reviewing and it was easier to see what has since changed. However, these commits really ought to be squashed (with commensurate updates to the PR description and commit comments) before merging, and review may be easier combined in any event.
ErrorGuaranteed from early lifetime resolution errors through to bound variable resolution
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
Reminder, once the PR becomes ready for a review, use |
Undeclared lifetimes that appear in user code always give rise to an error (E0261) early in name resolution. This patch adds such undeclared lifetimes to the relevant context's bound vars, so that they resolve to regions with
RegionKind::Error(ErrorGuaranteed), in order to suppress some ensuing diagnostics (that might be resolved if the lifetime becomes properly declared).Fixes #152014
r? fmease