1
Fork 0

Add infrastructure #[rustc_confusables] attribute to allow targeted

"no method" errors on standard library types

The standard library developer can annotate methods on e.g.
`BTreeSet::push` with `#[rustc_confusables("insert")]`. When the user
mistypes `btreeset.push()`, `BTreeSet::insert` will be suggested if
there are no other candidates to suggest.
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2023-07-16 18:18:38 +08:00
parent 00a39cc785
commit 08c77a6eb4
No known key found for this signature in database
GPG key ID: 94F68FD0E4899BB0
12 changed files with 259 additions and 4 deletions

View file

@ -625,6 +625,12 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
ErrorFollowing,
INTERNAL_UNSTABLE
),
rustc_attr!(
rustc_confusables, Normal,
template!(List: r#""name1", "name2", ..."#),
ErrorFollowing,
INTERNAL_UNSTABLE,
),
// Enumerates "identity-like" conversion methods to suggest on type mismatch.
rustc_attr!(
rustc_conversion_suggestion, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE