Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple defining uses of type alias impl trait in single function are not handled #73481

Closed
matthewjasper opened this issue Jun 18, 2020 · 2 comments · Fixed by #86118
Closed
Assignees
Labels
A-impl-trait C-bug F-type_alias_impl_trait I-unsound requires-nightly T-compiler

Comments

@matthewjasper
Copy link
Contributor

matthewjasper commented Jun 18, 2020

I tried this code:

#![feature(type_alias_impl_trait)]

type X<A, B> = impl Into<&'static A>;

fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) {
    (a, a)
}

fn main() {
    println!("{}", <X<_, _> as Into<&String>>::into(f(&[1isize, 2, 3], String::new()).1));
}

I expected to see this happen: compiler error because X<A, B> is unified with A and also X<B, A> is unified with A.

Instead, this happened: program compiles, runs and segfaults.

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (feb3536eb 2020-06-09)
binary: rustc
commit-hash: feb3536eba10c2e4585d066629598f03d5ddc7c6
commit-date: 2020-06-09
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0
@matthewjasper matthewjasper added T-compiler I-unsound A-impl-trait C-bug F-type_alias_impl_trait requires-nightly labels Jun 18, 2020
@matthewjasper matthewjasper self-assigned this Jun 18, 2020
@matthewjasper
Copy link
Contributor Author

matthewjasper commented Jun 18, 2020

Variants on this can cause ICEs and llvm errors instead, as one might expect.

@nikomatsakis
Copy link
Contributor

nikomatsakis commented May 26, 2021

@rustbot assign @spastorino

Santiago is working on the PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait C-bug F-type_alias_impl_trait I-unsound requires-nightly T-compiler
Projects
None yet
3 participants