Skip to content

Using extra lifetime parameter when implementing a trait is allowed #61888

Closed
@bjorn3

Description

@bjorn3
trait Abc {
    fn abc<'tcx>(&self);
}

struct MyAbc;

impl Abc for MyAbc {
    //     vv this lifetime parameter doesn't exist in the original trait
    fn abc<'a, 'tcx>(&self) {}
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
warning: struct is never constructed: `MyAbc`
 --> src/lib.rs:5:1
  |
5 | struct MyAbc;
  | ^^^^^^^^^^^^^
  |
  = note: #[warn(dead_code)] on by default

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions