Skip to content

Commit 3b4de3d

Browse files
compiler-errorscuviper
authored andcommitted
Check def id before calling match_projection_projections
(cherry picked from commit 43dae69)
1 parent 5d40b80 commit 3b4de3d

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

compiler/rustc_trait_selection/src/traits/project.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,9 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>(
794794
let Some(clause) = clause.as_projection_clause() else {
795795
return ControlFlow::Continue(());
796796
};
797+
if clause.projection_def_id() != obligation.predicate.def_id {
798+
return ControlFlow::Continue(());
799+
}
797800

798801
let is_match =
799802
selcx.infcx.probe(|_| selcx.match_projection_projections(obligation, clause, true));
Lines changed: 38 additions & 0 deletions
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)