Skip to content

Commit 9f667cd

Browse files
Add overlapping_assoc_constraints param to lower_bounds
1 parent 5de617e commit 9f667cd

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

compiler/rustc_hir_analysis/src/collect/item_bounds.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use tracing::{debug, instrument};
1212

1313
use super::ItemCtxt;
1414
use super::predicates_of::assert_only_contains_predicates_from;
15-
use crate::hir_ty_lowering::{HirTyLowerer, PredicateFilter};
15+
use crate::hir_ty_lowering::{HirTyLowerer, OverlappingAsssocItemConstraints, PredicateFilter};
1616

1717
/// For associated types we include both bounds written on the type
1818
/// (`type X: Trait`) and predicates from the trait: `where Self::X: Trait`.
@@ -37,7 +37,14 @@ fn associated_type_bounds<'tcx>(
3737

3838
let icx = ItemCtxt::new(tcx, assoc_item_def_id);
3939
let mut bounds = Vec::new();
40-
icx.lowerer().lower_bounds(item_ty, hir_bounds, &mut bounds, ty::List::empty(), filter);
40+
icx.lowerer().lower_bounds(
41+
item_ty,
42+
hir_bounds,
43+
&mut bounds,
44+
ty::List::empty(),
45+
filter,
46+
OverlappingAsssocItemConstraints::Allowed,
47+
);
4148

4249
match filter {
4350
PredicateFilter::All
@@ -347,7 +354,14 @@ fn opaque_type_bounds<'tcx>(
347354
ty::print::with_reduced_queries!({
348355
let icx = ItemCtxt::new(tcx, opaque_def_id);
349356
let mut bounds = Vec::new();
350-
icx.lowerer().lower_bounds(item_ty, hir_bounds, &mut bounds, ty::List::empty(), filter);
357+
icx.lowerer().lower_bounds(
358+
item_ty,
359+
hir_bounds,
360+
&mut bounds,
361+
ty::List::empty(),
362+
filter,
363+
OverlappingAsssocItemConstraints::Allowed,
364+
);
351365
// Implicit bounds are added to opaque types unless a `?Trait` bound is found
352366
match filter {
353367
PredicateFilter::All

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ use super::item_bounds::explicit_item_bounds_with_filter;
1818
use crate::collect::ItemCtxt;
1919
use crate::constrained_generic_params as cgp;
2020
use crate::delegation::inherit_predicates_for_delegation_item;
21-
use crate::hir_ty_lowering::{HirTyLowerer, PredicateFilter, RegionInferReason};
21+
use crate::hir_ty_lowering::{
22+
HirTyLowerer, OverlappingAsssocItemConstraints, PredicateFilter, RegionInferReason,
23+
};
2224

2325
/// Returns a list of all type predicates (explicit and implicit) for the definition with
2426
/// ID `def_id`. This includes all predicates returned by `explicit_predicates_of`, plus
@@ -187,6 +189,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
187189
&mut bounds,
188190
ty::List::empty(),
189191
PredicateFilter::All,
192+
OverlappingAsssocItemConstraints::Allowed,
190193
);
191194
icx.lowerer().add_sizedness_bounds(
192195
&mut bounds,
@@ -289,6 +292,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
289292
&mut bounds,
290293
bound_vars,
291294
PredicateFilter::All,
295+
OverlappingAsssocItemConstraints::Allowed,
292296
);
293297
predicates.extend(bounds);
294298
}
@@ -659,7 +663,14 @@ pub(super) fn implied_predicates_with_filter<'tcx>(
659663

660664
let self_param_ty = tcx.types.self_param;
661665
let mut bounds = Vec::new();
662-
icx.lowerer().lower_bounds(self_param_ty, superbounds, &mut bounds, ty::List::empty(), filter);
666+
icx.lowerer().lower_bounds(
667+
self_param_ty,
668+
superbounds,
669+
&mut bounds,
670+
ty::List::empty(),
671+
filter,
672+
OverlappingAsssocItemConstraints::Allowed,
673+
);
663674
match filter {
664675
PredicateFilter::All
665676
| PredicateFilter::SelfOnly
@@ -984,6 +995,7 @@ impl<'tcx> ItemCtxt<'tcx> {
984995
&mut bounds,
985996
bound_vars,
986997
filter,
998+
OverlappingAsssocItemConstraints::Allowed,
987999
);
9881000
}
9891001

@@ -1063,6 +1075,7 @@ pub(super) fn const_conditions<'tcx>(
10631075
&mut bounds,
10641076
bound_vars,
10651077
PredicateFilter::ConstIfConst,
1078+
OverlappingAsssocItemConstraints::Allowed,
10661079
);
10671080
}
10681081
_ => {}
@@ -1083,6 +1096,7 @@ pub(super) fn const_conditions<'tcx>(
10831096
&mut bounds,
10841097
ty::List::empty(),
10851098
PredicateFilter::ConstIfConst,
1099+
OverlappingAsssocItemConstraints::Allowed,
10861100
);
10871101
}
10881102

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
339339
bounds: &mut Vec<(ty::Clause<'tcx>, Span)>,
340340
bound_vars: &'tcx ty::List<ty::BoundVariableKind>,
341341
predicate_filter: PredicateFilter,
342+
overlapping_assoc_constraints: OverlappingAsssocItemConstraints,
342343
) where
343344
'tcx: 'hir,
344345
{
@@ -363,7 +364,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
363364
param_ty,
364365
bounds,
365366
predicate_filter,
366-
OverlappingAsssocItemConstraints::Allowed,
367+
overlapping_assoc_constraints,
367368
);
368369
}
369370
hir::GenericBound::Outlives(lifetime) => {
@@ -604,6 +605,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
604605
bounds,
605606
projection_ty.bound_vars(),
606607
predicate_filter,
608+
OverlappingAsssocItemConstraints::Allowed,
607609
);
608610
}
609611
PredicateFilter::SelfOnly

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,6 +2497,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
24972497
&mut bounds,
24982498
ty::List::empty(),
24992499
PredicateFilter::All,
2500+
OverlappingAsssocItemConstraints::Allowed,
25002501
);
25012502
self.add_sizedness_bounds(
25022503
&mut bounds,

0 commit comments

Comments
 (0)