os-rust/compiler
bors 11da267fdb Auto merge of #112239 - jieyouxu:targeted-no-method-suggestions, r=cjgillot
Add `#[rustc_confusables]` attribute to allow targeted "no method" error suggestions on standard library types

After this PR, 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 PR lays the foundations for contributors to add `rustc_confusables` annotations to standard library types for targeted suggestions, as specified in #59450, or to address cases such as #108437.

### Example

Assume `BTreeSet` is the standard library type:

```
// Standard library definition
#![feature(rustc_attrs)]

struct BTreeSet;

impl BTreeSet {
    #[rustc_confusables("push")]
    fn insert(&self) {}
}

// User code
fn main() {
    let x = BTreeSet {};
    x.push();
}
```

A new suggestion (which has lower precedence than suggestions for misspellings and only is shown when there are no misspellings suggestions) will be added to hint the user maybe they intended to write `x.insert()` instead:

```
error[E0599]: no method named `push` found for struct `BTreeSet` in the current scope
  --> test.rs:12:7
   |
3  | struct BTreeSet;
   | --------------- method `push` not found for this struct
...
12 |     x.push();
   |       ^^^^ method not found in `BTreeSet`
   |
help: you might have meant to use `insert`
   |
12 |     x.insert();
   |       ~~~~~~

error: aborting due to previous error
```
2023-07-16 15:25:03 +00:00
..
rustc fix link 2023-03-11 10:53:47 -06:00
rustc_abi i686-windows: make requested alignment > 4 special case apply transitively 2023-07-14 17:48:13 -04:00
rustc_apfloat
rustc_arena Extend unused_must_use to cover block exprs 2023-06-15 17:59:13 +08:00
rustc_ast Flip cfg's for bootstrap bump 2023-07-12 21:38:55 -04:00
rustc_ast_lowering Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
rustc_ast_passes Lint against misplaced where-clauses on assoc tys in traits 2023-07-11 01:19:11 +02:00
rustc_ast_pretty Syntatically accept become expressions 2023-06-19 12:54:34 +00:00
rustc_attr Add infrastructure #[rustc_confusables] attribute to allow targeted 2023-07-16 19:22:03 +08:00
rustc_baked_icu_data Regen baked data 2023-05-02 10:45:16 -07:00
rustc_borrowck Rollup merge of #113599 - chenyukang:yukang-fix-use-maybe_body_owned_by, r=cjgillot 2023-07-14 19:33:26 +02:00
rustc_builtin_macros Auto merge of #113557 - Amanieu:no-builtins-prelude, r=petrochenkov 2023-07-16 13:19:14 +00:00
rustc_codegen_cranelift Auto merge of #112157 - erikdesjardins:align, r=nikic 2023-07-15 15:39:53 +00:00
rustc_codegen_gcc refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_codegen_llvm Auto merge of #113430 - Zalathar:hash, r=b-naber 2023-07-16 01:56:23 +00:00
rustc_codegen_ssa Auto merge of #113626 - Urgau:dedup-native-static-libs, r=petrochenkov 2023-07-16 10:59:45 +00:00
rustc_const_eval refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_data_structures Introduce ExtentUnord trait for collections that can safely consume UnordItems. 2023-07-14 10:10:15 +02:00
rustc_driver Update rustix 2023-07-03 07:20:51 +00:00
rustc_driver_impl Don't require each rustc_interface tool to opt-in to parallel_rustc support 2023-07-11 22:55:23 -05:00
rustc_error_codes Implement custom diagnostic for ConstParamTy 2023-06-01 18:21:42 +00:00
rustc_error_messages Require TAITs to be mentioned in the signatures of functions that register hidden types for them 2023-07-07 13:13:18 +00:00
rustc_errors Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
rustc_expand Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
rustc_feature Add infrastructure #[rustc_confusables] attribute to allow targeted 2023-07-16 19:22:03 +08:00
rustc_fluent_macro Fix diagnostics with errors 2023-05-26 10:44:18 +00:00
rustc_fs_util Add try_canonicalize to rustc_fs_util and use it over fs::canonicalize 2023-03-16 21:50:23 +01:00
rustc_graphviz enable rust_2018_idioms for doctests 2023-05-07 00:12:29 +03:00
rustc_hir Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
rustc_hir_analysis Rollup merge of #113698 - compiler-errors:rpitit-check, r=spastorino 2023-07-14 19:33:29 +02:00
rustc_hir_pretty hir: Add Become expression kind 2023-06-26 08:56:32 +00:00
rustc_hir_typeck Add infrastructure #[rustc_confusables] attribute to allow targeted 2023-07-16 19:22:03 +08:00
rustc_incremental Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
rustc_index Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
rustc_infer refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_interface Auto merge of #113606 - jyn514:parallel-compiler-cleanup, r=cjgillot 2023-07-15 22:23:05 +00:00
rustc_lexer Revert the lexing of c_str_literals 2023-07-05 13:11:17 +02:00
rustc_lint refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_lint_defs Add machine-applicable suggestion for unused_qualifications lint 2023-07-13 08:26:02 +08:00
rustc_llvm Auto merge of #113430 - Zalathar:hash, r=b-naber 2023-07-16 01:56:23 +00:00
rustc_log Downgrade tracing and syn 2023-07-02 21:02:31 +02:00
rustc_macros Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
rustc_metadata Rollup merge of #113698 - compiler-errors:rpitit-check, r=spastorino 2023-07-14 19:33:29 +02:00
rustc_middle Auto merge of #112157 - erikdesjardins:align, r=nikic 2023-07-15 15:39:53 +00:00
rustc_mir_build Implement "items do not inherit unsafety" for THIR unsafeck 2023-07-15 11:59:38 -04:00
rustc_mir_dataflow refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_mir_transform Auto merge of #109025 - cjgillot:refprop-dbg, r=JakobDegen 2023-07-14 17:32:59 +00:00
rustc_monomorphize refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_parse Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
rustc_parse_format Fix typos in compiler 2023-04-10 22:02:52 +02:00
rustc_passes Add infrastructure #[rustc_confusables] attribute to allow targeted 2023-07-16 19:22:03 +08:00
rustc_plugin_impl Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
rustc_privacy refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_query_impl Avoid calling queries during query stack printing 2023-06-27 16:12:07 +02:00
rustc_query_system Show which type was not specialized on query cycle misuse 2023-07-05 07:30:28 +00:00
rustc_resolve refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_serialize Upgrade to indexmap 2.0.0 2023-07-03 13:51:54 -07:00
rustc_session Auto merge of #112988 - spastorino:new-rpitit-24, r=compiler-errors 2023-07-10 19:01:30 +00:00
rustc_smir Auto merge of #112982 - lukas-code:bootstrap-alias-default-crates, r=albertlarsan68 2023-07-14 12:09:27 +00:00
rustc_span Add infrastructure #[rustc_confusables] attribute to allow targeted 2023-07-16 19:22:03 +08:00
rustc_symbol_mangling refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_target i686-windows: make requested alignment > 4 special case apply transitively 2023-07-14 17:48:13 -04:00
rustc_trait_selection Rollup merge of #113625 - compiler-errors:structurally-norm-in-selection, r=lcnr 2023-07-15 19:42:51 +02:00
rustc_traits refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_transmute refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_ty_utils Auto merge of #112157 - erikdesjardins:align, r=nikic 2023-07-15 15:39:53 +00:00
rustc_type_ir refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00