diff options
| author | Sosthène Guédon <sosthene@guedon.gdn> | 2022-11-20 12:20:16 +0100 |
|---|---|---|
| committer | Sosthène Guédon <sosthene@guedon.gdn> | 2022-11-20 13:45:12 +0100 |
| commit | d9993cb133909eb17705cd9dc518c2c213fc779b (patch) | |
| tree | bc02a90e426431a2c0289ff611adadc85598f09c | |
| parent | 77374a95272dfb8fcbc75cd074b4e61b1890c724 (diff) | |
| download | rust-d9993cb133909eb17705cd9dc518c2c213fc779b.tar.gz rust-d9993cb133909eb17705cd9dc518c2c213fc779b.zip | |
Remove error when fields use autoderef
| -rw-r--r-- | clippy_lints/src/functions/misnamed_getters.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/clippy_lints/src/functions/misnamed_getters.rs b/clippy_lints/src/functions/misnamed_getters.rs index 599269e2d63..c553901059b 100644 --- a/clippy_lints/src/functions/misnamed_getters.rs +++ b/clippy_lints/src/functions/misnamed_getters.rs @@ -101,16 +101,14 @@ pub fn check_fn( } let Some(used_field) = used_field else { - if cfg!(debug_assertions) { - panic!("Struct doesn't contain the correct field"); - } else { - // Don't ICE when possible - return; - } - }; + // FIXME: This can be reached if the field access uses autoderef. + // `dec.all_fields()` should be replaced by something that uses autoderef. + return; + }; + let Some(correct_field) = correct_field else { return; - }; + }; if cx.tcx.type_of(used_field.did) == cx.tcx.type_of(correct_field.did) { let left_span = block_expr.span.until(used_ident.span); |
