-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
f01faac
to
00bb73f
Compare
@rustbot ready |
I'll take this one since I looked into it previously, r? me |
Failed to set assignee to
|
ceec8fa
to
a03f382
Compare
@rustbot author |
b386427
to
a5fcaea
Compare
if expr.span.from_expansion() { | ||
return false; | ||
} |
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.
Is this to catch something specific? It could lead to some FPs though it might be fairly rare
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.
hmmm, I forgot why I left it there, but... you're right 😂
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.
Oh I think I got it, it was a lazy solution to pass this test:
match Some(0) {
Some(x) => Some(vec![x]),
None => None,
};
// ^ help: try: `Some(0).map(|x| vec![x])`
The coercion in this case is totally irrelevant, but I don't know how to filter it out
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.
Ok, so... I think I know where the problem was.
technically, the above case is not a coercion site(?) according to the coercion doc:
...these are typically places where the desired type is explicit or can be derived by propagation from explicit types (without type inference).
Thus using map
here actually works. However, because I have a type adjustment check at first, which causing it to return early as soon as any expr's ty was adjusted (and this expr in vec!
was indeed adjusted), causing FN on the above test case.
Ignore what I said earlier that it was totally irrelevant, here is a counter example which might not seems rare at all:
let x: Option<Vec<&[u8]>> = match Some(()) {
Some(_) => Some(vec![b"1234"]),
None => None,
};
With that from_expansion
check, this will surely cause FP, so it's definitely a "no". And I also need the type adjustment check, otherwise this counter example wouldn't work.
Now I'm out of options, do I need to bring back the expr_has_explicit_ty
function from the beginning?
8996cc9
to
0e970e0
Compare
0e970e0
to
18d1a59
Compare
☔ The latest upstream changes (presumably #13440) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
Sorry for the delay! Looks ready to merge with conflicts fixed
18d1a59
to
7d64117
Compare
rebased, thank you for all the help and guidance~ |
@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