Improve self-referential diagnostic somewhat
This commit is contained in:
parent
6807d3773d
commit
7546163335
5 changed files with 27 additions and 20 deletions
|
@ -644,20 +644,18 @@ pub trait PrettyPrinter<'tcx>:
|
|||
return Ok(self);
|
||||
}
|
||||
|
||||
return with_no_queries(|| {
|
||||
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())));
|
||||
}
|
||||
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())));
|
||||
}
|
||||
return Ok(self);
|
||||
}
|
||||
|
||||
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) => {
|
||||
|
@ -900,6 +898,15 @@ 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;
|
||||
}
|
||||
|
|
|
@ -13,5 +13,5 @@ fn bar() -> Bar {
|
|||
|
||||
fn main() {
|
||||
println!("{:?}", bar());
|
||||
//~^ ERROR `impl Trait<Opaque(DefId(0:4 ~ nested[14f6]::Foo::{opaque#0}), [])>` doesn't implement `Debug`
|
||||
//~^ ERROR `impl Trait<impl Debug>` doesn't implement `Debug`
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0277]: `impl Trait<Opaque(DefId(0:4 ~ nested[14f6]::Foo::{opaque#0}), [])>` doesn't implement `Debug`
|
||||
error[E0277]: `impl Trait<impl Debug>` 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`
|
||||
| ^^^^^ `impl Trait<impl Debug>` 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}), [])>`
|
||||
= help: the trait `Debug` is not implemented for `impl Trait<impl Debug>`
|
||||
= 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
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
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
|
||||
i //~ ERROR can't compare `&i32` with `impl PartialEq<Bar<'a, 'b>
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
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`
|
||||
error[E0277]: can't compare `&i32` with `impl PartialEq<Bar<'a, 'b>::{opaque#0}> + 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`
|
||||
| ^ no implementation for `&i32 == impl PartialEq<Bar<'a, 'b>::{opaque#0}> + 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`
|
||||
= help: the trait `PartialEq<impl PartialEq<Bar<'a, 'b>::{opaque#0}> + Debug>` is not implemented for `&i32`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue