fix: Infinite recursion while lowering assoc type bounds from supertraits
This commit is contained in:
parent
fa7659d572
commit
99576aa3f7
2 changed files with 58 additions and 1 deletions
|
|
@ -1756,7 +1756,11 @@ fn named_associated_type_shorthand_candidates<'db, R>(
|
|||
db,
|
||||
GenericDefId::TraitId(trait_def_id),
|
||||
PredicateFilter::SelfTrait,
|
||||
|pred| pred == GenericDefId::TraitId(trait_def_id),
|
||||
// We are likely in the midst of lowering generic predicates of `def`.
|
||||
// So, if we allow `pred == def` we might fall into an infinite recursion.
|
||||
// Actually, we have already checked for the case `pred == def` above as we started
|
||||
// with a stack including `trait_id`
|
||||
|pred| pred != def && pred == GenericDefId::TraitId(trait_def_id),
|
||||
)
|
||||
.0
|
||||
.deref()
|
||||
|
|
|
|||
|
|
@ -2439,3 +2439,56 @@ pub fn null_mut<T: PointeeSized + Thin>() -> *mut T {
|
|||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_20484() {
|
||||
check_no_mismatches(
|
||||
r#"
|
||||
struct Eth;
|
||||
|
||||
trait FullBlockBody {
|
||||
type Transaction;
|
||||
}
|
||||
|
||||
impl FullBlockBody for () {
|
||||
type Transaction = ();
|
||||
}
|
||||
|
||||
trait NodePrimitives {
|
||||
type BlockBody;
|
||||
type SignedTx;
|
||||
}
|
||||
|
||||
impl NodePrimitives for () {
|
||||
type BlockBody = ();
|
||||
type SignedTx = ();
|
||||
}
|
||||
|
||||
impl NodePrimitives for Eth {
|
||||
type BlockBody = ();
|
||||
type SignedTx = ();
|
||||
}
|
||||
|
||||
trait FullNodePrimitives
|
||||
where
|
||||
Self: NodePrimitives<BlockBody: FullBlockBody<Transaction = Self::SignedTx>>,
|
||||
{
|
||||
}
|
||||
|
||||
impl<T> FullNodePrimitives for T where
|
||||
T: NodePrimitives<BlockBody: FullBlockBody<Transaction = Self::SignedTx>>,
|
||||
{
|
||||
}
|
||||
|
||||
fn node<N>(_: N)
|
||||
where
|
||||
N: FullNodePrimitives,
|
||||
{
|
||||
}
|
||||
|
||||
fn main() {
|
||||
node(Eth);
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue