Skip to content

Placing lifetime specifier after &mut emits wall of unhelpful diagnostics #73568

Closed
@SNCPlay42

Description

@SNCPlay42

Playground

fn x<'a>(x: &mut 'a i32){}

Expected result: a diagnostic suggests placing 'a before mut

Actual diagnostic output:

   Compiling playground v0.0.1 (/playground)
error: lifetime in trait object type must be followed by `+`
 --> src/lib.rs:1:18
  |
1 | fn x<'a>(x: &mut 'a i32){}
  |                  ^^

error: expected one of `:`, `@`, or `|`, found `)`
 --> src/lib.rs:1:24
  |
1 | fn x<'a>(x: &mut 'a i32){}
  |                        ^ expected one of `:`, `@`, or `|`
  |
  = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
help: if this was a parameter name, give it a type
  |
1 | fn x<'a>(x: &mut 'a i32: TypeName){}
  |                     ^^^^^^^^^^^^^
help: if this is a type, explicitly ignore the parameter name
  |
1 | fn x<'a>(x: &mut 'a _: i32){}
  |                     ^^^^^^

error: expected one of `)` or `,`, found `i32`
 --> src/lib.rs:1:21
  |
1 | fn x<'a>(x: &mut 'a i32){}
  |                    -^^^ expected one of `)` or `,`
  |                    |
  |                    help: missing `,`

warning: trait objects without an explicit `dyn` are deprecated
 --> src/lib.rs:1:18
  |
1 | fn x<'a>(x: &mut 'a i32){}
  |                  ^^ help: use `dyn`: `dyn 'a`
  |
  = note: `#[warn(bare_trait_objects)]` on by default

error[E0224]: at least one trait is required for an object type
 --> src/lib.rs:1:18
  |
1 | fn x<'a>(x: &mut 'a i32){}
  |                  ^^

error: aborting due to 4 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0224`.
error: could not compile `playground`.

To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.P-highHigh priorityregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions