-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Don't show two different types as the same thing in a single function #122673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@rustbot claim (cc @GuillaumeGomez ) |
Prior art: |
I don't think 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) |
I think the latter (or was that a rhetorical question lol?) |
I also prefer the latter (whether it's a rhetorical question or not). |
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 If we do the two passes solution, the matching/deconstructing code has to be duplicated (or we go for a full visitor pattern?) |
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? |
Here's some notes I have on how I think disambiguation should work:
|
Still in my TODO list. ^^' |
I noticed this in https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/traits/consts/trait.ConstMethods.html#tymethod.scalar_to_backend today:
Those two
Scalar
s are actually different types, however.It would be nice to detect things like this and show some distinguisher. Maybe
value::Scalar
andrustc_abi::Scalar
-- including enough module context to distinguish -- or something? Or maybe show the crate name?(Crate name might be good, since a single crate can fix multiple types with the same name, if needed.)
The text was updated successfully, but these errors were encountered: