Skip to content

Spurious reference binding from edition lint #87355

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

Closed
djc opened this issue Jul 21, 2021 · 6 comments
Closed

Spurious reference binding from edition lint #87355

djc opened this issue Jul 21, 2021 · 6 comments
Labels
A-edition-2021 Area: The 2021 edition C-bug Category: This is a bug.

Comments

@djc
Copy link
Contributor

djc commented Jul 21, 2021

I ran cargo +nightly fix --edition against quinn-rs/quinn@a21f010.

I expected to see this happen: no changes or necessary edition-related changes.

Instead, this happened: cargo fix produced this change:

djc-2019 main quinn $ git diff
diff --git a/quinn/examples/client.rs b/quinn/examples/client.rs
index f310b461..033b1c1e 100644
--- a/quinn/examples/client.rs
+++ b/quinn/examples/client.rs
@@ -60,7 +60,7 @@ fn main() {
 }
 
 #[tokio::main]
-async fn run(options: Opt) -> Result<()> {
+async fn run(options: Opt) -> Result<()> { let _ = &options; 
     let url = options.url;
     let remote = (url.host_str().unwrap(), url.port().unwrap_or(4433))
         .to_socket_addrs()?

(The formatting is surprising, but that's not what this issue is about.)

cargo +nightly c with cargo-features = ["edition2021"] seems to work with or without the change, so it seems like this change is not actually needed. Is there some odd interaction with tokio::main?

Meta

rustc 1.55.0-nightly (b41936b 2021-07-20)
binary: rustc
commit-hash: b41936b
commit-date: 2021-07-20
host: x86_64-apple-darwin
release: 1.55.0-nightly
LLVM version: 12.0.1

@djc djc added the C-bug Category: This is a bug. label Jul 21, 2021
@fbernier
Copy link
Contributor

fbernier commented Jul 22, 2021

@djc I too was confused about that change but I just found out this explanation.

Basically, this change is needed because without it it could change the order in which fields are dropped, possibly breaking backward compatibility.

@djc
Copy link
Contributor Author

djc commented Jul 25, 2021

@TriageBot modify labels to +A-edition-2021

@rustbot rustbot added the A-edition-2021 Area: The 2021 edition label Jul 25, 2021
@m-ou-se
Copy link
Member

m-ou-se commented Aug 2, 2021

cc @rust-lang/wg-rfc-2229

@arora-aman
Copy link
Member

This is the expected lint for RFC 2229.

The &options introduces an immutable read within the closure, forcing options to be read completely without changing the closure trait(Fn/FnMut/FnOnce).

@m-ou-se
Copy link
Member

m-ou-se commented Aug 12, 2021

(The formatting is surprising, but that's not what this issue is about.)

Filed an issue for that: #87952

@m-ou-se
Copy link
Member

m-ou-se commented Aug 12, 2021

This is the expected lint for RFC 2229.

Closing this issue then.

@m-ou-se m-ou-se closed this as completed Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2021 Area: The 2021 edition C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

5 participants