summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_middle/src/ty/diagnostics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_middle/src/ty/diagnostics.rs')
-rw-r--r--compiler/rustc_middle/src/ty/diagnostics.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs
index f03813a45..0094825fc 100644
--- a/compiler/rustc_middle/src/ty/diagnostics.rs
+++ b/compiler/rustc_middle/src/ty/diagnostics.rs
@@ -17,7 +17,7 @@ use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
use rustc_hir::{PredicateOrigin, WherePredicate};
use rustc_span::{BytePos, Span};
-use rustc_type_ir::sty::TyKind::*;
+use rustc_type_ir::TyKind::*;
impl<'tcx> IntoDiagnosticArg for Ty<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
@@ -274,6 +274,8 @@ pub fn suggest_constraining_type_params<'a>(
span,
if span_to_replace.is_some() {
constraint.clone()
+ } else if constraint.starts_with('<') {
+ constraint.to_string()
} else if bound_list_non_empty {
format!(" + {constraint}")
} else {
@@ -482,8 +484,8 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IsSuggestableVisitor<'tcx> {
FnDef(..)
| Closure(..)
| Infer(..)
- | Generator(..)
- | GeneratorWitness(..)
+ | Coroutine(..)
+ | CoroutineWitness(..)
| Bound(_, _)
| Placeholder(_)
| Error(_) => {
@@ -494,7 +496,8 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IsSuggestableVisitor<'tcx> {
let parent = self.tcx.parent(def_id);
let parent_ty = self.tcx.type_of(parent).instantiate_identity();
if let DefKind::TyAlias | DefKind::AssocTy = self.tcx.def_kind(parent)
- && let Alias(Opaque, AliasTy { def_id: parent_opaque_def_id, .. }) = *parent_ty.kind()
+ && let Alias(Opaque, AliasTy { def_id: parent_opaque_def_id, .. }) =
+ *parent_ty.kind()
&& parent_opaque_def_id == def_id
{
// Okay
@@ -566,8 +569,8 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for MakeSuggestableFolder<'tcx> {
// FIXME(compiler-errors): We could replace these with infer, I guess.
Closure(..)
| Infer(..)
- | Generator(..)
- | GeneratorWitness(..)
+ | Coroutine(..)
+ | CoroutineWitness(..)
| Bound(_, _)
| Placeholder(_)
| Error(_) => {
@@ -577,8 +580,10 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for MakeSuggestableFolder<'tcx> {
Alias(Opaque, AliasTy { def_id, .. }) => {
let parent = self.tcx.parent(def_id);
let parent_ty = self.tcx.type_of(parent).instantiate_identity();
- if let hir::def::DefKind::TyAlias | hir::def::DefKind::AssocTy = self.tcx.def_kind(parent)
- && let Alias(Opaque, AliasTy { def_id: parent_opaque_def_id, .. }) = *parent_ty.kind()
+ if let hir::def::DefKind::TyAlias | hir::def::DefKind::AssocTy =
+ self.tcx.def_kind(parent)
+ && let Alias(Opaque, AliasTy { def_id: parent_opaque_def_id, .. }) =
+ *parent_ty.kind()
&& parent_opaque_def_id == def_id
{
t