about summary refs log tree commit diff
path: root/src/test/rustdoc-ui
AgeCommit message (Collapse)AuthorLines
2020-09-05Make errors more concise and helpfulJoshua Nelson-30/+21
Before: ``` = note: this link partially resolves to the struct `S` = note: no `fmt` in `S` ``` After: ``` = note: the struct `S` has no field or associated item named `fmt` ```
2020-09-05Remove some TODOsJoshua Nelson-1/+0
2020-09-05Don't give misleading errors for `f::A`, where f is in the value namespaceJoshua Nelson-6/+6
2020-09-05Fix tests and improve error message if `::` isn't foundJoshua Nelson-47/+27
2020-09-05Pass on the DefId so rustdoc can name it in suggestionsJoshua Nelson-10/+24
Look at this beauty: ```rust error: unresolved link to `S::h` --> intra-link-errors.rs:51:6 | 51 | /// [type@S::h] | ^^^^^^^^^ help: to link to the associated function, use its disambiguator: `S::h()` | = note: this link resolves to the associated function `h`, which is not in the type namespace ```
2020-09-05Report if the thing exists in another namespaceJoshua Nelson-0/+1
2020-09-05Update .stderrJoshua Nelson-17/+55
2020-09-05[WIP] give better errors for broken intra doc linksJoshua Nelson-23/+176
2020-09-03Add test for doc alias on associated const in trait implsGuillaume Gomez-0/+30
2020-08-29Auto merge of #75916 - jyn514:unify-error-reporting, r=eucliobors-42/+86
Unify error reporting for intra-doc links - Give a suggestion even if there is no span available - Give a more accurate description of the change than 'use the disambiguator' - Write much less code Closes #75836. r? @euclio cc @pickfire - this gets rid of 'disambiguator' like you suggested in https://github.com/rust-lang/rust/pull/75079#discussion_r464464195.
2020-08-25Unify error reporting for intra-doc linksJoshua Nelson-42/+86
- Give a suggestion even if there is no span available - Give a more accurate description of the change than 'use the disambiguator' - Write much less code
2020-08-25Warn about unknown or renamed lintsJoshua Nelson-0/+36
Originally I tried to do a much broader refactoring that got rid of `init_lints` altogether. My reasoning is that now the lints aren't being run anymore (after https://github.com/rust-lang/rust/pull/73566), there's no need to ignore them explicitly. But it seems there are still some lints that aren't affected by setting `lint_mod` to a no-op: ``` deny(pub_use_of_private_extern_crate) deny(const_err) warn(unused_imports) ``` (there are possibly more, these are just the ones that failed in the rustdoc test suite). Some of these seem like we really should be warning about, but that's a much larger change and I don't propose to make it here. So for the time being, this just adds the `unknown_lints` and `renamed_or_removed_lints` passes to the list of lints rustdoc warns about.
2020-08-23Report an ambiguity if both modules and primitives are in scopeJoshua Nelson-0/+83
- Add a new `prim@` disambiguator, since both modules and primitives are in the same namespace - Refactor `report_ambiguity` into a closure Additionally, I noticed that rustdoc would previously allow `[struct@char]` if `char` resolved to a primitive (not if it had a DefId). I fixed that and added a test case.
2020-08-23Auto merge of #74489 - jyn514:assoc-items, r=manishearth,petrochenkovbors-0/+37
Fix intra-doc links for associated items @Manishearth and I found that links of the following sort are broken: ```rust $ cat str_from.rs /// [`String::from`] pub fn foo() {} $ rustdoc str_from.rs warning: `[String::from]` cannot be resolved, ignoring it. --> str_from.rs:4:6 | 4 | /// [`String::from`] | ^^^^^^^^^^^^^^ cannot be resolved, ignoring ``` It turns out this is because the current implementation only looks at inherent impls (`impl Bar {}`) and traits _for the item being documented_. Note that this is not the same as the item being _linked_ to. So this code would work: ```rust pub trait T1 { fn method(); } pub struct S; impl T1 for S { /// [S::method] on method fn method() {} } ``` but putting the documentation on `trait T1` would not. ~~I realized that writing it up that my fix is only partially correct: It removes the inherent impls code when it should instead remove the `trait_item` code.~~ Fixed. Additionally, I discovered while writing this there is some ambiguity: you could have multiple methods with the same name, but for different traits: ```rust pub trait T1 { fn method(); } pub trait T2 { fn method(); } /// See [S::method] pub struct S; ``` Rustdoc should give an ambiguity error here, but since there is currently no way to disambiguate the traits (https://github.com/rust-lang/rust/issues/74563) it does not (https://github.com/rust-lang/rust/pull/74489#issuecomment-673878404). There is a _third_ ambiguity that pops up: What if the trait is generic and is implemented multiple times with different generic parameters? In this case, my fix does not do very well: it thinks there is only one trait instantiated and links to that trait: ``` /// [`String::from`] -- this resolves to https://doc.rust-lang.org/nightly/alloc/string/struct.String.html#method.from pub fn foo() {} ``` However, every `From` implementation has a method called `from`! So the browser picks a random one. This is not the desired behavior, but it's not clear how to avoid it. To be consistent with the rest of intra-doc links, this only resolves associated items from traits that are in scope. This required changes to rustc_resolve to work cross-crate; the relevant commits are prefixed with `resolve: `. As a bonus, considering only traits in scope is slightly faster. To avoid re-calculating the traits over and over, rustdoc uses a cache to store the traits in scope for a given module.
2020-08-22rustdoc: Only resolve traits in scopeJoshua Nelson-0/+37
2020-08-21Strenghten tests for missing_doc_code_examples lintGuillaume Gomez-5/+54
2020-08-20Update how doc examples are countedGuillaume Gomez-8/+31
2020-08-20Remove "total" columns in --show-coverage outputGuillaume Gomez-58/+49
2020-08-20Update rustdoc coverage UI testGuillaume Gomez-2/+40
2020-08-19Auto merge of #74098 - GuillaumeGomez:doc-alias-checks, r=ollie27bors-0/+79
Doc alias checks: ensure only items appearing in search index can use it Following the discussion in #73721, I added checks to ensure that only items appearing in the search are allowed to have doc alias. r? @ollie27
2020-08-18Update rustdoc-ui testsGuillaume Gomez-51/+85
2020-08-12Allow #[doc(alias)] on impl const itemsGuillaume Gomez-9/+3
2020-08-11Move #[doc(alias)] attribute checks in rustcGuillaume Gomez-6/+6
2020-08-11Put back attributes check pass in rustdocGuillaume Gomez-0/+30
2020-08-11Add doc(alias) attribute checks for associated consts and associated typesGuillaume Gomez-7/+29
2020-08-11Add more tests for doc aliasGuillaume Gomez-0/+33
2020-08-10Auto merge of #75127 - jyn514:impl-trait, r=pnkfelixbors-95/+92
Fix async-std by special-casing rustdoc in typeck https://github.com/rust-lang/rust/issues/75100
2020-08-08Add another testJoshua Nelson-0/+32
2020-08-07EXTREMELY hacky fixJoshua Nelson-19/+34
This runs _just_ enough of typeck that later queries don't panic. Because this is in the same part of the compiler that errors on `impl Trait`, this special-cases impl Trait for rustdoc and no one else. Everything is fine.
2020-08-07Auto merge of #73842 - euclio:doctest-expn, r=GuillaumeGomezbors-4/+24
Use outermost invocation span for doctest names Fixes #70090. This PR also allows using aux-build files in rustdoc-ui tests.
2020-08-06Improve testsJoshua Nelson-17/+11
2020-08-06Use the proper kind for associated itemsJoshua Nelson-11/+17
See comments in the diff; this is such a hack. The reason this can't be done properly in `register_res` is because there's no way to get back the parent type: calling `tcx.parent(assoc_item)` gets you the _impl_, not the type. You can call `tcx.impl_trait_ref(impl_).self_ty()`, but there's no way to go from that to a DefId without unwrapping.
2020-08-05Suggest f() for functions and add a test caseJoshua Nelson-1/+14
2020-08-05Unresolved link -> incompatible link kindJoshua Nelson-20/+20
Clearly it has been resolved, because we say on the next line what it resolved to.
2020-08-05Give a much better error message if the struct failed to resolveJoshua Nelson-79/+49
2020-08-03Add more realistic example of async errorJoshua Nelson-0/+28
2020-08-03Fix async-std at the price of breaking half the test suiteJoshua Nelson-105/+27
- Don't mark impl trait as an error
2020-08-03item -> linkJoshua Nelson-30/+30
2020-08-02Disallow linking to items with a mismatched disambiguatorJoshua Nelson-0/+180
2020-07-30Fix uitestsManish Goregaokar-5/+5
2020-07-30intra_doc_resolution_failures -> broken_intra_doc_linksManish Goregaokar-18/+18
2020-07-30Update uitest expectationsManish Goregaokar-5/+5
2020-07-30Rename to intra_doc_resolution_failuresManish Goregaokar-18/+18
2020-07-29Rename usage of intra_doc_link_resolution_failureManish Goregaokar-18/+18
2020-07-27Separate `missing_doc_code_examples` from intra-doc linksJoshua Nelson-13/+13
These two lints have no relation other than both being nightly-only. This allows stabilizing intra-doc links without stabilizing missing_doc_code_examples.
2020-07-22rustdoc: Add explanation when linting against public to private item linksDennis Hamester-0/+4
The additional note helps explaining why the lint was triggered and that --document-private-items directly influences the link resolution.
2020-07-22rustdoc: Always warn when linking from public to private itemsDennis Hamester-5/+24
Change the logic such that linking from a public to a private item always triggers intra_doc_link_resolution_failure. Previously, the warning was not emitted when --document-private-items is passed. Also don't rely anymore on the item's visibility, which would falsely trigger the lint now that the check for --document-private-items is gone.
2020-07-20refactor and reword intra-doc link errorsAndy Russell-117/+117
This commit refactors intra-doc link error reporting to deduplicate code and decouple error construction from the type of error. This greatly improves flexibility at each error construction site, while reducing the complexity of the diagnostic creation. This commit also rewords the diagnostics for clarity and style: - Diagnostics should not end in periods. - It's unnecessary to say "ignoring it". Since this is a warning by default, it's already clear that the link is ignored.
2020-07-16Fix invalid lintJoshua Nelson-1/+1
intra_doc_resolution_failure is not a lint.
2020-07-16Rollup merge of #74148 - GuillaumeGomez:doc-alias-check, r=ManishearthManish Goregaokar-29/+0
Move #[doc(alias)] check in rustc Part of #73721. r? @ollie27