Comments (2)
I'll start looking into this issue slowly. For reference, Clippy has clippy_utils::def_path_res
. The documentation notes, that a path like std::vec
could resolve to the module and macro which is a good thing to keep in mind. I'm considering, if it might be good to restrict the resolve function to TyDefId
s, as that should be the main usage of it anyways.
Further things found during research:
- https://github.com/rust-lang/rust/blob/e9dd59131bc02986ec17f88307e1b0ae252dc5ad/compiler/rustc_ast_lowering/src/path.rs
- https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.def_path_str
- https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/decoder/struct.CrateMetadata.html
- https://rustc-dev-guide.rust-lang.org/name-resolution.html
- https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/late/index.html
- https://doc.rust-lang.org/nightly/nightly-rustc/rustc_resolve/struct.Resolver.html#method.resolve_path
Notes about special cases, for extra fun:
- Crates can depend on the same crate with different versions multiple times if they rename the dependency. The name resolution will need to handle this correctly... This will be fun....
- Symbols can life in different Namespaces. This might be a problem for types, const/static variables and macros. I hope that they're all in the same namespace, but we have to test for that at some point. See Namespaces
from marker.
I'm sadly still stuck on this issue. It seems like rustc does all path resolution at once in an AST-pass. It makes sense for rustc not to expose a simple way to resolve paths outside of that, as additional usages would be a "code smell". However, this doesn't make it easy for external tools like Clippy and Marker. I see 4 ways to solve this and will need some more time to decide:
- Create a PR allowing external tools to use rustc's path resolution. Here IDK, which method would be enough to expose and also how to create the state the solver would need
- Use Clippy's manual path resolution
- Write a manual path resolution for Marker, similar to Clippy's
- Magically find a way to resolve paths with rustc that I've overlooked so far.
from marker.
Related Issues (20)
- [Feat]: Provide a way to automatically fix lints with `--fix` flag HOT 2
- Use consistent naming `fn pat()` vs `fn pattern()`
- [Bug]: `marker_uitest` doesn't work in a workspace with rust-toolchain.toml file that uses `1.71` HOT 1
- [Bug]: Marker panics when the item identifier from macro expansion is debug-printed.
- [Bug]: Maker panics if the trait from `std` is requested via `ctx.ast().item()` HOT 2
- `FnItem::ident()` should return `Ident` instead of `Option<Ident>`
- [Feat]: Make `cargo test --doc` work with the lint crates to doc test examples HOT 2
- [Feat]: Add a method to check if type implements a trait HOT 2
- Chore: Bump nightly -> 2023-12-28
- [Bug]: `cargo marker setup --auto-install-toolchain` fails with E0554 `#[feature]` on stable channel HOT 14
- [Bug]: `cargo uitest` fails with `[E0463]: can't find crate for std` HOT 11
- [Panic]: broken on_unimplemented "{float}{_Self}{crate_local}{Trait}{ItemContext}" for <() as Baz>: no argument matching "crate_local
- [Panic]: `&MarkerConverterInner::lang_item_map` doesn't contain `TryTraitFromOutput
- [Panic]: assertion failed: 4 == 3
- [Panic]: unimplemented: type aliases / assoc type bounds
- [Panic]: not implemented: lifetimes?
- [Panic]: `this should be a literal expression Expr {`
- [Panic]: None / expected fulfillment errors
- [Panic]: no type for local variable
- [Panic]: unreachable HOT 2
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 marker.