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

trait objects without an explicit dyn are deprecated #414

Closed
xiaokang5350 opened this issue Jun 3, 2019 · 24 comments
Closed

trait objects without an explicit dyn are deprecated #414

xiaokang5350 opened this issue Jun 3, 2019 · 24 comments

Comments

@xiaokang5350
Copy link

I use rustc 1.37.0-nightly and report trait objects without an explicit dyn are deprecated warnings

@stepancheg
Copy link
Owner

Yep, most error were fixed in d6f783e and version 2.6.2, and more muted warnings are needed.

Note that rust-protobuf 2.6 cannot switch to dyn properly because of compatibility with Rust 1.26.

Probably rust-protobuf 2.7 needs to require Rust 1.27 where dyn is stable.

@stepancheg
Copy link
Owner

rust-protobuf 2.7 (unreleased branch) now works only with Rust 1.27.

@rtsisyk
Copy link

rtsisyk commented Jun 24, 2019

Any plans to release 2.7?

@stepancheg
Copy link
Owner

In about a week. I'm a bit worried that something may break, so if someone wants to help with code review, I'd appreciate that. (Changelog)

@stepancheg
Copy link
Owner

2.7 is released.

@jakubadamw
Copy link

@stepancheg, well, it's released, but the code that gets generated still produces trait objects without an explicit `dyn` are deprecated warnings under Rust >= 1.27. Shouldn't this issue be reopened, then?

I presume that the minimal Rust version required by protoc-rust should go hand in hand with the minimal version the generated code is expected to compile under, correct? Therefore, if the version 2.7 requires Rust 1.27, so should the code it generates, and thereby it can use dyn to eliminate the warnings?

@stepancheg
Copy link
Owner

@jakubadamw Maybe I'm missing something. Can you please show how to reproduce the problem?

@stepancheg
Copy link
Owner

(At least show generated code)

@stepancheg stepancheg reopened this Jul 10, 2019
@jakubadamw
Copy link

jakubadamw commented Jul 10, 2019

@stepancheg, sure! 🙂

https://github.com/jakubadamw/rust-protobuf-414

> cargo build
   Compiling reproduction_414 v0.0.1 (/home/jakub/rust-protobuf-414)
warning: trait objects without an explicit `dyn` are deprecated
  --> src/example.rs:91:26
   |
91 |     fn as_any(&self) -> &::std::any::Any {
   |                          ^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (::std::any::Any)`
   |
   = note: #[warn(bare_trait_objects)] on by default

warning: trait objects without an explicit `dyn` are deprecated
  --> src/example.rs:92:18
   |
92 |         self as &::std::any::Any
   |                  ^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (::std::any::Any)`

warning: trait objects without an explicit `dyn` are deprecated
  --> src/example.rs:94:38
   |
94 |     fn as_any_mut(&mut self) -> &mut ::std::any::Any {
   |                                      ^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (::std::any::Any)`

warning: trait objects without an explicit `dyn` are deprecated
  --> src/example.rs:95:22
   |
95 |         self as &mut ::std::any::Any
   |                      ^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (::std::any::Any)`

warning: trait objects without an explicit `dyn` are deprecated
  --> src/example.rs:97:55
   |
97 |     fn into_any(self: Box<Self>) -> ::std::boxed::Box<::std::any::Any> {
   |                                                       ^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (::std::any::Any)`

    Finished dev [unoptimized + debuginfo] target(s) in 2.98s

@ilblackdragon
Copy link

ilblackdragon commented Jul 18, 2019

Same here for warning: trait objects without an explicit `dyn` are deprecated with 2.7 and Rust 1.37

@stepancheg
Copy link
Owner

stepancheg commented Jul 18, 2019

OK, I see, the problem exists in stable but does not exist in master.

I don't know how to fix in stable.

&dyn ::std::any::Any

This syntax is not valid in edition 2015. And edition 2018 is not available until Rust 1.32.0 (2019-01-17).

Play

So if you know how to fix it, please let me know.

Otherwise, there are two options:

  • set minimum supported version 1.32 (it is 1.27 now)
  • keep warning as is

Thoughts?

@zsluedem
Copy link

I am facing the problem, too.
These warnings(I have 2000+warnings) would heavily trouble people debug.

I am quite new in rust.
How to set minimum supported version 1.32?

@bacek
Copy link
Contributor

bacek commented Jul 22, 2019

I think bumping minimal supported version to 1.32 and switch edition should be fine.

Another options are:

  1. to extend Customize object to explicitly enable dyn Trait generation.
  2. Detect edition in protoc-rust and generate code for it.

@bacek bacek mentioned this issue Jul 22, 2019
@stepancheg
Copy link
Owner

Let's set the minimum version to 1.32 since 2.8. Going to do it now.

@stepancheg
Copy link
Owner

I'll do it now.

@stepancheg
Copy link
Owner

stepancheg commented Jul 23, 2019

OK, stupid me.

It's not enough. &dyn Trait cannot be used even in latest stable in edition 2015.

@stepancheg
Copy link
Owner

stepancheg commented Jul 23, 2019

Got another idea: df9780f.

@stepancheg
Copy link
Owner

Published 2.8.0. Please let me know if it doesn't solve the problem.

@bacek
Copy link
Contributor

bacek commented Jul 23, 2019

Are you sure it's compatible with 2015 edition?

@bacek
Copy link
Contributor

bacek commented Jul 23, 2019

Ah. 1.27. Should be all right.

@stepancheg
Copy link
Owner

Are you sure it's compatible with 2015 edition?

Yes, because the protobuf library and all tests are done against the 2015 edition.

I'm a bit worried about compatibility with 2018 edition. I did basic checks, but there are no automated CI tests.

@bacek
Copy link
Contributor

bacek commented Jul 23, 2019

Works for me in my 2018 edition project.

@feuerste
Copy link

Works for me, too, thanks! You may also add the 2.8.0 release in github?

@stepancheg
Copy link
Owner

@feuerste I forgot to do git push. Thank you for the reminder!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants