Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

J-ZhengLi
Copy link
Member

fixes: #12659

[manual_map] and [manual_filter] shares the same check logic, but this issue doesn't seems like it could affect manual_filter (?)


changelog: make [manual_map] ignore types that contain dyn

@rustbot
Copy link
Collaborator

rustbot commented Apr 25, 2024

r? @dswij

rustbot has assigned @dswij.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 25, 2024
Comment on lines +76 to +89
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,
};
Copy link
Member

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));
}

Copy link
Member Author

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

@J-ZhengLi J-ZhengLi marked this pull request as draft April 26, 2024 01:33
@dswij dswij added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels May 4, 2024
@J-ZhengLi J-ZhengLi force-pushed the issue12666 branch 2 times, most recently from d44c289 to f01faac Compare May 10, 2024 07:51
@J-ZhengLi J-ZhengLi marked this pull request as ready for review May 10, 2024 08:35
@J-ZhengLi
Copy link
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

manual_map sugg with dyn causes error
4 participants