about summary refs log tree commit diff
path: root/src/librustdoc/passes
AgeCommit message (Collapse)AuthorLines
2021-08-29Use the correct type for Enum variant tuplesGuillaume Gomez-2/+2
2021-08-29Fix: don't document private macros by defaultinquisitivecrystal-2/+3
2021-08-26Fix the bugs and add a regression testJoshua Nelson-17/+29
- All attributes for an item need to be considered at once, they can't be considered a line at a time. - The top-level crate was not being visited. This bug was caught by `extern-crate-used-only-in-link`, which I'm very glad I added. - Make the loader private to the module, so that only one function is exposed.
2021-08-22Revert "Revert "Don't load all extern crates unconditionally""Joshua Nelson-1/+67
This reverts commit 5f0c54db4e595a6a77048f2b0605138ffa49a326.
2021-08-18remove box_syntax uses from cranelift and toolsMarcel Hellwig-1/+1
2021-08-12Use smaller spans for some structured suggestionsEsteban Kuber-2/+2
Use more accurate suggestion spans for * argument parse error * fully qualified path * missing code block type * numeric casts * E0212
2021-08-04Auto merge of #87568 - petrochenkov:localevel, r=cjgillotbors-5/+2
rustc: Replace `HirId`s with `LocalDefId`s in `AccessLevels` tables and passes using those tables - primarily privacy checking, stability checking and dead code checking. All these passes work with definitions rather than with arbitrary HIR nodes. r? `@cjgillot` cc `@lambinoo` (#87487)
2021-08-03don't use .into() to convert types to identical types ↵Matthias Krüger-7/+7
(clippy::useless_conversion) Example: let _x: String = String::from("hello world").into();
2021-07-31rustc: Replace `HirId`s with `LocalDefId`s in `AccessLevels` tablesVadim Petrochenkov-5/+2
and passes using them - primarily privacy checking, stability checking and dead code checking. WIP
2021-07-29Change span for intra-doc links errorsGuillaume Gomez-24/+73
2021-07-12suggest removing disambiguator if linking to fieldDeadbeef-0/+6
2021-07-08Rework SESSION_GLOBALS API to prevent overwriting itGuillaume Gomez-2/+2
2021-07-05Revert "rustdoc: Store DefId's in ItemId on heap for decreasing Item's size"Justus K-36/+38
This reverts commit 41a345d4c46dad1a98c9993bc78513415994e8ba.
2021-07-05rustdoc: Store DefId's in ItemId on heap for decreasing Item's sizeJustus K-38/+36
2021-07-05rustdoc: Rename `expect_real` to `expect_def_id`, remove `Item::is_fake`Justus K-52/+57
2021-07-05rustdoc: Replace `FakeDefId` with new `ItemId` typeJustus K-11/+11
2021-07-02Rollup merge of #85749 - GuillaumeGomez:revert-smart-extern-crate-load, r=jyn514Guillaume Gomez-67/+1
Revert "Don't load all extern crates unconditionally" Fixes https://github.com/rust-lang/rust/issues/84738. This reverts https://github.com/rust-lang/rust/pull/83738. For the "smart" load of external crates, we need to be able to access their items in order to check their doc comments, which seems, if not impossible, quite complicated using only the AST. For some context, I first tried to extend the `IntraLinkCrateLoader` visitor by adding `visit_foreign_item`. Unfortunately, it never enters into this call, so definitely not the right place... I then added `visit_use_tree` to then check all the imports outside with something like this: ```rust let mut loader = crate::passes::collect_intra_doc_links::IntraLinkCrateLoader::new(resolver); ast::visit::walk_crate(&mut loader, krate); let mut items = Vec::new(); for import in &loader.imports_to_check { if let Some(item) = krate.items.iter().find(|i| i.id == *import) { items.push(item); } } for item in items { ast::visit::walk_item(&mut item); for attr in &item.attrs { loader.check_attribute(attr); } } ``` This was, of course, a failure. We find the items without problems, but we still can't go into the external crate to check its items' attributes. Finally, `@jyn514` suggested to look into the [`CrateLoader`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/creader/struct.CrateLoader.html), but it only seems to provide metadata (I went through [`CStore`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/creader/struct.CStore.html) and [`CrateMetadata`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/decoder/struct.CrateMetadata.html)). I think we are too limited here (with AST only) to be able to determine the crates we actually need to import, but it's very likely that I missed something. Maybe `@petrochenkov` or `@Aaron1011` have an idea? So until we find a way to make it work completely, we need to revert it to fix the ICE. Once merged, we'll need to re-open #68427. r? `@jyn514`
2021-07-01Revert "Don't load all extern crates unconditionally"Guillaume Gomez-67/+1
2021-07-01Rename all_crate_nums query to crates and remove useless wrapperbjorn3-2/+2
2021-06-23Rollup merge of #86523 - LeSeulArtichaut:macros-disambiguators, r=jyn514Dylan DPC-27/+12
Improvements to intra-doc link macro disambiguators A few small improvements around macro disambiguators: - display the link text as it was entered: previously `[macro!()]` would be displayed without the parantheses (fixes #86309) - support `!{}` and `![]` as macro disambiguators (fixes #86310) r? `@jyn514` cc `@Manishearth` `@camelid`
2021-06-22Accept `!{}` and `![]` as macro disambiguatorsLeSeulArtichaut-3/+5
2021-06-22Rollup merge of #86334 - LeSeulArtichaut:86120-links-type-aliases, r=jyn514Yuki Okushi-5/+46
Resolve type aliases to the type they point to in intra-doc links This feels a bit sketchy, but I think it's better than just rejecting the link. Helps with #86120, r? ``@jyn514``
2021-06-21Fix handling of disambiguator suffixes for intra-doc linksLeSeulArtichaut-27/+10
2021-06-21Resolve type aliases to the type they point to in intra-doc linksLeSeulArtichaut-5/+46
2021-06-15Auto merge of #86311 - LeSeulArtichaut:cleanup-array-iter, r=jackh726bors-4/+4
Use the now available implementation of `IntoIterator` for arrays
2021-06-14Use the now available implementation of `IntoIterator` for arraysLeSeulArtichaut-4/+4
2021-06-10manually crafted revert of PR #80653, to address issue #82465.Felix S. Klock II-62/+35
(update: placated tidy) (update: rebased post PR #84707 ) merge me
2021-06-05Auto merge of #85990 - jyn514:channel-replace-rustdoc, r=Manishearthbors-2/+5
rustdoc: link consistently to stable/beta in diagnostic messages Builds on https://github.com/rust-lang/rust/pull/84942. This makes the diagnostics consistent with the links.
2021-06-05Rollup merge of #84466 - jyn514:prim-str, r=GuillaumeGomezYuki Okushi-6/+6
rustdoc: Remove `PrimitiveType::{to_url_str, as_str}` These can easily be rewritten in terms of `as_sym`, and this avoids bugs where the two get out of sync. I don't expect this to have a perf impact, but I'll start a perf run just in case.
2021-06-04rustdoc: link consistently to stable/beta in diagnostic messagesJoshua Nelson-2/+5
2021-05-20Remove `PrimitiveType::as_str`Joshua Nelson-6/+6
2021-05-17Fix rebase conflictsJoshua Nelson-1/+1
2021-05-17Address review commentsJoshua Nelson-1/+1
- Simplify boolean expression - Give an example of invalid syntax - Remove explanation of why code block is text
2021-05-17Rename INVALID_RUST_CODEBLOCK{,S}Joshua Nelson-1/+1
2021-05-17Add back missing help for ignore blocksJoshua Nelson-28/+26
This also gives a better error message when a span is missing.
2021-05-17New rustdoc lint to respect -Dwarnings correctlyAlexis Bourget-33/+59
This adds a new lint to `rustc` that is used in rustdoc when a code block is empty or cannot be parsed as valid Rust code. Previously this was unconditionally a warning. As such some documentation comments were (unknowingly) abusing this to pass despite the `-Dwarnings` used when compiling `rustc`, this should not be the case anymore.
2021-05-17Auto merge of #85178 - cjgillot:local-crate, r=oli-obkbors-6/+4
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-15Rollup merge of #85067 - Stupremee:minimize-amount-of-fake-defids, ↵Guillaume Gomez-46/+25
r=jyn514,GuillaumeGomez Minimize amount of fake `DefId`s used in rustdoc Follow up from #84707, which minimizes the amount of fake defids to the smallest amount possible. Every `FakeDefId` that is now used in the rustdoc library must be preserved and can not be replaced with a normal `DefId`.
2021-05-15Rollup merge of #84461 - jyn514:remove-strip-item, r=GuillaumeGomezGuillaume Gomez-5/+5
rustdoc: Remove unnecessary `StripItem` wrapper
2021-05-15Minimize amount of fake `DefId`s used in rustdocJustus K-46/+25
2021-05-12Use () for all_traits.Camille GILLOT-2/+2
2021-05-12Use () for privacy.Camille GILLOT-4/+2
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-3/+3
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-08Remove `FakeDefId::expect_local()`Camelid-3/+15
This function returned a fake `DefIndex`, with no indication that it was fake, when it was provided with a `FakeDefId::Fake`. Every use of the function uses the returned `DefIndex` in a call to `tcx.local_def_id_to_hir_id()`, which I'm pretty sure would panic if it were given a fake `DefIndex`. I removed the function and replaced all calls to it with a call to `expect_real()` followed by `DefId::expect_local()` (that's a function on the *real* `DefId`).
2021-05-07rustdoc: Link to the docs on namespaces when an unknown disambiguator is foundJoshua Nelson-1/+4
2021-05-05Use local and remapped paths where appropriateAndy Wang-2/+2
2021-05-05Remove impl Display for FileName and add FileNameDisplay wrapper typeAndy Wang-1/+1
2021-05-05Revert PR 83866Pietro Albini-8/+1
That PR caused multiple test failures when Rust's channel is changed from nightly to anything else. The commit will have to be landed again after the test suite is fixed.
2021-05-04rustdoc: Remove unnecessary `StripItem` wrapperJoshua Nelson-5/+5
2021-05-04Add type to differentiate between fake and real DefId'sJustus K-65/+94