Rollup merge of #111991 - BoxyUwU:change_error_term_display, r=compiler-errors

Change ty and const error's pretty printing to be in braces

`[const error]` and `[type error]` are slightly confusing since they look like either a slice with an error type for the element ty or a slice with a const argument as the type ???. This PR changes them to display as `{const error}` and `{type error}`  similar to `{integer}`.

This does not update the `Debug` impls for them which is done in #111988.

I updated some error logic to avoid printing the substs of trait refs when unable to resolve an assoc item for them, this avoids emitting errors with `{type error}` in them. The substs are not relevant for these errors since we don't take into account the substs when resolving the assoc item.

r? ``@compiler-errors``
This commit is contained in:
Matthias Krüger 2023-05-27 00:24:01 +02:00 committed by GitHub
commit a99209738e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 11 deletions

View File

@ -1159,7 +1159,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
// those that do.
self.one_bound_for_assoc_type(
|| traits::supertraits(tcx, trait_ref),
trait_ref.print_only_trait_path(),
trait_ref.skip_binder().print_only_trait_name(),
binding.item_name,
path_span,
match binding.kind {

View File

@ -700,7 +700,7 @@ pub trait PrettyPrinter<'tcx>:
if verbose { p!(write("{:?}", infer_ty)) } else { p!(write("{}", infer_ty)) }
}
}
ty::Error(_) => p!("[type error]"),
ty::Error(_) => p!("{{type error}}"),
ty::Param(ref param_ty) => p!(print(param_ty)),
ty::Bound(debruijn, bound_ty) => match bound_ty.kind {
ty::BoundTyKind::Anon => debug_bound_var(&mut self, debruijn, bound_ty.var)?,
@ -1379,8 +1379,8 @@ pub trait PrettyPrinter<'tcx>:
},
// FIXME(generic_const_exprs):
// write out some legible representation of an abstract const?
ty::ConstKind::Expr(_) => p!("[const expr]"),
ty::ConstKind::Error(_) => p!("[const error]"),
ty::ConstKind::Expr(_) => p!("{{const expr}}"),
ty::ConstKind::Error(_) => p!("{{const error}}"),
};
Ok(self)
}

View File

@ -4,8 +4,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^
|
= note: source type: `[[u32; H+1]; W]` (generic size [const expr])
= note: target type: `[[u32; W+1]; H]` (generic size [const expr])
= note: source type: `[[u32; H+1]; W]` (generic size {const expr})
= note: target type: `[[u32; W+1]; H]` (generic size {const expr})
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:16:5
@ -34,8 +34,8 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-
LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^
|
= note: source type: `[[u32; H]; W]` (generic size [const expr])
= note: target type: `[u32; W * H * H]` (generic size [const expr])
= note: source type: `[[u32; H]; W]` (generic size {const expr})
= note: target type: `[u32; W * H * H]` (generic size {const expr})
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:30:5

View File

@ -2,7 +2,7 @@
trait One<A> { fn foo(&self) -> A; }
fn foo(_: &dyn One()) //~ ERROR associated type `Output` not found for `One<()>`
fn foo(_: &dyn One()) //~ ERROR associated type `Output` not found for `One`
{}
fn main() { }

View File

@ -1,4 +1,4 @@
error[E0220]: associated type `Output` not found for `One<()>`
error[E0220]: associated type `Output` not found for `One`
--> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs:5:16
|
LL | fn foo(_: &dyn One())

View File

@ -12,7 +12,7 @@ note: trait defined here, with 3 generic parameters: `A`, `B`, `C`
LL | trait Three<A,B,C> { fn dummy(&self) -> (A,B,C); }
| ^^^^^ - - -
error[E0220]: associated type `Output` not found for `Three<(), [type error], [type error]>`
error[E0220]: associated type `Output` not found for `Three`
--> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:16
|
LL | fn foo(_: &dyn Three())