Skip to content

Bug: impl block with generics #16

@Banyc

Description

@Banyc
pub struct G<T> {
    buf: Vec<T>,
}
#[bon::bon]
impl<T> G<T> {
    #[builder]
    pub fn new() -> Self {
        Self { buf: vec![] }
    }
}

Error msg:

error[E0392]: type parameter `T` is never used
 --> src/lib.rs:5:6
  |
5 | impl<T> G<T> {
  |      ^
  |      |
  |      unused type parameter
  |      `T` is named here, but is likely unused in the containing type
  |
  = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
  = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead

error[E0392]: type parameter `T` is never used
 --> src/lib.rs:5:6
  |
5 | impl<T> G<T> {
  |      ^ unused type parameter
  |
  = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
  = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead

error[E0282]: type annotations needed
 --> src/lib.rs:4:1
  |
4 | #[bon::bon]
  | ^^^^^^^^^^^ cannot infer type
  |
  = note: this error originates in the attribute macro `bon::bon` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0282, E0392.
For more information about an error, try `rustc --explain E0282`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions