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

Type alias impl trait resolves to different concrete types #113619

Closed
mikialex opened this issue Jul 12, 2023 · 1 comment · Fixed by #113636
Closed

Type alias impl trait resolves to different concrete types #113619

mikialex opened this issue Jul 12, 2023 · 1 comment · Fixed by #113636
Labels
A-type-system Area: Type system C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness requires-nightly This issue requires a nightly compiler in some way. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@mikialex
Copy link

I tried this code:

#![feature(type_alias_impl_trait)]

trait Test {}

struct A;

impl Test for A {}

struct B<T> {
  inner: T,
}

impl<T: Test> Test for B<T> {}

type TestImpl = impl Test;
fn test() -> TestImpl {
  A
}

fn make_option() -> Option<TestImpl> {
  Some(test())
}

fn make_option2() -> Option<TestImpl> {
  let inner = make_option().unwrap();

  B { inner }.into()
}

I expected to see this happen: compile error that said the make_option2 return type is wrong.

Instead, this happened: compiled without error

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (37998ab50 2023-06-11)
binary: rustc
commit-hash: 37998ab508d5d9fa0d465d7b535dc673087dda8f
commit-date: 2023-06-11
host: x86_64-pc-windows-msvc
release: 1.72.0-nightly
LLVM version: 16.0.5
@mikialex mikialex added the C-bug Category: This is a bug. label Jul 12, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 12, 2023
@BoxyUwU BoxyUwU added A-type-system Area: Type system I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` T-types Relevant to the types team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 12, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jul 12, 2023
@BoxyUwU BoxyUwU removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jul 12, 2023
@BoxyUwU
Copy link
Member

BoxyUwU commented Jul 12, 2023

cc @oli-obk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness requires-nightly This issue requires a nightly compiler in some way. T-types Relevant to the types team, which will review and decide on the PR/issue.
Development

Successfully merging a pull request may close this issue.

4 participants