Skip to content

Commit

Permalink
Auto merge of rust-lang#97313 - cjgillot:ast-lifetimes-anon, r=petroc…
Browse files Browse the repository at this point in the history
…henkov

Resolve function lifetime elision on the AST

~Based on rust-lang#97720

Lifetime elision for functions is purely syntactic in nature, so can be resolved on the AST.
This PR replicates the elision logic and diagnostics on the AST, and replaces HIR-based resolution by a `delay_span_bug`.

This refactor allows for more consistent diagnostics, which don't have to guess the original code from HIR.

r? `@petrochenkov`
  • Loading branch information
bors committed Jul 25, 2022
2 parents bdf520f + b9bd65e commit 6dbae3a
Show file tree
Hide file tree
Showing 58 changed files with 1,560 additions and 1,627 deletions.
1 change: 0 additions & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1835,7 +1835,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
debug!(?self.captured_lifetimes);
let name = match res {
LifetimeRes::Param { mut param, binder } => {
debug_assert_ne!(ident.name, kw::UnderscoreLifetime);
let p_name = ParamName::Plain(ident);
if let Some(mut captured_lifetimes) = self.captured_lifetimes.take() {
if !captured_lifetimes.binders_to_ignore.contains(&binder) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ impl<Id> Res<Id> {
}

/// Resolution for a lifetime appearing in a type.
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum LifetimeRes {
/// Successfully linked the lifetime to a generic parameter.
Param {
Expand Down
660 changes: 499 additions & 161 deletions compiler/rustc_resolve/src/late.rs

Large diffs are not rendered by default.

Loading

0 comments on commit 6dbae3a

Please sign in to comment.