Giter VIP home page Giter VIP logo

Comments (3)

WaffleLapkin avatar WaffleLapkin commented on August 23, 2024 1

@EsotericPyramid you can actually call a function like Trait::func(), the same way you can do <_ as Trait>::func(). So the dyn object stuff is a result of a bad recovery most likely.

Your second point is good though, thanks. The fact that Trait::assoc can only refer to items of Trait, to allow disambiguation in cases where super traits have associated items named the same make sense to me. However, as @workingjubilee said, confusing diagnostics are still bugs, and these diagnostics are very confusing.

from rust.

EsotericPyramid avatar EsotericPyramid commented on August 23, 2024

I don’t believe this actually a bug at all.

  1. That’s not how you call associated functions. The syntax for that is Type::func() not Trait::func(). That’s why the compiler gives notes about making a dynamic trait object because that would give you an actual type for the correct syntax. If you could call associated functions with the Trait::func syntax then it may be impossible for the compiler to pick an implementation as multiple implementations for different types could have identical signatures (not in this particular case)
  2. assoc is not part of the Sub trait, it is required by it so <T as Sub>::assoc() wouldn’t work but <T as Super>::assoc() should. This is important as it allows both Sub and Super to have an associated function with the same name.

from rust.

workingjubilee avatar workingjubilee commented on August 23, 2024

confusing diagnostics are still bugs.

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.