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

Warn on bare_trait_objects by default #61203

Merged
merged 6 commits into from
May 30, 2019

Conversation

memoryruins
Copy link
Contributor

@memoryruins memoryruins commented May 26, 2019

The bare_trait_objects lint is set to warn by default.
Most ui tests have been updated to use dyn to avoid creating noise in stderr files.

r? @Centril

cc #54910

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 26, 2019
@rust-highfive

This comment has been minimized.

@memoryruins memoryruins force-pushed the bare_trait_objects branch 2 times, most recently from 2dc7a7a to 9eb7ad3 Compare May 26, 2019 04:35
@rust-highfive

This comment has been minimized.

@memoryruins
Copy link
Contributor Author

and now for level 2: updating run-pass suite.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@memoryruins
Copy link
Contributor Author

@Centril ready for review! \o/

@Centril
Copy link
Contributor

Centril commented May 28, 2019

@rust-lang/lang N.B. This PR implements the "lint against bare trait syntax" as specified in RFC 2113. As we only move to a warning, I think we can dispense with a crater run for now and perhaps move to deny later in the year.

@joshtriplett
Copy link
Member

joshtriplett commented May 28, 2019 via email

@memoryruins
Copy link
Contributor Author

Rebased on top of master and addressed comments ^^

@Centril
Copy link
Contributor

Centril commented May 28, 2019

Thanks!

@bors r+ p=1 rollup=never

@bors
Copy link
Contributor

bors commented May 28, 2019

📌 Commit a6eda0d1b841e18235575b4977435cf78ab711a3 has been approved by Centril

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 28, 2019
@Centril
Copy link
Contributor

Centril commented May 28, 2019

@bors p=2

@bors
Copy link
Contributor

bors commented May 29, 2019

⌛ Testing commit a6eda0d1b841e18235575b4977435cf78ab711a3 with merge f4d9baf059c86bacc6e25f38308f409c808f0cf9...

@bors
Copy link
Contributor

bors commented May 29, 2019

💔 Test failed - checks-travis

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 30, 2019
Changes:
````
Rustup to rust-lang#61203
rustup rust-lang#60928
rustup rust-lang#61164 (which is included in rust-lang#61274)
````
bors added a commit that referenced this pull request May 31, 2019
submodules: update clippy from fb33fad to d2f5122

Changes:
````
Rustup to #61203
rustup #60928
rustup #61164 (which is included in #61274)
````

Fixes #61287

r? @oli-obk
@alexcrichton
Copy link
Member

It appears that this lint isn't automatically rust-fixable, is that correct?

If so I would prefer that this were reverted, it's generating thousands of warnings in just one local project, and without rustfix to fix the majority of these it seems like this is prematurely warning by default.

@Centril
Copy link
Contributor

Centril commented May 31, 2019

It appears that this lint isn't automatically rust-fixable, is that correct?

I was able to rustfix this automatically in rust-lang/gll#100. Did you use cargo fix --edition-idioms? dyn Trait is even included as an example in the edition guide, https://doc.rust-lang.org/nightly/edition-guide/editions/transitioning-an-existing-project-to-a-new-edition.html#writing-idiomatic-code-in-a-new-edition

@alexcrichton
Copy link
Member

Since this is now an on-by-default warning it should not require --edition-idioms. It'd be great to make sure that these things are tested before landing.

Tweaking the cargo fix command locally it does look like these are automatically fixed, namely for me using --all worked since it only looks to fix in the local package otherwise.

@Centril
Copy link
Contributor

Centril commented May 31, 2019

@alexcrichton Ah; I assumed the --edition-idioms infrastructure simply set -W rust_2018_idioms. Can you upstream the fix (in cargo I assume?)?

namely for me using --all worked since it only looks to fix in the local package otherwise.

But --cap-lints should apply so you shouldn't get warnings otherwise... or perhaps you had some interactions with macros?

Librazy added a commit to Librazy/talent-plan that referenced this pull request Jun 2, 2019
Missing `dyn` for trait object (bare trait object) is a warning by default now as rust-lang/rust#61203 is merged, which breaks labrpc.
Also fixed a few other warnings and unclear documents.

Signed-off-by: Liqueur Librazy <im@librazy.org>
@alexcrichton
Copy link
Member

No fix was necessary, it's simply on by default and all that's needed is cargo fix. If there is more than one crate in a workspace you may need cargo fix --all. The --cap-lints argument isn't applied to workspace members.

overvenus pushed a commit to pingcap/talent-plan that referenced this pull request Jun 5, 2019
Missing `dyn` for trait object (bare trait object) is a warning by default now as rust-lang/rust#61203 is merged, which breaks labrpc.
Also fixed a few other warnings and unclear documents.

Signed-off-by: Liqueur Librazy <im@librazy.org>
@SimonSapin
Copy link
Contributor

This change is proving disruptive: #61963

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Aug 29, 2019
Pkgsrc changes:
 * Add a patch to llvm to deal with const dli_saddr.
 * Adapt two other patches.
 * Cross-build currently fails, so i386, powerpc and sparc64 bootstrap
   kits for 1.37.0 are built natively.  Missing aarch64 hardware, so that's
   not available yet.
 * Bump bootstrap requirements to 1.36.0 except for armv7-unknown-netbsd-eabihf
   which I've not managed to cross-build.

Upstream changes:

Version 1.37.0 (2019-08-15)
==========================

Language
--------
- `#[must_use]` will now warn if the type is contained in a [tuple][61100],
  [`Box`][62228], or an [array][62235] and unused.
- [You can now use the `cfg` and `cfg_attr` attributes on
  generic parameters.][61547]
- [You can now use enum variants through type alias.][61682] e.g. You can
  write the following:
  ```rust
  type MyOption = Option<u8>;

  fn increment_or_zero(x: MyOption) -> u8 {
      match x {
          MyOption::Some(y) => y + 1,
          MyOption::None => 0,
      }
  }
  ```
- [You can now use `_` as an identifier for consts.][61347] e.g. You can write
  `const _: u32 = 5;`.
- [You can now use `#[repr(align(X)]` on enums.][61229]
- [The  `?`/_"Kleene"_ macro operator is now available in the
  2015 edition.][60932]

Compiler
--------
- [You can now enable Profile-Guided Optimization with the `-C profile-generate`
  and `-C profile-use` flags.][61268] For more information on how to use profile
  guided optimization, please refer to the [rustc book][rustc-book-pgo].
- [The `rust-lldb` wrapper script should now work again.][61827]

Libraries
---------
- [`mem::MaybeUninit<T>` is now ABI-compatible with `T`.][61802]

Stabilized APIs
---------------
- [`BufReader::buffer`]
- [`BufWriter::buffer`]
- [`Cell::from_mut`]
- [`Cell<[T]>::as_slice_of_cells`][`Cell<slice>::as_slice_of_cells`]
- [`DoubleEndedIterator::nth_back`]
- [`Option::xor`]
- [`Wrapping::reverse_bits`]
- [`i128::reverse_bits`]
- [`i16::reverse_bits`]
- [`i32::reverse_bits`]
- [`i64::reverse_bits`]
- [`i8::reverse_bits`]
- [`isize::reverse_bits`]
- [`slice::copy_within`]
- [`u128::reverse_bits`]
- [`u16::reverse_bits`]
- [`u32::reverse_bits`]
- [`u64::reverse_bits`]
- [`u8::reverse_bits`]
- [`usize::reverse_bits`]

Cargo
-----
- [`Cargo.lock` files are now included by default when publishing executable crates
  with executables.][cargo/7026]
- [You can now specify `default-run="foo"` in `[package]` to specify the
  default executable to use for `cargo run`.][cargo/7056]

Misc
----

Compatibility Notes
-------------------
- [Using `...` for inclusive range patterns will now warn by default.][61342]
  Please transition your code to using the `..=` syntax for inclusive
  ranges instead.
- [Using a trait object without the `dyn` will now warn by default.][61203]
  Please transition your code to use `dyn Trait` for trait objects instead.

[62228]: rust-lang/rust#62228
[62235]: rust-lang/rust#62235
[61802]: rust-lang/rust#61802
[61827]: rust-lang/rust#61827
[61547]: rust-lang/rust#61547
[61682]: rust-lang/rust#61682
[61268]: rust-lang/rust#61268
[61342]: rust-lang/rust#61342
[61347]: rust-lang/rust#61347
[61100]: rust-lang/rust#61100
[61203]: rust-lang/rust#61203
[61229]: rust-lang/rust#61229
[60932]: rust-lang/rust#60932
[cargo/7026]: rust-lang/cargo#7026
[cargo/7056]: rust-lang/cargo#7056
[`BufReader::buffer`]: https://doc.rust-lang.org/std/io/struct.BufReader.html#method.buffer
[`BufWriter::buffer`]: https://doc.rust-lang.org/std/io/struct.BufWriter.html#method.buffer
[`Cell::from_mut`]: https://doc.rust-lang.org/std/cell/struct.Cell.html#method.from_mut
[`Cell<slice>::as_slice_of_cells`]: https://doc.rust-lang.org/std/cell/struct.Cell.html#method.as_slice_of_cells
[`DoubleEndedIterator::nth_back`]: https://doc.rust-lang.org/std/iter/trait.DoubleEndedIterator.html#method.nth_back
[`Option::xor`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.xor
[`RefCell::try_borrow_unguarded`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.try_borrow_unguarded
[`Wrapping::reverse_bits`]: https://doc.rust-lang.org/std/num/struct.Wrapping.html#method.reverse_bits
[`i128::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i128.html#method.reverse_bits
[`i16::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i16.html#method.reverse_bits
[`i32::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i32.html#method.reverse_bits
[`i64::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i64.html#method.reverse_bits
[`i8::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i8.html#method.reverse_bits
[`isize::reverse_bits`]: https://doc.rust-lang.org/std/primitive.isize.html#method.reverse_bits
[`slice::copy_within`]: https://doc.rust-lang.org/std/primitive.slice.html#method.copy_within
[`u128::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u128.html#method.reverse_bits
[`u16::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u16.html#method.reverse_bits
[`u32::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u32.html#method.reverse_bits
[`u64::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u64.html#method.reverse_bits
[`u8::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u8.html#method.reverse_bits
[`usize::reverse_bits`]: https://doc.rust-lang.org/std/primitive.usize.html#method.reverse_bits
[rustc-book-pgo]: https://doc.rust-lang.org/rustc/profile-guided-optimization.html
ryzhyk pushed a commit to vmware/differential-datalog that referenced this pull request Sep 5, 2019
When using Rust 1.37 a missing 'dyn' in conjunction with a trait object is now
emitting a warning (see [Rust issue #61203][issue-61203]), causing all generated
programs to warn as well:

> warning: trait objects without an explicit `dyn` are deprecated
>   --> src/valmap.rs:36:34
>    |
> 36 |     pub fn format(&self, w: &mut io::Write) -> io::Result<()> {
>    |                                  ^^^^^^^^^ help: use `dyn`: `dyn io::Write`
>    |
>    = note: #[warn(bare_trait_objects)] on by default

Let's remove these warnings by adding this keyword to the uses of trait objects
in the project template.

[issue-61203]: rust-lang/rust#61203
remi-dupre added a commit to Qwant/fafnir that referenced this pull request Nov 18, 2019
Using bare trait objects is deprecated and now triggers a warning by
default: rust-lang/rust#61203.
remi-dupre added a commit to Qwant/fafnir that referenced this pull request Nov 19, 2019
Using bare trait objects is deprecated and now triggers a warning by
default: rust-lang/rust#61203.
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request May 5, 2020
remi-dupre added a commit to Qwant/fafnir that referenced this pull request Sep 1, 2022
Using bare trait objects is deprecated and now triggers a warning by
default: rust-lang/rust#61203.
remi-dupre added a commit to Qwant/fafnir that referenced this pull request Sep 2, 2022
Using bare trait objects is deprecated and now triggers a warning by
default: rust-lang/rust#61203.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants