rust/library/core/src
bors a28d221a4b Auto merge of #120730 - estebank:confusable-api, r=oli-obk
Provide suggestions through `rustc_confusables` annotations

Help with common API confusion, like asking for `push` when the data structure really has `append`.

```
error[E0599]: no method named `size` found for struct `Vec<{integer}>` in the current scope
  --> $DIR/rustc_confusables_std_cases.rs:17:7
   |
LL |     x.size();
   |       ^^^^
   |
help: you might have meant to use `len`
   |
LL |     x.len();
   |       ~~~
help: there is a method with a similar name
   |
LL |     x.resize();
   |       ~~~~~~
```

Fix #59450 (we can open subsequent tickets for specific cases).

Fix #108437:

```
error[E0599]: `Option<{integer}>` is not an iterator
   --> f101.rs:3:9
    |
3   |     opt.flat_map(|val| Some(val));
    |         ^^^^^^^^ `Option<{integer}>` is not an iterator
    |
   ::: /home/gh-estebank/rust/library/core/src/option.rs:571:1
    |
571 | pub enum Option<T> {
    | ------------------ doesn't satisfy `Option<{integer}>: Iterator`
    |
    = note: the following trait bounds were not satisfied:
            `Option<{integer}>: Iterator`
            which is required by `&mut Option<{integer}>: Iterator`
help: you might have meant to use `and_then`
    |
3   |     opt.and_then(|val| Some(val));
    |         ~~~~~~~~
```

On type error of method call arguments, look at confusables for suggestion. Fix #87212:

```
error[E0308]: mismatched types
    --> f101.rs:8:18
     |
8    |     stuff.append(Thing);
     |           ------ ^^^^^ expected `&mut Vec<Thing>`, found `Thing`
     |           |
     |           arguments to this method are incorrect
     |
     = note: expected mutable reference `&mut Vec<Thing>`
                           found struct `Thing`
note: method defined here
    --> /home/gh-estebank/rust/library/alloc/src/vec/mod.rs:2025:12
     |
2025 |     pub fn append(&mut self, other: &mut Self) {
     |            ^^^^^^
help: you might have meant to use `push`
     |
8    |     stuff.push(Thing);
     |           ~~~~
```
2024-02-23 00:42:56 +00:00
..
alloc rename ptr::invalid -> ptr::without_provenance 2024-02-21 20:15:52 +01:00
array Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
ascii implement Default for AsciiChar 2024-02-13 12:04:44 +01:00
async_iter Step all bootstrap cfgs forward 2024-02-08 07:44:34 -05:00
cell Add some optimizations 2023-10-13 14:54:33 +02:00
char Use generic NonZero internally. 2024-02-15 08:09:42 +01:00
cmp Use generic NonZero internally. 2024-02-15 08:09:42 +01:00
convert Refactor trait implementations in core::convert::num. 2024-02-19 06:03:34 +01:00
ffi Rollup merge of #119449 - Nilstrieb:library-clippy, r=cuviper 2024-02-11 08:25:42 +01:00
fmt Remove dead codes in core 2023-12-12 07:03:37 +00:00
future Replace some usage of #[rustc_on_unimplemented] with 2024-01-05 15:23:09 +01:00
hash Add insta-stable std:#️⃣:{DefaultHasher, RandomState} exports 2023-11-02 20:35:20 -04:00
intrinsics remove simd_reduce_{min,max}_nanless 2024-02-21 20:50:47 +01:00
io Auto merge of #120741 - a1phyr:safe_buffer_advance, r=m-ou-se 2024-02-17 00:23:15 +00:00
iter Clarify the flatten specialization comment 2024-02-16 16:08:01 -08:00
macros Rollup merge of #111106 - Stargateur:doc/format_args, r=m-ou-se 2024-02-15 09:20:16 +01:00
mem Auto merge of #116385 - kornelski:maybe-rename, r=Amanieu 2024-02-16 14:11:10 +00:00
net Auto merge of #116385 - kornelski:maybe-rename, r=Amanieu 2024-02-16 14:11:10 +00:00
num Rollup merge of #121241 - reitermarkus:generic-nonzero-traits, r=dtolnay 2024-02-20 15:13:52 +01:00
ops Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
panic Replace some usage of #[rustc_on_unimplemented] with 2024-01-05 15:23:09 +01:00
prelude Add Future and IntoFuture to the 2024 prelude 2024-02-18 23:20:05 +01:00
ptr Fix typo in metadata.rs doc comment 2024-02-22 09:30:03 +01:00
slice rename ptr::invalid -> ptr::without_provenance 2024-02-21 20:15:52 +01:00
str docs: add missing "the" to str::strip_prefix doc 2024-02-20 18:05:55 +01:00
sync rename ptr::invalid -> ptr::without_provenance 2024-02-21 20:15:52 +01:00
task Auto merge of #119863 - tmiasko:will-wake, r=m-ou-se 2024-02-15 14:43:29 +00:00
unicode Bump Unicode to version 15.1.0, regenerate tables 2024-02-09 17:35:46 +01:00
any.rs update version placeholders 2023-12-22 11:01:42 +01:00
arch.rs use visibility to check unused imports and delete some stmts 2023-10-22 21:27:46 +08:00
ascii.rs Use generic NonZero internally. 2024-02-15 08:09:42 +01:00
asserting.rs [RFC 2011] Library code 2022-05-22 07:18:32 -03:00
bool.rs core is now compilable 2023-04-16 07:20:26 +00:00
borrow.rs doc: replace wrong punctuation mark 2023-07-28 14:46:17 +02:00
cell.rs Add rustc_confusables annotations to some stdlib APIs 2024-02-22 18:04:55 +00:00
clone.rs remove redundant imports 2023-12-10 10:56:22 +08:00
cmp.rs Rollup merge of #115386 - RalfJung:partial-eq-chain, r=dtolnay 2024-02-05 11:07:25 +01:00
default.rs implement Default for AsciiChar 2024-02-13 12:04:44 +01:00
error.md Fix minor grammar typo 2023-09-06 09:47:22 -07:00
error.rs Spelling fix 2024-01-20 18:27:55 +00:00
escape.rs Use generic NonZero internally. 2024-02-15 08:09:42 +01:00
hint.rs Rewrite assert_unsafe_precondition around the new intrinsic 2024-02-08 11:52:14 -05:00
internal_macros.rs add track_caller for arith ops 2023-11-24 00:54:06 +08:00
intrinsics.rs Auto merge of #121309 - Nilstrieb:inline-all-the-fallbacks, r=oli-obk 2024-02-22 12:07:08 +00:00
lib.rs diagnostic items for legacy numeric modules 2024-02-20 13:34:18 -07:00
marker.rs Step all bootstrap cfgs forward 2024-02-08 07:44:34 -05:00
option.rs Add flatmap/flat_map -> and_then suggestions 2024-02-22 18:05:28 +00:00
panic.rs Convert debug_assert_nounwind to intrinsics::debug_assertions 2024-02-19 20:38:09 -05:00
panicking.rs merge core_panic feature into panic_internals 2023-12-09 14:49:00 +01:00
pin.rs Rename pointer field on Pin 2024-01-16 14:58:42 -05:00
primitive.rs
primitive_docs.rs Rollup merge of #120880 - RalfJung:vtable-fnptr-partialeq, r=cuviper 2024-02-11 23:19:09 +01:00
result.rs Add flatmap/flat_map -> and_then suggestions 2024-02-22 18:05:28 +00:00
time.rs Rollup merge of #120307 - djc:duration-constructors, r=Mark-Simulacrum 2024-02-11 08:25:42 +01:00
tuple.rs Rollup merge of #118307 - scottmcm:tuple-eq-simpler, r=joshtriplett 2024-02-11 08:25:41 +01:00
unit.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00