fix impl trait message, bless tests · rust-lang/rust@207fb5f (original) (raw)
File tree
31 files changed
lines changed
- compiler/rustc_ast_lowering/src
31 files changed
lines changed
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -297,7 +297,7 @@ impl std::fmt::Display for ImplTraitPosition { | ||
| 297 | 297 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 298 | 298 | let name = match self { |
| 299 | 299 | ImplTraitPosition::Path => "path", |
| 300 | -ImplTraitPosition::Variable => "variable", | |
| 300 | +ImplTraitPosition::Variable => "variable binding", | |
| 301 | 301 | ImplTraitPosition::Type => "type", |
| 302 | 302 | ImplTraitPosition::Trait => "trait", |
| 303 | 303 | ImplTraitPosition::AsyncBlock => "async block", |
| @@ -1419,10 +1419,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { | ||
| 1419 | 1419 | self.sess, |
| 1420 | 1420 | t.span, |
| 1421 | 1421 | E0562, |
| 1422 | -"`impl Trait` not allowed outside of \ | |
| 1423 | - function and inherent method return types", | |
| 1422 | +"`impl Trait` only allowed in function and inherent method return types, not in {}", | |
| 1423 | +position | |
| 1424 | 1424 | ); |
| 1425 | - err.note(&format!("found `impl Trait` in {}", position)); | |
| 1426 | 1425 | err.emit(); |
| 1427 | 1426 | hir::TyKind::Err |
| 1428 | 1427 | } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -57,20 +57,20 @@ fn _rpit_dyn() -> Box<dyn Tr1<As1: Copy>> { Box::new(S1) } | ||
| 57 | 57 | |
| 58 | 58 | const _cdef: impl Tr1<As1: Copy> = S1; |
| 59 | 59 | //~^ ERROR associated type bounds are unstable |
| 60 | -//~| ERROR `impl Trait` not allowed outside of function and inherent method return types [E0562] | |
| 60 | +//~| ERROR `impl Trait` only allowed in function and inherent method return types | |
| 61 | 61 | // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. |
| 62 | 62 | // const _cdef_dyn: &dyn Tr1<As1: Copy> = &S1; |
| 63 | 63 | |
| 64 | 64 | static _sdef: impl Tr1<As1: Copy> = S1; |
| 65 | 65 | //~^ ERROR associated type bounds are unstable |
| 66 | -//~| ERROR `impl Trait` not allowed outside of function and inherent method return types [E0562] | |
| 66 | +//~| ERROR `impl Trait` only allowed in function and inherent method return types | |
| 67 | 67 | // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. |
| 68 | 68 | // static _sdef_dyn: &dyn Tr1<As1: Copy> = &S1; |
| 69 | 69 | |
| 70 | 70 | fn main() { |
| 71 | 71 | let _: impl Tr1<As1: Copy> = S1; |
| 72 | 72 | //~^ ERROR associated type bounds are unstable |
| 73 | -//~| ERROR `impl Trait` not allowed outside of function and inherent method return types [E0562] | |
| 73 | +//~| ERROR `impl Trait` only allowed in function and inherent method return types | |
| 74 | 74 | // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. |
| 75 | 75 | // let _: &dyn Tr1<As1: Copy> = &S1; |
| 76 | 76 | } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -115,29 +115,23 @@ LL | let _: impl Tr1<As1: Copy> = S1; | ||
| 115 | 115 | = note: see issue #52662 https://github.com/rust-lang/rust/issues/52662 for more information |
| 116 | 116 | = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable |
| 117 | 117 | |
| 118 | -error[E0562]: `impl Trait` not allowed outside of function and inherent method return types | |
| 118 | +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type | |
| 119 | 119 | --> $DIR/feature-gate-associated_type_bounds.rs:58:14 |
| 120 | 120 | | |
| 121 | 121 | LL | const _cdef: impl Tr1<As1: Copy> = S1; |
| 122 | 122 | | ^^^^^^^^^^^^^^^^^^^ |
| 123 | - | | |
| 124 | - = note: found `impl Trait` in type | |
| 125 | 123 | |
| 126 | -error[E0562]: `impl Trait` not allowed outside of function and inherent method return types | |
| 124 | +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type | |
| 127 | 125 | --> $DIR/feature-gate-associated_type_bounds.rs:64:15 |
| 128 | 126 | | |
| 129 | 127 | LL | static _sdef: impl Tr1<As1: Copy> = S1; |
| 130 | 128 | | ^^^^^^^^^^^^^^^^^^^ |
| 131 | - | | |
| 132 | - = note: found `impl Trait` in type | |
| 133 | 129 | |
| 134 | -error[E0562]: `impl Trait` not allowed outside of function and inherent method return types | |
| 130 | +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding | |
| 135 | 131 | --> $DIR/feature-gate-associated_type_bounds.rs:71:12 |
| 136 | 132 | | |
| 137 | 133 | LL | let _: impl Tr1<As1: Copy> = S1; |
| 138 | 134 | | ^^^^^^^^^^^^^^^^^^^ |
| 139 | - | | |
| 140 | - = note: found `impl Trait` in variable | |
| 141 | 135 | |
| 142 | 136 | error[E0277]: the trait bound `<<Self as _Tr3>::A as Iterator>::Item: Copy` is not satisfied |
| 143 | 137 | --> $DIR/feature-gate-associated_type_bounds.rs:15:28 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,6 +2,6 @@ use std::fmt::Debug; | ||
| 2 | 2 | |
| 3 | 3 | fn main() { |
| 4 | 4 | let x: Option<impl Debug> = Some(44_u32); |
| 5 | -//~^ `impl Trait` not allowed outside of function and inherent method return types | |
| 5 | +//~^ `impl Trait` only allowed in function and inherent method return types | |
| 6 | 6 | println!("{:?}", x); |
| 7 | 7 | } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,8 @@ | ||
| 1 | -error[E0562]: `impl Trait` not allowed outside of function and inherent method return types | |
| 1 | +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding | |
| 2 | 2 | --> $DIR/issue-54600.rs:4:19 |
| 3 | 3 | | |
| 4 | 4 | LL | let x: Option = Some(44_u32); |
| 5 | 5 | | ^^^^^^^^^^ |
| 6 | - | | |
| 7 | - = note: found `impl Trait` in variable | |
| 8 | 6 | |
| 9 | 7 | error: aborting due to previous error |
| 10 | 8 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3,5 +3,5 @@ use std::ops::Add; | ||
| 3 | 3 | fn main() { |
| 4 | 4 | let i: i32 = 0; |
| 5 | 5 | let j: &impl Add = &i; |
| 6 | -//~^ `impl Trait` not allowed outside of function and inherent method return types | |
| 6 | +//~^ `impl Trait` only allowed in function and inherent method return types | |
| 7 | 7 | } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,8 @@ | ||
| 1 | -error[E0562]: `impl Trait` not allowed outside of function and inherent method return types | |
| 1 | +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding | |
| 2 | 2 | --> $DIR/issue-54840.rs:5:13 |
| 3 | 3 | | |
| 4 | 4 | LL | let j: &impl Add = &i; |
| 5 | 5 | | ^^^^^^^^ |
| 6 | - | | |
| 7 | - = note: found `impl Trait` in variable | |
| 8 | 6 | |
| 9 | 7 | error: aborting due to previous error |
| 10 | 8 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -8,5 +8,5 @@ fn mk_gen() -> impl Generator<Return=!, Yield=()> { | ||
| 8 | 8 | |
| 9 | 9 | fn main() { |
| 10 | 10 | let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ]; |
| 11 | -//~^ `impl Trait` not allowed outside of function and inherent method return types | |
| 11 | +//~^ `impl Trait` only allowed in function and inherent method return types | |
| 12 | 12 | } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,8 @@ | ||
| 1 | -error[E0562]: `impl Trait` not allowed outside of function and inherent method return types | |
| 1 | +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding | |
| 2 | 2 | --> $DIR/issue-58504.rs:10:16 |
| 3 | 3 | | |
| 4 | 4 | LL | let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ]; |
| 5 | 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 6 | - | | |
| 7 | - = note: found `impl Trait` in variable | |
| 8 | 6 | |
| 9 | 7 | error: aborting due to previous error |
| 10 | 8 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -5,9 +5,9 @@ impl Lam for B {} | ||
| 5 | 5 | pub struct Wrap<T>(T); |
| 6 | 6 | |
| 7 | 7 | const _A: impl Lam = { |
| 8 | -//~^ `impl Trait` not allowed outside of function and inherent method return types | |
| 8 | +//~^ `impl Trait` only allowed in function and inherent method return types | |
| 9 | 9 | let x: Wrap<impl Lam> = Wrap(B); |
| 10 | -//~^ `impl Trait` not allowed outside of function and inherent method return types | |
| 10 | +//~^ `impl Trait` only allowed in function and inherent method return types | |
| 11 | 11 | x.0 |
| 12 | 12 | }; |
| 13 | 13 |