Skip to content

Commit 267d362

Browse files
committed
Move fn parameter ribs outwards.
1 parent ae70e36 commit 267d362

File tree

1 file changed

+62
-36
lines changed

1 file changed

+62
-36
lines changed

compiler/rustc_resolve/src/late.rs

+62-36
Original file line numberDiff line numberDiff line change
@@ -695,14 +695,25 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
695695
},
696696
|this| {
697697
this.visit_generic_params(&bare_fn.generic_params, false);
698-
this.resolve_fn_signature(
699-
ty.id,
700-
None,
701-
false,
702-
// We don't need to deal with patterns in parameters, because
703-
// they are not possible for foreign or bodiless functions.
704-
bare_fn.decl.inputs.iter().map(|Param { ty, .. }| (None, &**ty)),
705-
&bare_fn.decl.output,
698+
this.with_lifetime_rib(
699+
LifetimeRibKind::AnonymousCreateParameter {
700+
binder: ty.id,
701+
report_in_path: false,
702+
},
703+
|this| {
704+
this.resolve_fn_signature(
705+
ty.id,
706+
false,
707+
// We don't need to deal with patterns in parameters, because
708+
// they are not possible for foreign or bodiless functions.
709+
bare_fn
710+
.decl
711+
.inputs
712+
.iter()
713+
.map(|Param { ty, .. }| (None, &**ty)),
714+
&bare_fn.decl.output,
715+
)
716+
},
706717
);
707718
},
708719
)
@@ -782,12 +793,19 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
782793
| FnKind::Fn(_, _, sig, _, generics, None) => {
783794
self.visit_fn_header(&sig.header);
784795
self.visit_generics(generics);
785-
self.resolve_fn_signature(
786-
fn_id,
787-
None,
788-
sig.decl.has_self(),
789-
sig.decl.inputs.iter().map(|Param { ty, .. }| (None, &**ty)),
790-
&sig.decl.output,
796+
self.with_lifetime_rib(
797+
LifetimeRibKind::AnonymousCreateParameter {
798+
binder: fn_id,
799+
report_in_path: false,
800+
},
801+
|this| {
802+
this.resolve_fn_signature(
803+
fn_id,
804+
sig.decl.has_self(),
805+
sig.decl.inputs.iter().map(|Param { ty, .. }| (None, &**ty)),
806+
&sig.decl.output,
807+
)
808+
},
791809
);
792810
return;
793811
}
@@ -812,15 +830,22 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
812830
let declaration = &sig.decl;
813831
let async_node_id = sig.header.asyncness.opt_return_id();
814832

815-
this.resolve_fn_signature(
816-
fn_id,
817-
async_node_id,
818-
declaration.has_self(),
819-
declaration
820-
.inputs
821-
.iter()
822-
.map(|Param { pat, ty, .. }| (Some(&**pat), &**ty)),
823-
&declaration.output,
833+
this.with_lifetime_rib(
834+
LifetimeRibKind::AnonymousCreateParameter {
835+
binder: fn_id,
836+
report_in_path: async_node_id.is_some(),
837+
},
838+
|this| {
839+
this.resolve_fn_signature(
840+
fn_id,
841+
declaration.has_self(),
842+
declaration
843+
.inputs
844+
.iter()
845+
.map(|Param { pat, ty, .. }| (Some(&**pat), &**ty)),
846+
&declaration.output,
847+
)
848+
},
824849
);
825850

826851
// Construct the list of in-scope lifetime parameters for async lowering.
@@ -1035,12 +1060,19 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
10351060
kind: LifetimeBinderKind::PolyTrait,
10361061
..
10371062
} => {
1038-
self.resolve_fn_signature(
1039-
binder,
1040-
None,
1041-
false,
1042-
p_args.inputs.iter().map(|ty| (None, &**ty)),
1043-
&p_args.output,
1063+
self.with_lifetime_rib(
1064+
LifetimeRibKind::AnonymousCreateParameter {
1065+
binder,
1066+
report_in_path: false,
1067+
},
1068+
|this| {
1069+
this.resolve_fn_signature(
1070+
binder,
1071+
false,
1072+
p_args.inputs.iter().map(|ty| (None, &**ty)),
1073+
&p_args.output,
1074+
)
1075+
},
10441076
);
10451077
break;
10461078
}
@@ -1813,18 +1845,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
18131845
fn resolve_fn_signature(
18141846
&mut self,
18151847
fn_id: NodeId,
1816-
async_node_id: Option<NodeId>,
18171848
has_self: bool,
18181849
inputs: impl Iterator<Item = (Option<&'ast Pat>, &'ast Ty)> + Clone,
18191850
output_ty: &'ast FnRetTy,
18201851
) {
18211852
// Add each argument to the rib.
1822-
let parameter_rib = LifetimeRibKind::AnonymousCreateParameter {
1823-
binder: fn_id,
1824-
report_in_path: async_node_id.is_some(),
1825-
};
1826-
let elision_lifetime =
1827-
self.with_lifetime_rib(parameter_rib, |this| this.resolve_fn_params(has_self, inputs));
1853+
let elision_lifetime = self.resolve_fn_params(has_self, inputs);
18281854
debug!(?elision_lifetime);
18291855

18301856
let outer_failures = take(&mut self.diagnostic_metadata.current_elision_failures);

0 commit comments

Comments
 (0)