Skip to content

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

Closed
@Nemo157

Description

@Nemo157

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions