New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make [manual_map
] ignore types that contain dyn
#12712
base: master
Are you sure you want to change the base?
Conversation
fn foo<T: DummyTrait, F: Fn() -> Result<T, ()>>(f: F) { | ||
// Don't lint | ||
let _: Option<Result<Box<dyn DummyTrait>, ()>> = match Some(0) { | ||
Some(_) => Some(match f() { | ||
Ok(res) => Ok(Box::new(res)), | ||
_ => Err(()), | ||
}), | ||
None => None, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that it doesn't catch the adjustment rather than the presence of a dyn
, e.g. the same can occur with an unsized coercion
fn main() {
let x: &[u8; 4] = b"1234";
// ok
let _: Option<Box<&[u8]>> = match Some(()) {
Some(_) => Some(Box::new(x)),
None => None,
};
// error[E0308]: mismatched types
let _: Option<Box<&[u8]>> = Some(()).map(|_| Box::new(x));
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, you're right, I'll see what I can do with it
d44c289
to
f01faac
Compare
@rustbot ready |
fixes: #12659
[
manual_map
] and [manual_filter
] shares the same check logic, but this issue doesn't seems like it could affectmanual_filter
(?)changelog: make [
manual_map
] ignore types that containdyn