Git Product home page Git Product logo

Comments (11)

chrisnc avatar chrisnc commented on July 29, 2024 1

In the real code the &'static self does get used of course, but as I was minimizing it I found that it wasn't necessary to see the warning. The 'static itself is not necessary to see the warning either, but in this case I think the only way to call init in safe rust is with a static, so I included it for clarity.

from rust.

tgross35 avatar tgross35 commented on July 29, 2024

How do you wind up with the &'static self in the original code, is it via FFI? If so, #126169 / #127104 may be relevant. (If this was 1.80 then it happend before that, similar code though).

from rust.

chrisnc avatar chrisnc commented on July 29, 2024

The example I pasted shows how the &'static self is obtained: static FOO: Foo = FOO.init(7);
This part matches exactly what the original code was doing. I'm not using any repr attribute in this example so I'm not sure it's related to those issues (I did notice those while searching for dups). The warning should fire for Foo if the init function didn't exist, but init constructs Foo.

from rust.

tgross35 avatar tgross35 commented on July 29, 2024

Completely missed the example, thanks. This is a pretty weird case considering self is the parameter that doesn't get used.

from rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.