diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-03-14 17:40:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-14 17:40:07 +0100 |
| commit | b17ee106d8d6c3402020c72b703455305432b759 (patch) | |
| tree | 0973953470dd2342447e12f85ea22ac920ea74eb /compiler/rustc_codegen_gcc | |
| parent | b88c675946704cb2bf0e26fcad6149112d6aa326 (diff) | |
| parent | 6a2a6feca87fe52aa7c3bb4ab54a2b98e7459cd0 (diff) | |
| download | rust-b17ee106d8d6c3402020c72b703455305432b759.tar.gz rust-b17ee106d8d6c3402020c72b703455305432b759.zip | |
Rollup merge of #109116 - MaciejWas:add-modifies-receiver-diagn-when-method-not-found, r=petrochenkov
Emit diagnostic when calling methods on the unit type in method chains Fixes #104204. What this PR does: If a method is not found somewhere in a call chain, we check if we called earlier a method with signature `(&mut T, ...) -> ()`. If this is the case then we emit a diagnostic message. For example given input: ``` vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); ``` the current output is: ``` error[E0599]: no method named `sort` found for unit type `()` in the current scope --> hello.rs:3:72 | 3 | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); | ^^^^ method not found in `()` ``` after this PR it will be: ``` error[E0599]: no method named `sort` found for unit type `()` in the current scope --> ./hello.rs:3:72 | 3 | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); | ^^^^ method not found in `()` | note: method `sort_by_key` modifies its receiver in-place, it is not meant to be used in method chains. --> ./hello.rs:3:53 | 3 | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); | ^^^^^^^^^^^ this call modifies its receiver in-place ```
Diffstat (limited to 'compiler/rustc_codegen_gcc')
0 files changed, 0 insertions, 0 deletions
