Git Product home page Git Product logo

Comments (7)

krtab avatar krtab commented on July 19, 2024

@rustbot claim

(cc @GuillaumeGomez )

from rust.

fmease avatar fmease commented on July 19, 2024

Prior art: trimmed_def_paths.

from rust.

krtab avatar krtab commented on July 19, 2024

I don't think trimmed_def_paths does exactly what we want, because in our case, we should trim based on what has already been displayed.

MRE

pub mod Foo {
    pub enum E {}
}

pub mod Bar {
    pub enum E {}
}


pub fn f(foo: Foo::E, bar: Bar::E) {}

gives in doc

pub fn f(foo: E, bar: E)

Now the question is, should it be:

pub fn f(foo: E, bar: Foo::E)
pub fn f(foo: Bar::E, bar: E)

or

pub fn f(foo: Bar::E, bar: Foo::E)

from rust.

fmease avatar fmease commented on July 19, 2024

I think the latter (or was that a rhetorical question lol?)

from rust.

GuillaumeGomez avatar GuillaumeGomez commented on July 19, 2024

I also prefer the latter (whether it's a rhetorical question or not).

from rust.

krtab avatar krtab commented on July 19, 2024

I prefer it as well, but as discussed in #122872 this means that there must be two passes to disambiguate: the first one identifies the non ambiguous suffix of the symbol path, and the second one does the actual rendering. Choosing pub fn f(foo: E, bar: Foo::E) allows us to do it in one pass (a sort of "streaming" disambiguation), which makes it easier to generalize: printing functions must now simply take a context and reset it when appropriate. This context can easily be passed along when we match on the constructs.

If we do the two passes solution, the matching/deconstructing code has to be duplicated (or we go for a full visitor pattern?)

from rust.

GuillaumeGomez avatar GuillaumeGomez commented on July 19, 2024

What information is missing to force it to be done in two passes? Once you have all names in the same context (ie, function arguments, struct fields, etc), you can check that a same type has the same name or not and there disambiguate. If you don't have a context when displaying, then try generating the name ahead of time if needed in the clean pass?

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.