rust/src/librustdoc
Mara Bos ffcbeefd64
Rollup merge of #80765 - petrochenkov:traitsinscope, r=matthewjasper
resolve: Simplify collection of traits in scope

"Traits in scope" for a given location are collected by walking all scopes in type namespace, collecting traits in them and pruning traits that don't have an associated item with the given name and namespace.

Previously we tried to prune traits using some kind of hygienic resolution for associated items, but that was complex and likely incorrect, e.g. in #80762 correction to visibilites of trait items caused some traits to not be in scope anymore.
I previously had some comments and concerns about this in https://github.com/rust-lang/rust/pull/65351.

In this PR we are doing some much simpler pruning based on `Symbol` and `Namespace` comparisons, it should be enough to throw away 99.9% of unnecessary traits.
It is not necessary for pruning to be precise because for trait aliases, for example, we don't do any pruning at all, and precise hygienic resolution for associated items needs to be done in typeck anyway.

The somewhat unexpected effect is that trait imports introduced by macros 2.0 now bring traits into scope due to the removed hygienic check on associated item names.
I'm not sure whether it is desirable or not, but I think it's acceptable for now.
The old check was certainly incorrect because macros 2.0 did bring trait aliases into scope.
If doing this is not desirable, then we should come up with some other way to avoid bringing traits from macros 2.0 into scope, that would accommodate for trait aliases as well.

---

The PR also contains a couple of pure refactorings
- Scope walk is done by using `visit_scopes` instead of a hand-rolled version.
- Code is restructured to accomodate for rustdoc that also wants to query traits in scope, but doesn't want to filter them by associated items at all.

r? ```@matthewjasper```
2021-01-17 12:24:47 +00:00
..
clean Rollup merge of #81021 - CraftSpider:rustdoc-remove-import, r=jyn514 2021-01-16 17:30:08 +00:00
doctest Remove unnecessary semicolon from Rustdoc-generated code 2020-12-29 16:30:02 -05:00
formats Improve code for DocFragment rework 2021-01-02 19:16:27 +01:00
html Rollup merge of #81033 - jyn514:nested-variant, r=CraftSpider 2021-01-15 23:31:00 +01:00
json Rename VariantKind -> Variant 2021-01-15 13:55:03 -05:00
passes Rollup merge of #80765 - petrochenkov:traitsinscope, r=matthewjasper 2021-01-17 12:24:47 +00:00
theme Add test to check if minified theme are handled correctly 2020-02-12 15:49:39 +01:00
Cargo.toml Simplfy color availability check 2020-11-17 10:33:14 +01:00
config.rs clippy fixes for librustdoc 2021-01-01 21:19:10 +01:00
core.rs Rollup merge of #80372 - jyn514:fix-panics, r=Manishearth 2021-01-08 11:11:41 +09:00
docfs.rs Make all rustdoc functions and structs crate-private 2020-11-15 11:21:12 -05:00
doctest.rs doctest: Reset errors before dropping the parse session 2021-01-16 06:55:29 +03:00
doctree.rs Remove doctree::Import 2021-01-15 12:49:45 -05:00
error.rs Make all rustdoc functions and structs crate-private 2020-11-15 11:21:12 -05:00
externalfiles.rs Make all rustdoc functions and structs crate-private 2020-11-15 11:21:12 -05:00
fold.rs Rename VariantKind -> Variant 2021-01-15 13:55:03 -05:00
lib.rs Auto merge of #77858 - ijackson:split-inclusive, r=KodrAus 2021-01-13 07:38:58 +00:00
markdown.rs Make all rustdoc functions and structs crate-private 2020-11-15 11:21:12 -05:00
README.md rust-lang.github.io/rustc-dev-guide -> rustc-dev-guide.rust-lang.org 2020-03-10 17:08:18 -03:00
theme.rs Replace under-used ImplPolarity enum with a boolean 2021-01-09 14:59:37 +01:00
visit_ast.rs Remove doctree::Import 2021-01-15 12:49:45 -05:00
visit_lib.rs Make all rustdoc functions and structs crate-private 2020-11-15 11:21:12 -05:00

For more information about how librustdoc works, see the rustc dev guide.