Skip to content

Commit 43dae69

Browse files
Check def id before calling match_projection_projections
1 parent 0fd5712 commit 43dae69

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

compiler/rustc_trait_selection/src/traits/project.rs

+3
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,9 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>(
793793
let Some(clause) = clause.as_projection_clause() else {
794794
return ControlFlow::Continue(());
795795
};
796+
if clause.projection_def_id() != obligation.predicate.def_id {
797+
return ControlFlow::Continue(());
798+
}
796799

797800
let is_match =
798801
selcx.infcx.probe(|_| selcx.match_projection_projections(obligation, clause, true));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//@ check-pass
2+
3+
#![recursion_limit = "1024"]
4+
// Really high recursion limit ^
5+
6+
// Test that ensures we're filtering projections by def id before matching
7+
// them in `match_projection_projections`.
8+
9+
use std::ops::{Add, Sub};
10+
11+
pub trait Scalar {}
12+
13+
pub trait VectorCommon: Sized {
14+
type T: Scalar;
15+
}
16+
17+
pub trait VectorOpsByValue<Rhs = Self, Output = Self>:
18+
VectorCommon + Add<Rhs, Output = Output> + Sub<Rhs, Output = Output>
19+
{
20+
}
21+
22+
pub trait VectorView<'a>:
23+
VectorOpsByValue<Self, Self::Owned> + VectorOpsByValue<Self::Owned, Self::Owned>
24+
{
25+
type Owned;
26+
}
27+
28+
pub trait Vector: VectorOpsByValue<Self> + for<'a> VectorOpsByValue<Self::View<'a>> {
29+
type View<'a>: VectorView<'a, T = Self::T, Owned = Self>
30+
where
31+
Self: 'a;
32+
}
33+
34+
pub trait MatrixCommon {
35+
type V: Vector;
36+
}
37+
38+
fn main() {}

0 commit comments

Comments
 (0)