-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-coherenceArea: CoherenceArea: CoherenceA-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityHigh priorityS-triggers-future-incompat-lintStatus: This bug triggers a future-incompatibility lintStatus: This bug triggers a future-incompatibility lintT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
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
| ty::Alias(ty::Projection | ty::Inherent | ty::Weak, ..) => { | |
self.found_non_local_ty(ty) | |
} |
but do not consider them to be parameters when checking for uncovered types
} else if let ty::Param(_) = input_ty.kind() { |
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
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-coherenceArea: CoherenceArea: CoherenceA-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityHigh priorityS-triggers-future-incompat-lintStatus: This bug triggers a future-incompatibility lintStatus: This bug triggers a future-incompatibility lintT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Type
Projects
Status
future compat lint