Skip to content

Commit 2d22c34

Browse files
w
1 parent 25a615b commit 2d22c34

File tree

4 files changed

+7
-50
lines changed

4 files changed

+7
-50
lines changed

compiler/rustc_errors/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,6 @@ pub enum StashKey {
625625
/// FRU syntax
626626
MaybeFruTypo,
627627
CallAssocMethod,
628-
AssociatedTypeSuggestion,
629628
/// Query cycle detected, stashing in favor of a better error.
630629
Cycle,
631630
UndeterminedMacroResolution,
@@ -983,7 +982,9 @@ impl<'a> DiagCtxtHandle<'a> {
983982
}
984983

985984
pub fn has_stashed_diagnostic(&self, span: Span, key: StashKey) -> bool {
986-
self.inner.borrow().stashed_diagnostics.get(&(span.with_parent(None), key)).is_some()
985+
let inner = self.inner.borrow();
986+
!inner.stashed_diagnostics.is_empty()
987+
&& inner.stashed_diagnostics.get(&(span.with_parent(None), key)).is_some()
987988
}
988989

989990
/// Emit all stashed diagnostics.

compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_ast::TraitObjectSyntax;
22
use rustc_errors::codes::*;
3-
use rustc_errors::{Diag, EmissionGuarantee, ErrorGuaranteed, StashKey, Suggestions};
3+
use rustc_errors::{Diag, EmissionGuarantee, ErrorGuaranteed};
44
use rustc_hir as hir;
55
use rustc_hir::def::{DefKind, Namespace, Res};
66
use rustc_hir::def_id::DefId;
@@ -100,16 +100,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
100100
poly_trait_ref.trait_ref.trait_def_id(),
101101
&mut diag,
102102
);
103-
// In case there is an associated type with the same name
104-
// Add the suggestion to this error
105-
if let Some(mut sugg) =
106-
tcx.dcx().steal_non_err(self_ty.span, StashKey::AssociatedTypeSuggestion)
107-
&& let Suggestions::Enabled(ref mut s1) = diag.suggestions
108-
&& let Suggestions::Enabled(ref mut s2) = sugg.suggestions
109-
{
110-
s1.append(s2);
111-
sugg.cancel();
112-
}
113103
Some(diag.emit())
114104
} else {
115105
tcx.node_span_lint(BARE_TRAIT_OBJECTS, self_ty.hir_id, self_ty.span, |lint| {

compiler/rustc_resolve/src/late.rs

+1-26
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ use rustc_ast::*;
2020
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
2121
use rustc_data_structures::unord::{UnordMap, UnordSet};
2222
use rustc_errors::codes::*;
23-
use rustc_errors::{
24-
Applicability, DiagArgValue, ErrorGuaranteed, IntoDiagArg, StashKey, Suggestions,
25-
};
23+
use rustc_errors::{Applicability, DiagArgValue, ErrorGuaranteed, IntoDiagArg, Suggestions};
2624
use rustc_hir::def::Namespace::{self, *};
2725
use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS};
2826
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId};
@@ -4340,29 +4338,6 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
43404338
finalize,
43414339
) {
43424340
Ok(Some(partial_res)) if let Some(res) = partial_res.full_res() => {
4343-
// if we also have an associated type that matches the ident, stash a suggestion
4344-
if let Some(items) = self.diag_metadata.current_trait_assoc_items
4345-
&& let [Segment { ident, .. }] = path
4346-
&& items.iter().any(|item| {
4347-
if let AssocItemKind::Type(alias) = &item.kind
4348-
&& alias.ident == *ident
4349-
{
4350-
true
4351-
} else {
4352-
false
4353-
}
4354-
})
4355-
{
4356-
let mut diag = self.r.tcx.dcx().struct_allow("");
4357-
diag.span_suggestion_verbose(
4358-
path_span.shrink_to_lo(),
4359-
"there is an associated type with the same name",
4360-
"Self::",
4361-
Applicability::MaybeIncorrect,
4362-
);
4363-
diag.stash(path_span, StashKey::AssociatedTypeSuggestion);
4364-
}
4365-
43664341
if source.is_expected(res) || res == Res::Err {
43674342
partial_res
43684343
} else {

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use rustc_data_structures::fx::FxHashMap;
77
use rustc_data_structures::unord::UnordSet;
88
use rustc_errors::codes::*;
99
use rustc_errors::{
10-
Applicability, Diag, ErrorGuaranteed, Level, MultiSpan, StashKey, StringPart, Suggestions,
11-
pluralize, struct_span_code_err,
10+
Applicability, Diag, ErrorGuaranteed, Level, MultiSpan, StashKey, StringPart, pluralize,
11+
struct_span_code_err,
1212
};
1313
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId};
1414
use rustc_hir::intravisit::Visitor;
@@ -2446,15 +2446,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
24462446
obligation.cause.code(),
24472447
);
24482448
self.suggest_unsized_bound_if_applicable(err, obligation);
2449-
if let Some(span) = err.span.primary_span()
2450-
&& let Some(mut diag) =
2451-
self.dcx().steal_non_err(span, StashKey::AssociatedTypeSuggestion)
2452-
&& let Suggestions::Enabled(ref mut s1) = err.suggestions
2453-
&& let Suggestions::Enabled(ref mut s2) = diag.suggestions
2454-
{
2455-
s1.append(s2);
2456-
diag.cancel()
2457-
}
24582449
}
24592450
}
24602451

0 commit comments

Comments
 (0)