Skip to content

Don't lint let_unit_value when needed for type inferenece#8563

Merged
bors merged 3 commits into
rust-lang:masterfrom
Jarcho:let_unit_1502
Apr 15, 2022
Merged

Don't lint let_unit_value when needed for type inferenece#8563
bors merged 3 commits into
rust-lang:masterfrom
Jarcho:let_unit_1502

Conversation

@Jarcho

@Jarcho Jarcho commented Mar 17, 2022

Copy link
Copy Markdown
Contributor

fixes: #1502

Pinging @dtolnay. I think this is enough to fix the issue. Do you have a good list crates to test this on?

changelog: Don't lint let_unit_value when needed for type inference

@rust-highfive

Copy link
Copy Markdown

r? @llogiq

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Mar 17, 2022

@llogiq llogiq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know which crates suffered this problem, but code-wise this looks good to me.

Comment thread tests/ui/let_unit.rs Outdated
@Jarcho Jarcho force-pushed the let_unit_1502 branch 5 times, most recently from 6bf3e41 to ff0e654 Compare March 18, 2022 03:30
@bors

bors commented Mar 30, 2022

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #8602) made this pull request unmergeable. Please resolve the merge conflicts.

@llogiq

llogiq commented Apr 2, 2022

Copy link
Copy Markdown
Contributor

Sorry for letting this wait for so long, but I lack insight into actual cases in the wild, so I'm not sure if they are all caught

However, as even if this misses some cases it is still a good improvement, r=me with a rebase.

@Jarcho

Jarcho commented Apr 5, 2022

Copy link
Copy Markdown
Contributor Author

This will now handle block expression and branches when checking if type inference is needed.

The only thing I can think of that would also be a false positive would be a something like:

trait Foo {
    type T;
    fn get_t(&self) -> Self::T;
    fn use_t(&self, _: T);
}
struct Bar;
impl Foo for Bar {
    type T = ();
    ...
}

fn f(bar: Bar) {
    let x = bar.get_t();
    bar.use_t(x);
}

But I'm pretty sure that already doesn't lint.

@Jarcho Jarcho force-pushed the let_unit_1502 branch 2 times, most recently from a81ac09 to 4ec407c Compare April 5, 2022 02:18
@bors

bors commented Apr 11, 2022

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #8660) made this pull request unmergeable. Please resolve the merge conflicts.

@llogiq

llogiq commented Apr 14, 2022

Copy link
Copy Markdown
Contributor

Ok, I might be offline for a while, but r+ when rebased. Thanks and again sorry for the wait.

@bors delegate+

@bors

bors commented Apr 14, 2022

Copy link
Copy Markdown
Contributor

✌️ @Jarcho can now approve this pull request

@Jarcho

Jarcho commented Apr 15, 2022

Copy link
Copy Markdown
Contributor Author

@bors r+

@bors

bors commented Apr 15, 2022

Copy link
Copy Markdown
Contributor

📌 Commit 70f7c62 has been approved by Jarcho

@bors

bors commented Apr 15, 2022

Copy link
Copy Markdown
Contributor

⌛ Testing commit 70f7c62 with merge 0bc93b6...

@bors

bors commented Apr 15, 2022

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Jarcho
Pushing 0bc93b6 to master...

tgross35 added a commit to tgross35/linux that referenced this pull request Jul 16, 2023
Currently, 'rustc_common_flags' lives in the top-level 'Makefile'.
This means that we need to touch this whenever adjustments to Rust's CLI
configuration are desired, such as changing what lints Clippy should
emit.

This patch moves these flags to a separate file within 'rust/' so that
necessary changes can be made without affecting 'Makefile'. It copies
the behavior currently used with 'bindgen_parameters', which accepts
comments.

Additionally, 'let_unit_value` is no longer specifically named as it is
now part of the 'style' group [1].

[1]: rust-lang/rust-clippy#8563

Signed-off-by: Trevor Gross <tmgross@umich.edu>
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.

Let_unit_value false positive when return type is type parameter

4 participants