Skip to content

Commit 6dbae3a

Browse files
committed
Auto merge of #97313 - cjgillot:ast-lifetimes-anon, r=petrochenkov
Resolve function lifetime elision on the AST ~Based on #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`
2 parents bdf520f + b9bd65e commit 6dbae3a

File tree

58 files changed

+1560
-1627
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1560
-1627
lines changed

compiler/rustc_ast_lowering/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1835,7 +1835,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
18351835
debug!(?self.captured_lifetimes);
18361836
let name = match res {
18371837
LifetimeRes::Param { mut param, binder } => {
1838-
debug_assert_ne!(ident.name, kw::UnderscoreLifetime);
18391838
let p_name = ParamName::Plain(ident);
18401839
if let Some(mut captured_lifetimes) = self.captured_lifetimes.take() {
18411840
if !captured_lifetimes.binders_to_ignore.contains(&binder) {

compiler/rustc_hir/src/def.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ impl<Id> Res<Id> {
713713
}
714714

715715
/// Resolution for a lifetime appearing in a type.
716-
#[derive(Copy, Clone, Debug)]
716+
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
717717
pub enum LifetimeRes {
718718
/// Successfully linked the lifetime to a generic parameter.
719719
Param {

compiler/rustc_resolve/src/late.rs

+499-161
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)