attribute cleanup: rustc_confusables

This commit is contained in:
mejrs
2026-04-14 14:24:26 +02:00
parent dab8d9d106
commit f17ca97749
7 changed files with 20 additions and 38 deletions
@@ -44,9 +44,6 @@ fn finalize(self, _cx: &FinalizeContext<'_, '_, S>) -> Option<AttributeKind> {
return None;
}
Some(AttributeKind::RustcConfusables {
symbols: self.confusables,
first_span: self.first_span.unwrap(),
})
Some(AttributeKind::RustcConfusables { confusables: self.confusables })
}
}
@@ -1331,9 +1331,7 @@ pub enum AttributeKind {
/// Represents `#[rustc_confusables]`.
RustcConfusables {
symbols: ThinVec<Symbol>,
// FIXME(jdonszelmann): remove when target validation code is moved
first_span: Span,
confusables: ThinVec<Symbol>,
},
/// Represents `#[rustc_const_stable]` and `#[rustc_const_unstable]`.
RustcConstStability {
+9 -22
View File
@@ -26,7 +26,7 @@
use rustc_span::edit_distance::{
edit_distance_with_substrings, find_best_match_for_name_with_substrings,
};
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, sym};
use rustc_span::{DUMMY_SP, Ident, Span, Symbol};
use rustc_trait_selection::error_reporting::infer::need_type_info::TypeAnnotationNeeded;
use rustc_trait_selection::infer::InferCtxtExt as _;
use rustc_trait_selection::solve::Goal;
@@ -2591,38 +2591,25 @@ fn is_relevant_kind_for_mode(&self, kind: ty::AssocKind) -> bool {
}
/// Determine if the associated item with the given DefId matches
/// the desired name via a doc alias.
/// the desired name via a doc alias or rustc_confusables
fn matches_by_doc_alias(&self, def_id: DefId) -> bool {
let Some(method) = self.method_name else {
return false;
};
let Some(local_def_id) = def_id.as_local() else {
return false;
};
let hir_id = self.fcx.tcx.local_def_id_to_hir_id(local_def_id);
let attrs = self.fcx.tcx.hir_attrs(hir_id);
if let Some(d) = find_attr!(attrs, Doc(d) => d)
if let Some(d) = find_attr!(self.tcx, def_id, Doc(d) => d)
&& d.aliases.contains_key(&method.name)
{
return true;
}
for attr in attrs {
if attr.has_name(sym::rustc_confusables) {
let Some(confusables) = attr.meta_item_list() else {
continue;
};
// #[rustc_confusables("foo", "bar"))]
for n in confusables {
if let Some(lit) = n.lit()
&& method.name == lit.symbol
{
return true;
}
}
}
if let Some(confusables) =
find_attr!(self.tcx, def_id, RustcConfusables{ confusables } => confusables)
&& confusables.contains(&method.name)
{
return true;
}
false
}
@@ -2276,8 +2276,8 @@ pub(crate) fn confusable_method_name(
for inherent_method in
self.tcx.associated_items(inherent_impl_did).in_definition_order()
{
if let Some(candidates) = find_attr!(self.tcx, inherent_method.def_id, RustcConfusables{symbols, ..} => symbols)
&& candidates.contains(&item_name.name)
if let Some(confusables) = find_attr!(self.tcx, inherent_method.def_id, RustcConfusables{confusables} => confusables)
&& confusables.contains(&item_name.name)
&& inherent_method.is_fn()
{
let args =
+1 -1
View File
@@ -51,7 +51,7 @@ error[E0599]: no method named `push` found for struct `rustc_confusables_across_
--> $DIR/rustc_confusables.rs:17:7
|
LL | x.push();
| ^^^^ method not found in `rustc_confusables_across_crate::BTreeSet`
| ^^^^
|
help: you might have meant to use `insert`
|
@@ -20,7 +20,7 @@ LL | struct S;
| -------- method `baz` not found for this struct
...
LL | s.baz(10);
| ^^^ method not found in `S`
| ^^^
|
help: you might have meant to use `qux`
|
@@ -2,7 +2,7 @@ error[E0599]: no method named `push` found for struct `BTreeSet<T, A>` in the cu
--> $DIR/rustc_confusables_std_cases.rs:6:7
|
LL | x.push(1);
| ^^^^ method not found in `BTreeSet<_>`
| ^^^^
|
help: you might have meant to use `insert`
|
@@ -14,7 +14,7 @@ error[E0599]: no method named `push_back` found for struct `Vec<_>` in the curre
--> $DIR/rustc_confusables_std_cases.rs:9:7
|
LL | x.push_back(1);
| ^^^^^^^^^ method not found in `Vec<_>`
| ^^^^^^^^^
|
help: you might have meant to use `push`
|
@@ -26,7 +26,7 @@ error[E0599]: no method named `push` found for struct `VecDeque<T, A>` in the cu
--> $DIR/rustc_confusables_std_cases.rs:12:7
|
LL | x.push(1);
| ^^^^ method not found in `VecDeque<_>`
| ^^^^
|
note: there's an earlier shadowed binding `x` of type `Vec<_>` that has method `push` available
--> $DIR/rustc_confusables_std_cases.rs:8:9
@@ -104,7 +104,7 @@ error[E0599]: no method named `append` found for struct `String` in the current
--> $DIR/rustc_confusables_std_cases.rs:24:19
|
LL | String::new().append("");
| ^^^^^^ method not found in `String`
| ^^^^^^
|
help: you might have meant to use `push_str`
|
@@ -116,7 +116,7 @@ error[E0599]: no method named `get_line` found for struct `Stdin` in the current
--> $DIR/rustc_confusables_std_cases.rs:28:11
|
LL | stdin.get_line(&mut buffer).unwrap();
| ^^^^^^^^ method not found in `Stdin`
| ^^^^^^^^
|
help: you might have meant to use `read_line`
|