Skip to content

Commit 842a7d3

Browse files
authored
Rollup merge of #102492 - compiler-errors:simplify-deny-assoc-bindings, r=cjgillot
Don't lower assoc bindings just to deny them Some clean-up: #102338 (comment)
2 parents 808f197 + 3722ad4 commit 842a7d3

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

compiler/rustc_hir_analysis/src/astconv/generics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
448448
let infer_lifetimes =
449449
(gen_pos != GenericArgPosition::Type || infer_args) && !gen_args.has_lifetime_params();
450450

451-
if gen_pos != GenericArgPosition::Type && !gen_args.bindings.is_empty() {
452-
Self::prohibit_assoc_ty_binding(tcx, gen_args.bindings[0].span);
451+
if gen_pos != GenericArgPosition::Type && let Some(b) = gen_args.bindings.first() {
452+
Self::prohibit_assoc_ty_binding(tcx, b.span);
453453
}
454454

455455
let explicit_late_bound =

compiler/rustc_hir_analysis/src/astconv/mod.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
276276
item_segment.infer_args,
277277
None,
278278
);
279-
let assoc_bindings = self.create_assoc_bindings_for_generic_args(item_segment.args());
280-
281-
if let Some(b) = assoc_bindings.first() {
279+
if let Some(b) = item_segment.args().bindings.first() {
282280
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
283281
}
284282

@@ -605,8 +603,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
605603
None,
606604
);
607605

608-
let assoc_bindings = self.create_assoc_bindings_for_generic_args(item_segment.args());
609-
if let Some(b) = assoc_bindings.first() {
606+
if let Some(b) = item_segment.args().bindings.first() {
610607
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
611608
}
612609

@@ -794,8 +791,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
794791
trait_segment,
795792
is_impl,
796793
);
797-
let assoc_bindings = self.create_assoc_bindings_for_generic_args(trait_segment.args());
798-
if let Some(b) = assoc_bindings.first() {
794+
if let Some(b) = trait_segment.args().bindings.first() {
799795
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
800796
}
801797
ty::TraitRef::new(trait_def_id, substs)
@@ -2207,8 +2203,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
22072203

22082204
for segment in segments {
22092205
// Only emit the first error to avoid overloading the user with error messages.
2210-
if let [binding, ..] = segment.args().bindings {
2211-
Self::prohibit_assoc_ty_binding(self.tcx(), binding.span);
2206+
if let Some(b) = segment.args().bindings.first() {
2207+
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
22122208
return true;
22132209
}
22142210
}

0 commit comments

Comments
 (0)