Skip to content

Commit ed32482

Browse files
committed
Handle multiple trait-def projection candidates
1 parent 0dfa6ff commit ed32482

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

compiler/rustc_trait_selection/src/traits/project.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,13 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
977977

978978
if is_match {
979979
candidate_set.push_candidate(ctor(data));
980+
981+
if potentially_unnormalized_candidates && !obligation.predicate.needs_infer() {
982+
// HACK: Pick the first trait def candidate for a fully
983+
// inferred predicate. This is to allow duplicates that
984+
// differ only in normalization.
985+
return;
986+
}
980987
}
981988
}
982989
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Check that if we have multiple applicable projection bounds we pick one (for
2+
// backwards compatibility reasons).
3+
4+
// check-pass
5+
use std::ops::Mul;
6+
7+
trait A {
8+
type V;
9+
type U: Mul<Self::V, Output = ()> + Mul<(), Output = ()>;
10+
}
11+
12+
fn g<T: A<V = ()>>() {
13+
let y: <T::U as Mul<()>>::Output = ();
14+
}
15+
16+
fn main() {}

0 commit comments

Comments
 (0)