Skip to content

Hint when using a static method on an instance is wrong #29121

Description

@jdm

I wrote Box::new(telemetry_t::new()).into_raw() and got this output:

src/lib.rs:41:34: 41:44 error: no method named `into_raw` found for type `Box<telemetry_t>` in the current scope
src/lib.rs:41     Box::new(telemetry_t::new()).into_raw()
                                               ^~~~~~~~~~
src/lib.rs:41:34: 41:44 note: found defined static methods, maybe a `self` is missing?
src/lib.rs:41:34: 41:44 note: candidate #1 is defined in an impl for the type `Box<_>`
src/lib.rs:41     Box::new(telemetry_t::new()).into_raw()
                                               ^~~~~~~~~~

The hint in particular was confusing, since it is targeted at developers who created the impl and forgot to provide a self argument, rather than consumers of an impl that is specifically designed to be static.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions