Skip to content

Add const and static TAIT tests #88349

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

Merged
merged 1 commit into from
Aug 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/test/ui/type-alias-impl-trait/static-const-types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#![feature(type_alias_impl_trait)]
#![allow(dead_code)]

// FIXME: This should compile, but it currently doesn't

use std::fmt::Debug;

type Foo = impl Debug;
//~^ ERROR: could not find defining uses

static FOO1: Foo = 22_u32;
//~^ ERROR: mismatched types [E0308]
const FOO2: Foo = 22_u32;
//~^ ERROR: mismatched types [E0308]

fn main() {}
33 changes: 33 additions & 0 deletions src/test/ui/type-alias-impl-trait/static-const-types.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
error[E0308]: mismatched types
--> $DIR/static-const-types.rs:11:20
|
LL | type Foo = impl Debug;
| ---------- the expected opaque type
...
LL | static FOO1: Foo = 22_u32;
| ^^^^^^ expected opaque type, found `u32`
|
= note: expected opaque type `impl Debug`
found type `u32`

error[E0308]: mismatched types
--> $DIR/static-const-types.rs:13:19
|
LL | type Foo = impl Debug;
| ---------- the expected opaque type
...
LL | const FOO2: Foo = 22_u32;
| ^^^^^^ expected opaque type, found `u32`
|
= note: expected opaque type `impl Debug`
found type `u32`

error: could not find defining uses
--> $DIR/static-const-types.rs:8:12
|
LL | type Foo = impl Debug;
| ^^^^^^^^^^

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0308`.