Open
Description
We consider projections to be foreign types during orphan check
rust/compiler/rustc_trait_selection/src/traits/coherence.rs
Lines 780 to 782 in 7ed044c
but do not consider them to be parameters when checking for uncovered types
This is more obvious after #99552
this means that the following impl passes the orphan check even though it shouldn't
// crate a
pub trait Foreign<T, U> {
type Assoc;
}
// crate b
use a::Foreign;
trait Id {
type Assoc;
}
impl<T> Id for T {
type Assoc = T;
}
pub struct B;
impl<T> Foreign<B, T> for <T as Id>::Assoc {
type Assoc = usize;
}
The impl in b
overlaps with an impl impl<U> Foreign<T, LocalTy> for LocalTy
in another crate c
which passes the orphan check.
While I wasn't able to cause runtime UB with this, I was able to get an ICE during codegen_fulfill_obligation
: https://github.com/lcnr/orphan-check-ub
cc @rust-lang/types
Metadata
Metadata
Assignees
Labels
Area: Associated items (types, constants & functions)Area: CoherenceArea: Trait systemCategory: This is a bug.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessHigh priorityStatus: This bug triggers a future-incompatibility lintRelevant to the types team, which will review and decide on the PR/issue.
Type
Projects
Status
future compat lint