Rollup merge of #116431 - estebank:issue-80476, r=compiler-errors · rust-lang/rust@d7b02c3

40 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -99,7 +99,7 @@ ast_lowering_misplaced_double_dot =

9999

.note = only allowed in tuple, tuple struct, and slice patterns

100100
101101

ast_lowering_misplaced_impl_trait =

102-

`impl Trait` only allowed in function and inherent method return types, not in {$position}

102+

`impl Trait` only allowed in function and inherent method argument and return types, not in {$position}

103103
104104

ast_lowering_misplaced_relax_trait_bound =

105105

`?Trait` bounds are only permitted at the point where a type parameter is declared

Original file line numberDiff line numberDiff line change

@@ -33,7 +33,7 @@ LL | fn main<A: TraitWAssocConst<A=32>>() {

3333

= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information

3434

= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable

3535
36-

error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in impl headers

36+

error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in impl headers

3737

--> $DIR/issue-105330.rs:6:27

3838

|

3939

LL | impl TraitWAssocConst for impl Demo {

Original file line numberDiff line numberDiff line change

@@ -11,7 +11,7 @@ trait MyTrait {

1111
1212

impl MyTrait for i32 {

1313

fn foo(&self) -> impl Future<Output = i32> {

14-

//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types

14+

//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in `impl` method return types

1515

async { *self }

1616

}

1717

}

Original file line numberDiff line numberDiff line change

@@ -1,4 +1,4 @@

1-

error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types

1+

error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `impl` method return types

22

--> $DIR/fn-not-async-err2.rs:13:22

33

|

44

LL | fn foo(&self) -> impl Future<Output = i32> {

Original file line numberDiff line numberDiff line change

@@ -54,20 +54,20 @@ fn _rpit_dyn() -> Box<dyn Tr1<As1: Copy>> { Box::new(S1) }

5454
5555

const _cdef: impl Tr1<As1: Copy> = S1;

5656

//~^ ERROR associated type bounds are unstable

57-

//~| ERROR `impl Trait` only allowed in function and inherent method return types

57+

//~| ERROR `impl Trait` only allowed in function and inherent method argument and return types

5858

// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed.

5959

// const _cdef_dyn: &dyn Tr1<As1: Copy> = &S1;

6060
6161

static _sdef: impl Tr1<As1: Copy> = S1;

6262

//~^ ERROR associated type bounds are unstable

63-

//~| ERROR `impl Trait` only allowed in function and inherent method return types

63+

//~| ERROR `impl Trait` only allowed in function and inherent method argument and return types

6464

// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed.

6565

// static _sdef_dyn: &dyn Tr1<As1: Copy> = &S1;

6666
6767

fn main() {

6868

let _: impl Tr1<As1: Copy> = S1;

6969

//~^ ERROR associated type bounds are unstable

70-

//~| ERROR `impl Trait` only allowed in function and inherent method return types

70+

//~| ERROR `impl Trait` only allowed in function and inherent method argument and return types

7171

// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed.

7272

// let _: &dyn Tr1<As1: Copy> = &S1;

7373

}

Original file line numberDiff line numberDiff line change

@@ -115,19 +115,19 @@ LL | let _: impl Tr1<As1: Copy> = S1;

115115

= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information

116116

= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable

117117
118-

error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in const types

118+

error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in const types

119119

--> $DIR/feature-gate-associated_type_bounds.rs:55:14

120120

|

121121

LL | const _cdef: impl Tr1<As1: Copy> = S1;

122122

| ^^^^^^^^^^^^^^^^^^^

123123
124-

error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in const types

124+

error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in const types

125125

--> $DIR/feature-gate-associated_type_bounds.rs:61:15

126126

|

127127

LL | static _sdef: impl Tr1<As1: Copy> = S1;

128128

| ^^^^^^^^^^^^^^^^^^^

129129
130-

error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings

130+

error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings

131131

--> $DIR/feature-gate-associated_type_bounds.rs:68:12

132132

|

133133

LL | let _: impl Tr1<As1: Copy> = S1;

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,6 @@

11

fn f() -> impl Fn() -> impl Sized { || () }

2-

//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return

2+

//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return

33

fn g() -> &'static dyn Fn() -> impl Sized { &|| () }

4-

//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return

4+

//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return

55
66

fn main() {}

Original file line numberDiff line numberDiff line change

@@ -1,4 +1,4 @@

1-

error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types

1+

error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types

22

--> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:1:24

33

|

44

LL | fn f() -> impl Fn() -> impl Sized { || () }

@@ -7,7 +7,7 @@ LL | fn f() -> impl Fn() -> impl Sized { || () }

77

= note: see issue #99697 <https://github.com/rust-lang/rust/issues/99697> for more information

88

= help: add `#![feature(impl_trait_in_fn_trait_return)]` to the crate attributes to enable

99
10-

error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types

10+

error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types

1111

--> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:3:32

1212

|

1313

LL | fn g() -> &'static dyn Fn() -> impl Sized { &|| () }

Original file line numberDiff line numberDiff line change

@@ -5,14 +5,14 @@

55

#![feature(async_fn_in_trait)]

66
77

trait Foo {

8-

fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return

9-

fn baz() -> Box<impl std::fmt::Display>; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return

8+

fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return

9+

fn baz() -> Box<impl std::fmt::Display>; //~ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return

1010

}

1111
1212

// Both return_position_impl_trait_in_trait and async_fn_in_trait are required for this (see also

1313

// feature-gate-async_fn_in_trait.rs)

1414

trait AsyncFoo {

15-

async fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return

15+

async fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return

1616

}

1717
1818

fn main() {}

Original file line numberDiff line numberDiff line change

@@ -1,4 +1,4 @@

1-

error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return types

1+

error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return types

22

--> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:8:17

33

|

44

LL | fn bar() -> impl Sized;

@@ -7,7 +7,7 @@ LL | fn bar() -> impl Sized;

77

= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information

88

= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable

99
10-

error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return types

10+

error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return types

1111

--> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:9:21

1212

|

1313

LL | fn baz() -> Box<impl std::fmt::Display>;

@@ -16,7 +16,7 @@ LL | fn baz() -> Box<impl std::fmt::Display>;

1616

= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information

1717

= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable

1818
19-

error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return types

19+

error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return types

2020

--> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:15:23

2121

|

2222

LL | async fn bar() -> impl Sized;