mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 09:38:26 +03: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:
@@ -104,12 +104,18 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
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 @@ const fn f4() {
|
||||
None => None,
|
||||
};
|
||||
}
|
||||
|
||||
// #7077
|
||||
let s = &String::new();
|
||||
let _: Option<&str> = match Some(s) {
|
||||
Some(s) => Some(s),
|
||||
None => None,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user