-
- Notifications
You must be signed in to change notification settings - Fork 14.3k
Closed
Closed
Copy link
Labels
A-codegenArea: Code generationArea: Code generationC-bugCategory: This is a bug.Category: This is a bug.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-criticalCritical priorityCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-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.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)The Rustc Trait System Refactor Initiative (-Znext-solver)
Description
I tried this code:
trait Mirror { type Assoc: ?Sized; } impl<T: ?Sized> Mirror for T { type Assoc = T; } trait Q: 'static { fn q(&self); } impl Q for i32 { fn q(&self) { println!("i32"); } } impl Q for <dyn Q as Mirror>::Assoc where Self: 'static { fn q(&self) { println!("dyn Q"); } } fn foo<T: Q + ?Sized>(t: &T) { t.q(); } fn main() { foo(&1 as &dyn Q); }I expected it to work. But instead:
Exited with signal 11 (SIGSEGV): segmentation violation This is a manifestation of two bugs:
- Overlap between built-in and user-written impls for
dyn Trait: Trait - Ambiguity was being treated as a hard error in the
impossible_predicatesmethod
Since the new trait solver treats some dyn Trait: Trait overlap as ambiguity (specifically when the responses from the two candidates differ), and we strike methods from the vtable if impossible_predicates returns true, a false positive will lead to a segfault.
Meta
rustc --version --verbose:
rustc 1.89.0-nightly (16d2276fa 2025-05-16) binary: rustc commit-hash: 16d2276fa6fccb0cc239a542d4c3f0eb46f660ec commit-date: 2025-05-16 host: x86_64-unknown-linux-gnu release: 1.89.0-nightly LLVM version: 20.1.4 Metadata
Metadata
Assignees
Labels
A-codegenArea: Code generationArea: Code generationC-bugCategory: This is a bug.Category: This is a bug.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-criticalCritical priorityCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-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.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)The Rustc Trait System Refactor Initiative (-Znext-solver)
Type
Projects
Status
Completed