Skip to content

Failure to update dyn usage in Rust 2018 to 2021 transition #86751

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
rylev opened this issue Jun 30, 2021 · 1 comment · Fixed by #86572
Closed

Failure to update dyn usage in Rust 2018 to 2021 transition #86751

rylev opened this issue Jun 30, 2021 · 1 comment · Fixed by #86572
Assignees
Labels
A-edition-2021 Area: The 2021 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug.

Comments

@rylev
Copy link
Member

rylev commented Jun 30, 2021

To reproduce:

  • Clone serde.
  • Run cargo +nightly fix --edition (this updates serde from Rust 2015 to Rust 2018).
  • Add the edition field to the Cargo.toml with "2018" and commit changes.
  • Run cargo +nightly fix --edition (this updates serde from Rust 2018 to Rust 2021).
  • Change the edition field to "2021" (ensure cargo-features = ["edition2021"] is present at the top of the Cargo.toml file)

This produces an error because some uses of bare trait objects were not updated:

error[E0782]: trait objects must include the `dyn` keyword
    --> serde/src/private/de.rs:1725:37
     |
1725 |         fn invalid_type(self, exp: &Expected) -> E {
     |                                     ^^^^^^^^
     |
help: add `dyn` keyword before this trait

Running cargo +nightly rustc -- -Zunstable-options --force-warns rust_2021_compatibility produces the proper warnings, but these are not picked up by cargo fix.

warning: trait objects without an explicit `dyn` are deprecated
    --> serde/src/private/de.rs:1725:37
     |
1725 |         fn invalid_type(self, exp: &Expected) -> E {
     |                                     ^^^^^^^^ help: use `dyn`: `dyn Expected`
     |
     = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
     = note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>

I'm filing this in rust-lang/rust instead of in rust-lang/cargo, because I have a feeling this is a rustc issue.

Meta

rustc +nightly --version --verbose:

rustc 1.55.0-nightly (6d820866a 2021-06-29)
binary: rustc
commit-hash: 6d820866a27b1949e237be79b9c8c0145fe728b7
commit-date: 2021-06-29
host: x86_64-unknown-linux-gnu
release: 1.55.0-nightly
LLVM version: 12.0.1
@rylev rylev added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. A-edition-2021 Area: The 2021 edition labels Jun 30, 2021
@ehuss
Copy link
Contributor

ehuss commented Jun 30, 2021

For reference, the cause is that cargo is using --force-warns=rust-2021-compatibility and --cap-lints=warn, and serde uses #![allow(bare_trait_objects)] and the interaction seems to be broken by #86009.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-edition-2021 Area: The 2021 edition A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants