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

const initializer is not considered a "defining use" for type_alias_impl_trait #77898

Closed
Nemo157 opened this issue Oct 13, 2020 · 5 comments
Closed
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` requires-nightly This issue requires a nightly compiler in some way.

Comments

@Nemo157
Copy link
Member

Nemo157 commented Oct 13, 2020

I tried this code:

#![feature(type_alias_impl_trait)]

pub type Foo = impl std::fmt::Debug;
pub const FOO: Foo = 5usize;

I expected to see this happen: successful compilation

Instead, this happened:

error[E0308]: mismatched types
 --> src/lib.rs:4:22
  |
3 | pub type Foo = impl std::fmt::Debug;
  |                -------------------- the expected opaque type
4 | pub const FOO: Foo = 5usize;
  |                      ^^^^^^ expected opaque type, found `usize`
  |
  = note: expected opaque type `impl Debug`
                    found type `usize`

error: could not find defining uses
 --> src/lib.rs:3:16
  |
3 | pub type Foo = impl std::fmt::Debug;
  |                ^^^^^^^^^^^^^^^^^^^^

Meta

1.49.0-nightly (2020-10-12 8dae8cdcc8fa879cea6a)

@Nemo157 Nemo157 added the C-bug Category: This is a bug. label Oct 13, 2020
@Nemo157
Copy link
Member Author

Nemo157 commented Oct 13, 2020

@rustbot modify labels: +requires-nightly, +A-impl-trait, +F-type_alias_impl_trait

@rustbot rustbot added A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` requires-nightly This issue requires a nightly compiler in some way. labels Oct 13, 2020
@jackh726
Copy link
Contributor

This works now with min_type_alias_impl_trait, but also requires impl_trait_in_bindings

@jackh726 jackh726 added the F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` label Jun 29, 2021
@jplatte
Copy link
Contributor

jplatte commented Aug 17, 2021

min_type_alias_impl_trait has been removed in #87501, what does that mean for this issue?

@jackh726
Copy link
Contributor

This is something we probably want type_alias_impl_trait to do, so this can stay open.

Also, not sure why I said this requires impl_trait_in_bindings...

@jackh726 jackh726 removed the F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` label Aug 17, 2021
@oli-obk
Copy link
Contributor

oli-obk commented Apr 4, 2022

This has been fixed in #94081 which also has tests that pass with it

@oli-obk oli-obk closed this as completed Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` requires-nightly This issue requires a nightly compiler in some way.
Development

No branches or pull requests

5 participants