Print opaque types from type aliases via their path
This commit is contained in:
parent
7546163335
commit
c93f571c2a
44 changed files with 153 additions and 77 deletions
|
@ -644,18 +644,23 @@ pub trait PrettyPrinter<'tcx>:
|
|||
return Ok(self);
|
||||
}
|
||||
|
||||
let def_key = self.tcx().def_key(def_id);
|
||||
if let Some(name) = def_key.disambiguated_data.data.get_opt_name() {
|
||||
p!(write("{}", name));
|
||||
// FIXME(eddyb) print this with `print_def_path`.
|
||||
if !substs.is_empty() {
|
||||
p!("::");
|
||||
p!(generic_delimiters(|cx| cx.comma_sep(substs.iter())));
|
||||
let parent = self.tcx().parent(def_id).expect("opaque types always have a parent");
|
||||
match self.tcx().def_kind(parent) {
|
||||
DefKind::TyAlias | DefKind::AssocTy => {
|
||||
if let ty::Opaque(d, _) = *self.tcx().type_of(parent).kind() {
|
||||
if d == def_id {
|
||||
// If the type alias directly starts with the `impl` of the
|
||||
// opaque type we're printing, then skip the `::{opaque#1}`.
|
||||
p!(print_def_path(parent, substs));
|
||||
return Ok(self);
|
||||
}
|
||||
}
|
||||
// Complex opaque type, e.g. `type Foo = (i32, impl Debug);`
|
||||
p!(print_def_path(def_id, substs));
|
||||
return Ok(self);
|
||||
}
|
||||
return Ok(self);
|
||||
_ => return self.pretty_print_opaque_impl_type(def_id, substs),
|
||||
}
|
||||
|
||||
return self.pretty_print_opaque_impl_type(def_id, substs);
|
||||
}
|
||||
ty::Str => p!("str"),
|
||||
ty::Generator(did, substs, movability) => {
|
||||
|
@ -898,15 +903,6 @@ pub trait PrettyPrinter<'tcx>:
|
|||
if !first {
|
||||
p!(", ");
|
||||
}
|
||||
if let GenericArgKind::Type(ty) = ty.unpack() {
|
||||
if let ty::Opaque(d, substs) = *ty.kind() {
|
||||
if d == def_id {
|
||||
p!(print_def_path(d, substs));
|
||||
first = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
p!(print(trait_ref.rebind(*ty)));
|
||||
first = false;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ error[E0277]: the trait bound `String: Copy` is not satisfied
|
|||
LL | Box::new(AssocNoCopy)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
|
||||
|
|
||||
= note: required for the cast to the object type `dyn Bar<Assoc = impl Copy>`
|
||||
= note: required for the cast to the object type `dyn Bar<Assoc = <AssocNoCopy as Thing>::Out::{opaque#0}>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ impl<T: Send> AnotherTrait for T {}
|
|||
// (We treat opaque types as "foreign types" that could grow more impls
|
||||
// in the future.)
|
||||
impl AnotherTrait for D<OpaqueType> {
|
||||
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<impl OpaqueTrait>`
|
||||
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<impl OpaqueTrait>`
|
||||
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
|
||||
--> $DIR/auto-trait.rs:21:1
|
||||
|
|
||||
LL | impl<T: Send> AnotherTrait for T {}
|
||||
| -------------------------------- first implementation here
|
||||
...
|
||||
LL | impl AnotherTrait for D<OpaqueType> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<impl OpaqueTrait>`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ impl<T: std::fmt::Debug> AnotherTrait for T {}
|
|||
|
||||
// This is in error, because we cannot assume that `OpaqueType: !Debug`
|
||||
impl AnotherTrait for D<OpaqueType> {
|
||||
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<impl OpaqueTrait>`
|
||||
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<impl OpaqueTrait>`
|
||||
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
|
||||
--> $DIR/negative-reasoning.rs:19:1
|
||||
|
|
||||
LL | impl<T: std::fmt::Debug> AnotherTrait for T {}
|
||||
| ------------------------------------------- first implementation here
|
||||
...
|
||||
LL | impl AnotherTrait for D<OpaqueType> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<impl OpaqueTrait>`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
|
||||
|
|
||||
= note: upstream crates may add a new impl of trait `std::fmt::Debug` for type `impl OpaqueTrait` in future versions
|
||||
= note: upstream crates may add a new impl of trait `std::fmt::Debug` for type `OpaqueType` in future versions
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ pub struct A<T: Foo> {
|
|||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn lint_me() -> A<()>; //~ ERROR: uses type `impl Baz`
|
||||
pub fn lint_me() -> A<()>; //~ ERROR: uses type `Qux`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: `extern` block uses type `impl Baz`, which is not FFI-safe
|
||||
error: `extern` block uses type `Qux`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes-73249-2.rs:26:25
|
||||
|
|
||||
LL | pub fn lint_me() -> A<()>;
|
||||
|
|
|
@ -17,7 +17,7 @@ pub struct A {
|
|||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn lint_me() -> A; //~ ERROR: uses type `impl Baz`
|
||||
pub fn lint_me() -> A; //~ ERROR: uses type `Qux`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: `extern` block uses type `impl Baz`, which is not FFI-safe
|
||||
error: `extern` block uses type `Qux`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes-73249-3.rs:20:25
|
||||
|
|
||||
LL | pub fn lint_me() -> A;
|
||||
|
|
|
@ -17,7 +17,7 @@ pub struct A {
|
|||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn lint_me() -> A; //~ ERROR: uses type `impl Baz`
|
||||
pub fn lint_me() -> A; //~ ERROR: uses type `Qux`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: `extern` block uses type `impl Baz`, which is not FFI-safe
|
||||
error: `extern` block uses type `Qux`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes-73249-5.rs:20:25
|
||||
|
|
||||
LL | pub fn lint_me() -> A;
|
||||
|
|
|
@ -20,7 +20,7 @@ fn assign() -> Qux {
|
|||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn lint_me() -> <u32 as Foo>::Assoc; //~ ERROR: uses type `impl Baz`
|
||||
pub fn lint_me() -> <u32 as Foo>::Assoc; //~ ERROR: uses type `Qux`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: `extern` block uses type `impl Baz`, which is not FFI-safe
|
||||
error: `extern` block uses type `Qux`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes-73251-1.rs:23:25
|
||||
|
|
||||
LL | pub fn lint_me() -> <u32 as Foo>::Assoc;
|
||||
|
|
|
@ -33,7 +33,7 @@ fn use_of_b() -> AliasB {
|
|||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn lint_me() -> <AliasB as TraitB>::Assoc; //~ ERROR: uses type `impl TraitA<Assoc = u32>`
|
||||
pub fn lint_me() -> <AliasB as TraitB>::Assoc; //~ ERROR: uses type `AliasA`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: `extern` block uses type `impl TraitA<Assoc = u32>`, which is not FFI-safe
|
||||
error: `extern` block uses type `AliasA`, which is not FFI-safe
|
||||
--> $DIR/lint-ctypes-73251-2.rs:36:25
|
||||
|
|
||||
LL | pub fn lint_me() -> <AliasB as TraitB>::Assoc;
|
||||
|
|
|
@ -9,7 +9,7 @@ pub fn ret_closure() -> A {
|
|||
|
||||
extern "C" {
|
||||
pub fn a(_: A);
|
||||
//~^ ERROR `extern` block uses type `impl Fn()`, which is not FFI-safe [improper_ctypes]
|
||||
//~^ ERROR `extern` block uses type `A`, which is not FFI-safe [improper_ctypes]
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: `extern` block uses type `impl Fn()`, which is not FFI-safe
|
||||
error: `extern` block uses type `A`, which is not FFI-safe
|
||||
--> $DIR/opaque-ty-ffi-unsafe.rs:11:17
|
||||
|
|
||||
LL | pub fn a(_: A);
|
||||
|
|
|
@ -8,6 +8,6 @@ fn mk_opaque() -> OpaqueType {
|
|||
trait AnotherTrait {}
|
||||
impl<T: Send> AnotherTrait for T {}
|
||||
impl AnotherTrait for OpaqueType {}
|
||||
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `impl OpaqueTrait`
|
||||
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `OpaqueType`
|
||||
//~| ERROR cannot implement trait on type alias impl trait
|
||||
fn main() {}
|
||||
|
|
|
@ -10,13 +10,13 @@ note: type alias impl trait defined here
|
|||
LL | type OpaqueType = impl OpaqueTrait;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `impl OpaqueTrait`
|
||||
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `OpaqueType`
|
||||
--> $DIR/issue-83613.rs:10:1
|
||||
|
|
||||
LL | impl<T: Send> AnotherTrait for T {}
|
||||
| -------------------------------- first implementation here
|
||||
LL | impl AnotherTrait for OpaqueType {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `impl OpaqueTrait`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `OpaqueType`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -2,15 +2,15 @@ error[E0277]: `Rc<u32>` cannot be sent between threads safely
|
|||
--> $DIR/auto-trait-leakage2.rs:17:13
|
||||
|
|
||||
LL | type Foo = impl std::fmt::Debug;
|
||||
| -------------------- within this `impl Debug`
|
||||
| -------------------- within this `Foo`
|
||||
...
|
||||
LL | is_send(m::foo());
|
||||
| ------- ^^^^^^^^ `Rc<u32>` cannot be sent between threads safely
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
= help: within `impl Debug`, the trait `Send` is not implemented for `Rc<u32>`
|
||||
= note: required because it appears within the type `impl Debug`
|
||||
= help: within `Foo`, the trait `Send` is not implemented for `Rc<u32>`
|
||||
= note: required because it appears within the type `Foo`
|
||||
note: required by a bound in `is_send`
|
||||
--> $DIR/auto-trait-leakage2.rs:14:15
|
||||
|
|
||||
|
|
|
@ -15,7 +15,7 @@ LL | pub type Boo = impl ::std::fmt::Debug;
|
|||
LL | ""
|
||||
| ^^ expected opaque type, found `&str`
|
||||
|
|
||||
= note: expected opaque type `impl Debug`
|
||||
= note: expected opaque type `Boo`
|
||||
found reference `&str`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
|
@ -25,7 +25,7 @@ LL | type Closure = impl FnOnce();
|
|||
LL | || -> Closure { || () }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found closure
|
||||
|
|
||||
= note: expected opaque type `impl FnOnce()`
|
||||
= note: expected opaque type `Closure`
|
||||
found closure `[closure@$DIR/issue-63279.rs:8:5: 8:28]`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
|
|
@ -7,7 +7,7 @@ LL | type Test = impl Copy;
|
|||
LL | 7
|
||||
| ^ expected `()`, found integer
|
||||
|
|
||||
= note: expected opaque type `impl Copy`
|
||||
= note: expected opaque type `Test`
|
||||
found type `{integer}`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
|
@ -5,7 +5,7 @@ LL | fn test() -> Pointer<_> {
|
|||
| --------^-
|
||||
| | |
|
||||
| | not allowed in type signatures
|
||||
| help: replace with the correct return type: `impl Deref<Target = i32>`
|
||||
| help: replace with the correct return type: `Pointer<i32>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ LL | fn g<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A
|
|||
LL | (a, b)
|
||||
| ^ expected type parameter `A`, found type parameter `B`
|
||||
|
|
||||
= note: expected opaque type `impl ToString`
|
||||
= note: expected opaque type `X<A, B>`
|
||||
found type parameter `B`
|
||||
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
|
||||
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
|
||||
|
|
|
@ -12,7 +12,7 @@ impl Foo<()> for () { }
|
|||
fn foo() -> impl Foo<FooX> {
|
||||
// FIXME(type-alias-impl-trait): We could probably make this work.
|
||||
()
|
||||
//~^ ERROR: the trait bound `(): Foo<impl Debug>` is not satisfied
|
||||
//~^ ERROR: the trait bound `(): Foo<FooX>` is not satisfied
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error[E0277]: the trait bound `(): Foo<impl Debug>` is not satisfied
|
||||
error[E0277]: the trait bound `(): Foo<FooX>` is not satisfied
|
||||
--> $DIR/nested-tait-inference.rs:14:5
|
||||
|
|
||||
LL | ()
|
||||
| ^^ the trait `Foo<impl Debug>` is not implemented for `()`
|
||||
| ^^ the trait `Foo<FooX>` is not implemented for `()`
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
<() as Foo<()>>
|
||||
|
|
|
@ -12,7 +12,7 @@ impl Foo<u32> for () {}
|
|||
|
||||
fn foo() -> impl Foo<FooX> {
|
||||
()
|
||||
//~^ ERROR: the trait bound `(): Foo<impl Debug>` is not satisfied
|
||||
//~^ ERROR: the trait bound `(): Foo<FooX>` is not satisfied
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error[E0277]: the trait bound `(): Foo<impl Debug>` is not satisfied
|
||||
error[E0277]: the trait bound `(): Foo<FooX>` is not satisfied
|
||||
--> $DIR/nested-tait-inference2.rs:14:5
|
||||
|
|
||||
LL | ()
|
||||
| ^^ the trait `Foo<impl Debug>` is not implemented for `()`
|
||||
| ^^ the trait `Foo<FooX>` is not implemented for `()`
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
<() as Foo<()>>
|
||||
|
|
|
@ -13,5 +13,5 @@ fn bar() -> Bar {
|
|||
|
||||
fn main() {
|
||||
println!("{:?}", bar());
|
||||
//~^ ERROR `impl Trait<impl Debug>` doesn't implement `Debug`
|
||||
//~^ ERROR `Bar` doesn't implement `Debug`
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0277]: `impl Trait<impl Debug>` doesn't implement `Debug`
|
||||
error[E0277]: `Bar` doesn't implement `Debug`
|
||||
--> $DIR/nested.rs:15:22
|
||||
|
|
||||
LL | println!("{:?}", bar());
|
||||
| ^^^^^ `impl Trait<impl Debug>` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
||||
| ^^^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
||||
|
|
||||
= help: the trait `Debug` is not implemented for `impl Trait<impl Debug>`
|
||||
= help: the trait `Debug` is not implemented for `Bar`
|
||||
= 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
|
||||
|
|
|
@ -8,7 +8,7 @@ LL | let _: &str = bomp();
|
|||
| ^^^^^^ expected `&str`, found opaque type
|
||||
|
|
||||
= note: expected reference `&str`
|
||||
found opaque type `impl Debug`
|
||||
found opaque type `Boo`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/no_revealing_outside_defining_module.rs:19:5
|
||||
|
@ -19,7 +19,7 @@ LL | pub type Boo = impl ::std::fmt::Debug;
|
|||
LL | ""
|
||||
| ^^ expected opaque type, found `&str`
|
||||
|
|
||||
= note: expected opaque type `impl Debug`
|
||||
= note: expected opaque type `Boo`
|
||||
found reference `&str`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
|
@ -4,7 +4,7 @@ type Foo = impl std::fmt::Debug;
|
|||
type Bar = impl PartialEq<Foo>;
|
||||
|
||||
fn bar() -> Bar {
|
||||
42_i32 //~ ERROR can't compare `i32` with `impl Debug`
|
||||
42_i32 //~ ERROR can't compare `i32` with `Foo`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0277]: can't compare `i32` with `impl Debug`
|
||||
error[E0277]: can't compare `i32` with `Foo`
|
||||
--> $DIR/self-referential-2.rs:7:5
|
||||
|
|
||||
LL | 42_i32
|
||||
| ^^^^^^ no implementation for `i32 == impl Debug`
|
||||
| ^^^^^^ no implementation for `i32 == Foo`
|
||||
|
|
||||
= help: the trait `PartialEq<impl Debug>` is not implemented for `i32`
|
||||
= help: the trait `PartialEq<Foo>` is not implemented for `i32`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
25
src/test/ui/type-alias-impl-trait/self-referential-4.rs
Normal file
25
src/test/ui/type-alias-impl-trait/self-referential-4.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
type Bar<'a, 'b> = impl PartialEq<Bar<'b, 'static>> + std::fmt::Debug;
|
||||
|
||||
fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> {
|
||||
i //~ ERROR can't compare `&i32` with `Bar<'b, 'static>`
|
||||
}
|
||||
|
||||
type Foo<'a, 'b> = impl PartialEq<Foo<'static, 'b>> + std::fmt::Debug;
|
||||
|
||||
fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> {
|
||||
i //~ ERROR can't compare `&i32` with `Foo<'static, 'b>`
|
||||
}
|
||||
|
||||
type Moo<'a, 'b> = impl PartialEq<Moo<'static, 'a>> + std::fmt::Debug;
|
||||
|
||||
fn moo<'a, 'b>(i: &'a i32) -> Moo<'a, 'b> {
|
||||
i //~ ERROR can't compare `&i32` with `Moo<'static, 'a>`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let meh = 42;
|
||||
let muh = 69;
|
||||
assert_eq!(bar(&meh), bar(&meh));
|
||||
}
|
27
src/test/ui/type-alias-impl-trait/self-referential-4.stderr
Normal file
27
src/test/ui/type-alias-impl-trait/self-referential-4.stderr
Normal file
|
@ -0,0 +1,27 @@
|
|||
error[E0277]: can't compare `&i32` with `Bar<'b, 'static>`
|
||||
--> $DIR/self-referential-4.rs:6:5
|
||||
|
|
||||
LL | i
|
||||
| ^ no implementation for `&i32 == Bar<'b, 'static>`
|
||||
|
|
||||
= help: the trait `PartialEq<Bar<'b, 'static>>` is not implemented for `&i32`
|
||||
|
||||
error[E0277]: can't compare `&i32` with `Foo<'static, 'b>`
|
||||
--> $DIR/self-referential-4.rs:12:5
|
||||
|
|
||||
LL | i
|
||||
| ^ no implementation for `&i32 == Foo<'static, 'b>`
|
||||
|
|
||||
= help: the trait `PartialEq<Foo<'static, 'b>>` is not implemented for `&i32`
|
||||
|
||||
error[E0277]: can't compare `&i32` with `Moo<'static, 'a>`
|
||||
--> $DIR/self-referential-4.rs:18:5
|
||||
|
|
||||
LL | i
|
||||
| ^ no implementation for `&i32 == Moo<'static, 'a>`
|
||||
|
|
||||
= help: the trait `PartialEq<Moo<'static, 'a>>` is not implemented for `&i32`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
|
@ -3,7 +3,19 @@
|
|||
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<Bar<'a, 'b>
|
||||
i //~ ERROR can't compare `&i32` with `Bar<'b, 'a>`
|
||||
}
|
||||
|
||||
type Foo<'a, 'b> = (i32, impl PartialEq<Foo<'a, 'b>> + std::fmt::Debug);
|
||||
|
||||
fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> {
|
||||
(42, i) //~ ERROR can't compare `&i32` with `(i32, &i32)`
|
||||
}
|
||||
|
||||
type Moo<'a, 'b> = (i32, impl PartialEq<Moo<'b, 'a>> + std::fmt::Debug);
|
||||
|
||||
fn moo<'a, 'b>(i: &'a i32) -> Moo<'a, 'b> {
|
||||
(42, i) //~ ERROR can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,11 +1,27 @@
|
|||
error[E0277]: can't compare `&i32` with `impl PartialEq<Bar<'a, 'b>::{opaque#0}> + Debug`
|
||||
error[E0277]: can't compare `&i32` with `Bar<'b, 'a>`
|
||||
--> $DIR/self-referential.rs:6:5
|
||||
|
|
||||
LL | i
|
||||
| ^ no implementation for `&i32 == impl PartialEq<Bar<'a, 'b>::{opaque#0}> + Debug`
|
||||
| ^ no implementation for `&i32 == Bar<'b, 'a>`
|
||||
|
|
||||
= help: the trait `PartialEq<impl PartialEq<Bar<'a, 'b>::{opaque#0}> + Debug>` is not implemented for `&i32`
|
||||
= help: the trait `PartialEq<Bar<'b, 'a>>` is not implemented for `&i32`
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0277]: can't compare `&i32` with `(i32, &i32)`
|
||||
--> $DIR/self-referential.rs:12:10
|
||||
|
|
||||
LL | (42, i)
|
||||
| ^ no implementation for `&i32 == (i32, &i32)`
|
||||
|
|
||||
= help: the trait `PartialEq<(i32, &i32)>` is not implemented for `&i32`
|
||||
|
||||
error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})`
|
||||
--> $DIR/self-referential.rs:18:10
|
||||
|
|
||||
LL | (42, i)
|
||||
| ^ no implementation for `&i32 == (i32, Moo<'b, 'a>::{opaque#0})`
|
||||
|
|
||||
= help: the trait `PartialEq<(i32, Moo<'b, 'a>::{opaque#0})>` is not implemented for `&i32`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
@ -13,7 +13,7 @@ const LEAK_FREE: Bar = leak_free();
|
|||
fn leak_free_test() {
|
||||
match LEAK_FREE {
|
||||
LEAK_FREE => (),
|
||||
//~^ `impl Send` cannot be used in patterns
|
||||
//~^ `Bar` cannot be used in patterns
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: `impl Send` cannot be used in patterns
|
||||
error: `Bar` cannot be used in patterns
|
||||
--> $DIR/structural-match-no-leak.rs:15:9
|
||||
|
|
||||
LL | LEAK_FREE => (),
|
||||
|
|
|
@ -14,7 +14,7 @@ const VALUE: Foo = value();
|
|||
fn test() {
|
||||
match VALUE {
|
||||
VALUE => (),
|
||||
//~^ `impl Send` cannot be used in patterns
|
||||
//~^ `Foo` cannot be used in patterns
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: `impl Send` cannot be used in patterns
|
||||
error: `Foo` cannot be used in patterns
|
||||
--> $DIR/structural-match.rs:16:9
|
||||
|
|
||||
LL | VALUE => (),
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0382]: use of moved value: `x`
|
|||
--> $DIR/type_of_a_let.rs:16:16
|
||||
|
|
||||
LL | let x: Foo = 22_u32;
|
||||
| - move occurs because `x` has type `impl Debug`, which does not implement the `Copy` trait
|
||||
| - move occurs because `x` has type `Foo`, which does not implement the `Copy` trait
|
||||
LL | let y: Foo = x;
|
||||
| - value moved here
|
||||
LL | same_type((x, y));
|
||||
|
@ -12,7 +12,7 @@ error[E0382]: use of moved value: `y`
|
|||
--> $DIR/type_of_a_let.rs:17:5
|
||||
|
|
||||
LL | let y: Foo = x;
|
||||
| - move occurs because `y` has type `impl Debug`, which does not implement the `Copy` trait
|
||||
| - move occurs because `y` has type `Foo`, which does not implement the `Copy` trait
|
||||
LL | same_type((x, y));
|
||||
| - value moved here
|
||||
LL | y
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue