Comments (7)
@rustbot claim
(cc @GuillaumeGomez )
from rust.
Prior art: trimmed_def_paths
.
from rust.
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.
I think the latter (or was that a rhetorical question lol?)
from rust.
I also prefer the latter (whether it's a rhetorical question or not).
from rust.
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.
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)
- Unhelpful error on mismatched types for anonymous futures HOT 3
- More instructions generated for `Ord::clamp` than manual `max(X).min(Y)` for saturating truncating cast from `i32` to `u8` HOT 1
- run-make-support: use a `CommandWrapper` trait instead of `impl_helper_methods` macro HOT 5
- Tracking Issue for `duration_new_checked`
- ICE: `called Option::unwrap() on a None value` in `compiler/rustc_infer/src/infer/error_reporting/note_and_explain.rs` HOT 2
- ICE: `SizeSkeleton::compute` layout errored in `layout.rs`
- ICE: `assertion failed: !value.has_infer()` in `rustc_hir_typeck/src/writeback.rs`
- Illegal instruction when cross compile HOT 16
- conflicting impl since nightly-2024-05-01 HOT 13
- flaky aborts with `lto=thin` on Windows in `--release` HOT 11
- ICE: `!self.intercrate` HOT 4
- ICE: `invalid asymmetric binary op` HOT 1
- ICE: `FloatToFloat/FloatToInt cast: source type usize is not a float type` HOT 2
- ICE; `tried to combine ConstKind::Infer/ConstKind::Infer(InferConst::Var): ?0e: bool and ?0c: Dimension` HOT 1
- ICE: `layout mismatch for result of MulWithOverflow`
- Unexpected float value when casted from `f32` to `f64` HOT 4
- inline-asm x86 CR0 register not recognized depending on the instruction used HOT 1
- rustc panic with -C prefer-dynamic=yes and -C rpath=yes
- Tracking Issue for RFC 3624: Supertrait item shadowing v2 HOT 1
- Misleading suggestion to add bound to type alias parameter HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.