mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-21 20:23:21 +00:00
Auto merge of #7085 - Jarcho:manual_map_autoderef, r=giraffate
Don't allow adjustments for `manual_map` fixes: #7077 The other option here would be to add the return type to the closure. It would be fine for simple types, but longer types can be rather unwieldy. Could also implement the adjustment manually. changelog: Don't lint `manual_map` when type adjustments are added. e.g. autoderef
This commit is contained in:
commit
faa97568a0
@ -104,12 +104,18 @@ impl LateLintPass<'_> for ManualMap {
|
||||
None => return,
|
||||
};
|
||||
|
||||
// These two lints will go back and forth with each other.
|
||||
if cx.typeck_results().expr_ty(some_expr) == cx.tcx.types.unit
|
||||
&& !is_allowed(cx, OPTION_MAP_UNIT_FN, expr.hir_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// `map` won't perform any adjustments.
|
||||
if !cx.typeck_results().expr_adjustments(some_expr).is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
if !can_move_expr_to_closure(cx, some_expr) {
|
||||
return;
|
||||
}
|
||||
|
@ -146,4 +146,11 @@ fn main() {
|
||||
None => None,
|
||||
};
|
||||
}
|
||||
|
||||
// #7077
|
||||
let s = &String::new();
|
||||
let _: Option<&str> = match Some(s) {
|
||||
Some(s) => Some(s),
|
||||
None => None,
|
||||
};
|
||||
}
|
||||
|
@ -212,4 +212,11 @@ fn main() {
|
||||
None => None,
|
||||
};
|
||||
}
|
||||
|
||||
// #7077
|
||||
let s = &String::new();
|
||||
let _: Option<&str> = match Some(s) {
|
||||
Some(s) => Some(s),
|
||||
None => None,
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user