diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-11-01 10:01:42 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-12-04 23:13:58 +0100 |
| commit | d3a6d4b1a00806797d8588e9efd3e133a7e55003 (patch) | |
| tree | 2d110382f8c7017c996cf2c66966e6ae61dc1d5d | |
| parent | 6152b1d7225a45c7814ea6c9e3ea09304268c499 (diff) | |
| download | rust-d3a6d4b1a00806797d8588e9efd3e133a7e55003.tar.gz rust-d3a6d4b1a00806797d8588e9efd3e133a7e55003.zip | |
Use multipart suggestions.
19 files changed, 254 insertions, 62 deletions
diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index 3d449578eb0..73face2b270 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -2617,30 +2617,39 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { if let hir::TyKind::TraitObject([poly_trait_ref, ..], _, TraitObjectSyntax::None) = self_ty.kind { - let (mut sugg, app) = match tcx.sess.source_map().span_to_snippet(self_ty.span) { - Ok(s) if poly_trait_ref.trait_ref.path.is_global() => { - (format!("dyn ({})", s), Applicability::MachineApplicable) - } - Ok(s) => (format!("dyn {}", s), Applicability::MachineApplicable), - Err(_) => ("dyn <type>".to_string(), Applicability::HasPlaceholders), - }; - if in_path { - let has_bracket = tcx + let needs_bracket = in_path + && !tcx .sess .source_map() .span_to_prev_source(self_ty.span) .ok() .map_or(false, |s| s.trim_end().ends_with('<')); - if !has_bracket { - sugg = format!("<{}>", sugg); - } - } + + let is_global = poly_trait_ref.trait_ref.path.is_global(); + let sugg = Vec::from_iter([ + ( + self_ty.span.shrink_to_lo(), + format!( + "{}dyn {}", + if needs_bracket { "<" } else { "" }, + if is_global { "(" } else { "" }, + ), + ), + ( + self_ty.span.shrink_to_hi(), + format!( + "{}{}", + if is_global { ")" } else { "" }, + if needs_bracket { ">" } else { "" }, + ), + ), + ]); if self_ty.span.edition() >= Edition::Edition2021 { let msg = "trait objects must include the `dyn` keyword"; let label = "add `dyn` keyword before this trait"; - let mut err = - rustc_errors::struct_span_err!(tcx.sess, self_ty.span, E0782, "{}", msg); - err.span_suggestion_verbose(self_ty.span, label, sugg, app).emit(); + rustc_errors::struct_span_err!(tcx.sess, self_ty.span, E0782, "{}", msg) + .multipart_suggestion_verbose(label, sugg, Applicability::MachineApplicable) + .emit(); } else { let msg = "trait objects without an explicit `dyn` are deprecated"; tcx.struct_span_lint_hir( @@ -2648,9 +2657,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { self_ty.hir_id, self_ty.span, |lint| { - let mut db = lint.build(msg); - db.span_suggestion(self_ty.span, "use `dyn`", sugg, app); - db.emit() + lint.build(msg) + .multipart_suggestion_verbose( + "use `dyn`", + sugg, + Applicability::MachineApplicable, + ) + .emit() }, ); } diff --git a/src/test/ui/did_you_mean/bad-assoc-ty.stderr b/src/test/ui/did_you_mean/bad-assoc-ty.stderr index fc63e379eb8..11514a28b2c 100644 --- a/src/test/ui/did_you_mean/bad-assoc-ty.stderr +++ b/src/test/ui/did_you_mean/bad-assoc-ty.stderr @@ -103,11 +103,15 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/bad-assoc-ty.rs:33:10 | LL | type H = Fn(u8) -> (u8)::Output; - | ^^^^^^^^^^^^^^ help: use `dyn`: `<dyn Fn(u8) -> (u8)>` + | ^^^^^^^^^^^^^^ | = note: `#[warn(bare_trait_objects)]` on by default = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL | type H = <dyn Fn(u8) -> (u8)>::Output; + | ++++ + error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:33:10 diff --git a/src/test/ui/dyn-keyword/dyn-2018-edition-lint.stderr b/src/test/ui/dyn-keyword/dyn-2018-edition-lint.stderr index 13d7185041a..7e9435efb08 100644 --- a/src/test/ui/dyn-keyword/dyn-2018-edition-lint.stderr +++ b/src/test/ui/dyn-keyword/dyn-2018-edition-lint.stderr @@ -2,7 +2,7 @@ error: trait objects without an explicit `dyn` are deprecated --> $DIR/dyn-2018-edition-lint.rs:4:17 | LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) { - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | note: the lint level is defined here --> $DIR/dyn-2018-edition-lint.rs:2:8 @@ -11,15 +11,25 @@ LL | #[deny(bare_trait_objects)] | ^^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) { +LL + fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) { + | error: trait objects without an explicit `dyn` are deprecated --> $DIR/dyn-2018-edition-lint.rs:4:35 | LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) { - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) { +LL + fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) { + | error: aborting due to 2 previous errors diff --git a/src/test/ui/dyn-keyword/dyn-2021-edition-error.stderr b/src/test/ui/dyn-keyword/dyn-2021-edition-error.stderr index ea1baf01ed4..b5bc359d716 100644 --- a/src/test/ui/dyn-keyword/dyn-2021-edition-error.stderr +++ b/src/test/ui/dyn-keyword/dyn-2021-edition-error.stderr @@ -6,8 +6,9 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) { | help: add `dyn` keyword before this trait | -LL | fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) { - | ~~~~~~~~~~~~~ +LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) { +LL + fn function(x: &dyn SomeTrait, y: Box<SomeTrait>) { + | error[E0782]: trait objects must include the `dyn` keyword --> $DIR/dyn-2021-edition-error.rs:3:35 @@ -17,8 +18,9 @@ LL | fn function(x: &SomeTrait, y: Box<SomeTrait>) { | help: add `dyn` keyword before this trait | -LL | fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) { - | ~~~~~~~~~~~~~ +LL - fn function(x: &SomeTrait, y: Box<SomeTrait>) { +LL + fn function(x: &SomeTrait, y: Box<dyn SomeTrait>) { + | error: aborting due to 2 previous errors diff --git a/src/test/ui/dyn-keyword/dyn-angle-brackets.stderr b/src/test/ui/dyn-keyword/dyn-angle-brackets.stderr index 1f5a10223f1..fd4030e9622 100644 --- a/src/test/ui/dyn-keyword/dyn-angle-brackets.stderr +++ b/src/test/ui/dyn-keyword/dyn-angle-brackets.stderr @@ -2,7 +2,7 @@ error: trait objects without an explicit `dyn` are deprecated --> $DIR/dyn-angle-brackets.rs:15:10 | LL | <fmt::Debug>::fmt(self, f) - | ^^^^^^^^^^ help: use `dyn`: `dyn fmt::Debug` + | ^^^^^^^^^^ | note: the lint level is defined here --> $DIR/dyn-angle-brackets.rs:4:9 @@ -11,6 +11,11 @@ LL | #![deny(bare_trait_objects)] | ^^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - <fmt::Debug>::fmt(self, f) +LL + <dyn fmt::Debug>::fmt(self, f) + | error: aborting due to previous error diff --git a/src/test/ui/editions/dyn-trait-sugg-2021.stderr b/src/test/ui/editions/dyn-trait-sugg-2021.stderr index 9d1d2d7c51e..8c68dec1df7 100644 --- a/src/test/ui/editions/dyn-trait-sugg-2021.stderr +++ b/src/test/ui/editions/dyn-trait-sugg-2021.stderr @@ -7,7 +7,7 @@ LL | Foo::hi(123); help: add `dyn` keyword before this trait | LL | <dyn Foo>::hi(123); - | ~~~~~~~~~ + | ++++ + error: aborting due to previous error diff --git a/src/test/ui/issues/issue-28344.stderr b/src/test/ui/issues/issue-28344.stderr index 1582ef23731..b1d1c01b27a 100644 --- a/src/test/ui/issues/issue-28344.stderr +++ b/src/test/ui/issues/issue-28344.stderr @@ -2,11 +2,15 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/issue-28344.rs:4:17 | LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); - | ^^^^^^ help: use `dyn`: `<dyn BitXor>` + | ^^^^^^ | = note: `#[warn(bare_trait_objects)]` on by default = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL | let x: u8 = <dyn BitXor>::bitor(0 as u8, 0 as u8); + | ++++ + error[E0191]: the value of the associated type `Output` (from trait `BitXor`) must be specified --> $DIR/issue-28344.rs:4:17 @@ -27,10 +31,14 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/issue-28344.rs:10:13 | LL | let g = BitXor::bitor; - | ^^^^^^ help: use `dyn`: `<dyn BitXor>` + | ^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL | let g = <dyn BitXor>::bitor; + | ++++ + error[E0191]: the value of the associated type `Output` (from trait `BitXor`) must be specified --> $DIR/issue-28344.rs:10:13 diff --git a/src/test/ui/issues/issue-58734.stderr b/src/test/ui/issues/issue-58734.stderr index 61d0a2796e9..a91a1b3778e 100644 --- a/src/test/ui/issues/issue-58734.stderr +++ b/src/test/ui/issues/issue-58734.stderr @@ -2,11 +2,15 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/issue-58734.rs:20:5 | LL | Trait::nonexistent(()); - | ^^^^^ help: use `dyn`: `<dyn Trait>` + | ^^^^^ | = note: `#[warn(bare_trait_objects)]` on by default = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL | <dyn Trait>::nonexistent(()); + | ++++ + error[E0599]: no function or associated item named `nonexistent` found for trait object `dyn Trait` in the current scope --> $DIR/issue-58734.rs:20:12 diff --git a/src/test/ui/issues/issue-86756.stderr b/src/test/ui/issues/issue-86756.stderr index 0d576909a35..5b2f04ffa83 100644 --- a/src/test/ui/issues/issue-86756.stderr +++ b/src/test/ui/issues/issue-86756.stderr @@ -18,11 +18,16 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/issue-86756.rs:5:15 | LL | eq::<dyn, Foo> - | ^^^ help: use `dyn`: `dyn Foo` + | ^^^ | = note: `#[warn(bare_trait_objects)]` on by default = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - eq::<dyn, Foo> +LL + eq::<dyn, dyn Foo> + | error[E0107]: missing generics for trait `Foo` --> $DIR/issue-86756.rs:5:15 diff --git a/src/test/ui/lint/bare-trait-objects-path.stderr b/src/test/ui/lint/bare-trait-objects-path.stderr index cbc0fada65a..4b8c2b539d5 100644 --- a/src/test/ui/lint/bare-trait-objects-path.stderr +++ b/src/test/ui/lint/bare-trait-objects-path.stderr @@ -2,11 +2,15 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/bare-trait-objects-path.rs:23:12 | LL | let _: Dyn::Ty; - | ^^^ help: use `dyn`: `<dyn Dyn>` + | ^^^ | = note: `#[warn(bare_trait_objects)]` on by default = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL | let _: <dyn Dyn>::Ty; + | ++++ + error[E0223]: ambiguous associated type --> $DIR/bare-trait-objects-path.rs:23:12 @@ -18,28 +22,40 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/bare-trait-objects-path.rs:14:5 | LL | Dyn::func(); - | ^^^ help: use `dyn`: `<dyn Dyn>` + | ^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL | <dyn Dyn>::func(); + | ++++ + warning: trait objects without an explicit `dyn` are deprecated --> $DIR/bare-trait-objects-path.rs:17:5 | LL | ::Dyn::func(); - | ^^^^^ help: use `dyn`: `<dyn (::Dyn)>` + | ^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL | <dyn (::Dyn)>::func(); + | ++++++ ++ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/bare-trait-objects-path.rs:20:5 | LL | Dyn::CONST; - | ^^^ help: use `dyn`: `<dyn Dyn>` + | ^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL | <dyn Dyn>::CONST; + | ++++ + error: aborting due to previous error; 4 warnings emitted diff --git a/src/test/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr b/src/test/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr index 4ad8306d00c..99d97ba52a0 100644 --- a/src/test/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr +++ b/src/test/ui/lint/force-warn/allowed-group-warn-by-default-lint.stderr @@ -2,29 +2,44 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/allowed-group-warn-by-default-lint.rs:10:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = note: requested on the command line with `--force-warn bare-trait-objects` = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: trait objects without an explicit `dyn` are deprecated --> $DIR/allowed-group-warn-by-default-lint.rs:10:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: trait objects without an explicit `dyn` are deprecated --> $DIR/allowed-group-warn-by-default-lint.rs:10:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: 3 warnings emitted diff --git a/src/test/ui/lint/force-warn/cap-lints-allow.stderr b/src/test/ui/lint/force-warn/cap-lints-allow.stderr index 3d850cdf94a..90496ca7d20 100644 --- a/src/test/ui/lint/force-warn/cap-lints-allow.stderr +++ b/src/test/ui/lint/force-warn/cap-lints-allow.stderr @@ -2,29 +2,44 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/cap-lints-allow.rs:8:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = note: requested on the command line with `--force-warn bare-trait-objects` = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: trait objects without an explicit `dyn` are deprecated --> $DIR/cap-lints-allow.rs:8:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: trait objects without an explicit `dyn` are deprecated --> $DIR/cap-lints-allow.rs:8:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: 3 warnings emitted diff --git a/src/test/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr b/src/test/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr index ad61da95df1..b6d36eaac44 100644 --- a/src/test/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr +++ b/src/test/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr @@ -2,29 +2,44 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/lint-group-allowed-cli-warn-by-default-lint.rs:8:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: trait objects without an explicit `dyn` are deprecated --> $DIR/lint-group-allowed-cli-warn-by-default-lint.rs:8:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: trait objects without an explicit `dyn` are deprecated --> $DIR/lint-group-allowed-cli-warn-by-default-lint.rs:8:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: 3 warnings emitted diff --git a/src/test/ui/lint/force-warn/lint-group-allowed-lint-group.stderr b/src/test/ui/lint/force-warn/lint-group-allowed-lint-group.stderr index 9e00384a23d..e8fdaa72cc0 100644 --- a/src/test/ui/lint/force-warn/lint-group-allowed-lint-group.stderr +++ b/src/test/ui/lint/force-warn/lint-group-allowed-lint-group.stderr @@ -2,29 +2,44 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/lint-group-allowed-lint-group.rs:10:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: trait objects without an explicit `dyn` are deprecated --> $DIR/lint-group-allowed-lint-group.rs:10:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: trait objects without an explicit `dyn` are deprecated --> $DIR/lint-group-allowed-lint-group.rs:10:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: 3 warnings emitted diff --git a/src/test/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr b/src/test/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr index ed042609d15..2de30d0c2f4 100644 --- a/src/test/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr +++ b/src/test/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr @@ -2,29 +2,44 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms` = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: trait objects without an explicit `dyn` are deprecated --> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: trait objects without an explicit `dyn` are deprecated --> $DIR/lint-group-allowed-warn-by-default-lint.rs:10:25 | LL | pub fn function(_x: Box<SomeTrait>) {} - | ^^^^^^^^^ help: use `dyn`: `dyn SomeTrait` + | ^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub fn function(_x: Box<SomeTrait>) {} +LL + pub fn function(_x: Box<dyn SomeTrait>) {} + | warning: 3 warnings emitted diff --git a/src/test/ui/parser/trait-object-trait-parens.stderr b/src/test/ui/parser/trait-object-trait-parens.stderr index bce40edfcd2..a852337b6fe 100644 --- a/src/test/ui/parser/trait-object-trait-parens.stderr +++ b/src/test/ui/parser/trait-object-trait-parens.stderr @@ -20,11 +20,16 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/trait-object-trait-parens.rs:8:16 | LL | let _: Box<(Obj) + (?Sized) + (for<'a> Trait<'a>)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn (Obj) + (?Sized) + (for<'a> Trait<'a>)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(bare_trait_objects)]` on by default = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - let _: Box<(Obj) + (?Sized) + (for<'a> Trait<'a>)>; +LL + let _: Box<dyn (Obj) + (?Sized) + (for<'a> Trait<'a>)>; + | error[E0225]: only auto traits can be used as additional traits in a trait object --> $DIR/trait-object-trait-parens.rs:8:35 @@ -41,10 +46,15 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/trait-object-trait-parens.rs:13:16 | LL | let _: Box<?Sized + (for<'a> Trait<'a>) + (Obj)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn ?Sized + (for<'a> Trait<'a>) + (Obj)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - let _: Box<?Sized + (for<'a> Trait<'a>) + (Obj)>; +LL + let _: Box<dyn ?Sized + (for<'a> Trait<'a>) + (Obj)>; + | error[E0225]: only auto traits can be used as additional traits in a trait object --> $DIR/trait-object-trait-parens.rs:13:47 @@ -61,10 +71,15 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/trait-object-trait-parens.rs:18:16 | LL | let _: Box<for<'a> Trait<'a> + (Obj) + (?Sized)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn for<'a> Trait<'a> + (Obj) + (?Sized)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - let _: Box<for<'a> Trait<'a> + (Obj) + (?Sized)>; +LL + let _: Box<dyn for<'a> Trait<'a> + (Obj) + (?Sized)>; + | error[E0225]: only auto traits can be used as additional traits in a trait object --> $DIR/trait-object-trait-parens.rs:18:36 diff --git a/src/test/ui/suggestions/issue-61963.stderr b/src/test/ui/suggestions/issue-61963.stderr index bb487920e3b..7dfd8c32708 100644 --- a/src/test/ui/suggestions/issue-61963.stderr +++ b/src/test/ui/suggestions/issue-61963.stderr @@ -2,7 +2,7 @@ error: trait objects without an explicit `dyn` are deprecated --> $DIR/issue-61963.rs:22:14 | LL | bar: Box<Bar>, - | ^^^ help: use `dyn`: `dyn Bar` + | ^^^ | note: the lint level is defined here --> $DIR/issue-61963.rs:3:9 @@ -11,15 +11,25 @@ LL | #![deny(bare_trait_objects)] | ^^^^^^^^^^^^^^^^^^ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - bar: Box<Bar>, +LL + bar: Box<dyn Bar>, + | error: trait objects without an explicit `dyn` are deprecated --> $DIR/issue-61963.rs:18:1 | LL | pub struct Foo { - | ^^^ help: use `dyn`: `dyn pub` + | ^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - pub struct Foo { +LL + dyn pub struct Foo { + | error: aborting due to 2 previous errors diff --git a/src/test/ui/traits/bound/not-on-bare-trait.stderr b/src/test/ui/traits/bound/not-on-bare-trait.stderr index 0bbf1bffda5..08f6d166d22 100644 --- a/src/test/ui/traits/bound/not-on-bare-trait.stderr +++ b/src/test/ui/traits/bound/not-on-bare-trait.stderr @@ -2,11 +2,16 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/not-on-bare-trait.rs:7:12 | LL | fn foo(_x: Foo + Send) { - | ^^^^^^^^^^ help: use `dyn`: `dyn Foo + Send` + | ^^^^^^^^^^ | = note: `#[warn(bare_trait_objects)]` on by default = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL - fn foo(_x: Foo + Send) { +LL + fn foo(_x: dyn Foo + Send) { + | error[E0277]: the size for values of type `(dyn Foo + Send + 'static)` cannot be known at compilation time --> $DIR/not-on-bare-trait.rs:7:8 diff --git a/src/test/ui/unspecified-self-in-trait-ref.stderr b/src/test/ui/unspecified-self-in-trait-ref.stderr index e6e824ec5dc..2ba92187157 100644 --- a/src/test/ui/unspecified-self-in-trait-ref.stderr +++ b/src/test/ui/unspecified-self-in-trait-ref.stderr @@ -2,11 +2,15 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/unspecified-self-in-trait-ref.rs:10:13 | LL | let a = Foo::lol(); - | ^^^ help: use `dyn`: `<dyn Foo>` + | ^^^ | = note: `#[warn(bare_trait_objects)]` on by default = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL | let a = <dyn Foo>::lol(); + | ++++ + error[E0599]: no function or associated item named `lol` found for trait object `dyn Foo<_>` in the current scope --> $DIR/unspecified-self-in-trait-ref.rs:10:18 @@ -18,10 +22,14 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/unspecified-self-in-trait-ref.rs:14:13 | LL | let b = Foo::<_>::lol(); - | ^^^^^^^^ help: use `dyn`: `<dyn Foo::<_>>` + | ^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL | let b = <dyn Foo::<_>>::lol(); + | ++++ + error[E0599]: no function or associated item named `lol` found for trait object `dyn Foo<_>` in the current scope --> $DIR/unspecified-self-in-trait-ref.rs:14:23 @@ -33,10 +41,14 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/unspecified-self-in-trait-ref.rs:18:13 | LL | let c = Bar::lol(); - | ^^^ help: use `dyn`: `<dyn Bar>` + | ^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL | let c = <dyn Bar>::lol(); + | ++++ + error[E0599]: no function or associated item named `lol` found for trait object `dyn Bar<_, _>` in the current scope --> $DIR/unspecified-self-in-trait-ref.rs:18:18 @@ -48,10 +60,14 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/unspecified-self-in-trait-ref.rs:22:13 | LL | let d = Bar::<usize, _>::lol(); - | ^^^^^^^^^^^^^^^ help: use `dyn`: `<dyn Bar::<usize, _>>` + | ^^^^^^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL | let d = <dyn Bar::<usize, _>>::lol(); + | ++++ + error[E0599]: no function or associated item named `lol` found for trait object `dyn Bar<usize, _>` in the current scope --> $DIR/unspecified-self-in-trait-ref.rs:22:30 @@ -63,10 +79,14 @@ warning: trait objects without an explicit `dyn` are deprecated --> $DIR/unspecified-self-in-trait-ref.rs:26:13 | LL | let e = Bar::<usize>::lol(); - | ^^^^^^^^^^^^ help: use `dyn`: `<dyn Bar::<usize>>` + | ^^^^^^^^^^^^ | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html> +help: use `dyn` + | +LL | let e = <dyn Bar::<usize>>::lol(); + | ++++ + error[E0393]: the type parameter `A` must be explicitly specified --> $DIR/unspecified-self-in-trait-ref.rs:26:13 |
