Suggest &str.chars() on attempt to &str.iter()#90803
Conversation
|
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
|
Here's a similar error: Maybe this one should mention |
estebank
left a comment
There was a problem hiding this comment.
I would prefer it if we could have a more... generalized solution for this problem. One that I've seen presented is an #[alias("alt_name")] attribute, where we could manually annotate methods in std with common names used in other languages for the same behavior. In this case we could annotate #[alias("iter", "codepoints")] fn chars and let that machinery do the rest.
But in the meantime I'm not against landing targeted solutions, although it is additional tech debt.
|
@r00ster91 that error occurs in a separate part of the compiler. E0599 occurs during typeck, while E0277 occurs during trait resolution. It is also using the |
e5afb63 to
ae6f7b6
Compare
|
r? @estebank |
estebank
left a comment
There was a problem hiding this comment.
There's some trailing whitespace, but after fixing that r=me
check if `String` or `&String` or `&str` Update compiler/rustc_typeck/src/check/method/suggest.rs Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com> remove some trailing whitespace
f103b93 to
d562f48
Compare
|
@bors r+ |
|
📌 Commit d562f48 has been approved by |
…-iter, r=estebank Suggest `&str.chars()` on attempt to `&str.iter()` closes rust-lang#90786
Rollup of 8 pull requests Successful merges: - rust-lang#86455 (check where-clause for explicit `Sized` before suggesting `?Sized`) - rust-lang#90801 (Normalize both arguments of `equate_normalized_input_or_output`) - rust-lang#90803 (Suggest `&str.chars()` on attempt to `&str.iter()`) - rust-lang#90819 (Fixes incorrect handling of TraitRefs when emitting suggestions.) - rust-lang#90910 (fix getting the discriminant of a zero-variant enum) - rust-lang#90925 (rustc_mir_build: reorder bindings) - rust-lang#90928 (Use a different server for checking clock drift) - rust-lang#90936 (Add a regression test for rust-lang#80772) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
closes #90786