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

Add argument types tait tests #88332

Merged
merged 1 commit into from
Aug 27, 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
28 changes: 28 additions & 0 deletions src/test/ui/type-alias-impl-trait/argument-types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#![feature(type_alias_impl_trait)]
#![allow(dead_code)]

use std::fmt::Debug;

type Foo = impl Debug;

// FIXME: This should compile, but it currently doesn't
fn foo1(mut x: Foo) {
x = 22_u32;
//~^ ERROR: mismatched types [E0308]
}

fn foo2(mut x: Foo) {
// no constraint on x
}

fn foo3(x: Foo) {
println!("{:?}", x);
}

fn foo_value() -> Foo {
11_u32
}

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

error: aborting due to previous error

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