Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some new tests with amusing diagnostics
- Loading branch information
Showing
9 changed files
with
91 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#![feature(type_alias_impl_trait)] | ||
|
||
type Foo = impl std::fmt::Debug; | ||
type Bar = impl Trait<Foo>; | ||
|
||
trait Trait<T> {} | ||
|
||
impl<T, U> Trait<T> for U {} | ||
|
||
fn bar() -> Bar { | ||
42 | ||
} | ||
|
||
fn main() { | ||
println!("{:?}", bar()); | ||
//~^ ERROR `impl Trait<Opaque(DefId(0:4 ~ nested[14f6]::Foo::{opaque#0}), [])>` doesn't implement `Debug` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0277]: `impl Trait<Opaque(DefId(0:4 ~ nested[14f6]::Foo::{opaque#0}), [])>` doesn't implement `Debug` | ||
--> $DIR/nested.rs:15:22 | ||
| | ||
LL | println!("{:?}", bar()); | ||
| ^^^^^ `impl Trait<Opaque(DefId(0:4 ~ nested[14f6]::Foo::{opaque#0}), [])>` cannot be formatted using `{:?}` because it doesn't implement `Debug` | ||
| | ||
= help: the trait `Debug` is not implemented for `impl Trait<Opaque(DefId(0:4 ~ nested[14f6]::Foo::{opaque#0}), [])>` | ||
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#![feature(type_alias_impl_trait)] | ||
|
||
type Foo = impl std::fmt::Debug; | ||
type Bar = impl PartialEq<Foo>; | ||
|
||
fn bar() -> Bar { | ||
42_i32 //~ ERROR can't compare `i32` with `impl Debug` | ||
} | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
src/test/ui/type-alias-impl-trait/self-referential-2.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0277]: can't compare `i32` with `impl Debug` | ||
--> $DIR/self-referential-2.rs:7:5 | ||
| | ||
LL | 42_i32 | ||
| ^^^^^^ no implementation for `i32 == impl Debug` | ||
| | ||
= help: the trait `PartialEq<impl Debug>` is not implemented for `i32` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// run-pass | ||
#![feature(type_alias_impl_trait)] | ||
|
||
type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + std::fmt::Debug; | ||
|
||
fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { | ||
i | ||
} | ||
|
||
fn main() { | ||
let meh = 42; | ||
let muh = 42; | ||
assert_eq!(bar(&meh), bar(&muh)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![feature(type_alias_impl_trait)] | ||
|
||
type Bar<'a, 'b> = impl PartialEq<Bar<'b, 'a>> + std::fmt::Debug; | ||
|
||
fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { | ||
i //~ ERROR can't compare `&i32` with `impl PartialEq<Opaque | ||
} | ||
|
||
fn main() { | ||
let meh = 42; | ||
let muh = 69; | ||
assert_eq!(bar(&meh), bar(&meh)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0277]: can't compare `&i32` with `impl PartialEq<Opaque(DefId(0:6 ~ self_referential[5b7d]::Bar::{opaque#0}), [ReFree(DefId(0:7 ~ self_referential[5b7d]::bar), BrNamed(DefId(0:8 ~ self_referential[5b7d]::bar::'a), 'a)), ReEarlyBound(0, 'b)])> + Debug` | ||
--> $DIR/self-referential.rs:6:5 | ||
| | ||
LL | i | ||
| ^ no implementation for `&i32 == impl PartialEq<Opaque(DefId(0:6 ~ self_referential[5b7d]::Bar::{opaque#0}), [ReFree(DefId(0:7 ~ self_referential[5b7d]::bar), BrNamed(DefId(0:8 ~ self_referential[5b7d]::bar::'a), 'a)), ReEarlyBound(0, 'b)])> + Debug` | ||
| | ||
= help: the trait `PartialEq<impl PartialEq<Opaque(DefId(0:6 ~ self_referential[5b7d]::Bar::{opaque#0}), [ReFree(DefId(0:7 ~ self_referential[5b7d]::bar), BrNamed(DefId(0:8 ~ self_referential[5b7d]::bar::'a), 'a)), ReEarlyBound(0, 'b)])> + Debug>` is not implemented for `&i32` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |