Commit Graph

33 Commits

Author SHA1 Message Date
Camelid
0193a8871c Remove unhelpful help message 2020-10-02 14:47:41 -07:00
Camelid
87f3f81451 Improve rustdoc error for failed intra-doc link resolution
The previous error was confusing since it made it sound like you can't
link to items that are defined outside the current module.

Also suggested importing the item.
2020-10-02 14:36:34 -07:00
Joshua Nelson
dd7b8c85a6 Perform most diagnostic lookups in resolution_failure
Previously, these were spread throughout the codebase. This had two
drawbacks:

1. It caused the fast path to be slower: even if a link resolved,
rustdoc would still perform various lookups for the error diagnostic.
2. It was inconsistent and didn't always give all diagnostics (https://github.com/rust-lang/rust/issues/76925)

Now, diagnostics only perform expensive lookups in the error case.
Additionally, the error handling is much more consistent, both in
wording and behavior.

- Remove `CannotHaveAssociatedItems`, `NotInScope`, `NoAssocItem`, and `NotAVariant`
  in favor of the more general `NotResolved`

  `resolution_failure` will now look up which of the four above
  categories is relevant, instead of requiring the rest of the code to
  be consistent and accurate in which it picked.

- Remove unnecessary lookups throughout the intra-doc link pass. These
are now done by `resolution_failure`.
  + Remove unnecessary `extra_fragment` argument to `variant_field()`;
    it was only used to do lookups on failure.
  + Remove various lookups related to associated items
  + Remove distinction between 'not in scope' and 'no associated item'

- Don't perform unnecessary copies
- Remove unused variables and code
- Update tests
- Note why looking at other namespaces is still necessary
- 'has no inner item' -> 'contains no item'

bless tests
2020-09-23 21:04:20 -04:00
Joshua Nelson
5ea3eaf237 Name the current module
'not in scope' -> 'not in `module`'
2020-09-11 14:52:45 -04:00
Joshua Nelson
57250eff55 Use span_label instead of note
This puts the error message closer to the link, making it easier to see
what went wrong.
2020-09-11 13:42:56 -04:00
Joshua Nelson
d67eb1f148 Don't suggest \[ \] if there's a :: in the path 2020-09-05 13:48:20 -04:00
Joshua Nelson
e2d69f2eb1 Make errors more concise and helpful
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-05 13:48:19 -04:00
Joshua Nelson
f4e6ebd11a Fix tests and improve error message if :: isn't found 2020-09-05 13:48:19 -04:00
Joshua Nelson
f45e7b5862 Update .stderr 2020-09-05 13:48:19 -04:00
Joshua Nelson
3797f29aad [WIP] give better errors for broken intra doc links 2020-09-05 13:48:19 -04:00
Manish Goregaokar
8fe438e632 intra_doc_resolution_failures -> broken_intra_doc_links 2020-07-30 10:38:55 -07:00
Manish Goregaokar
4df76f0f90 Rename to intra_doc_resolution_failures 2020-07-30 08:14:27 -07:00
Manish Goregaokar
48de8ac041 Rename usage of intra_doc_link_resolution_failure 2020-07-29 15:23:14 -07:00
Andy Russell
7f3e2c0d37
refactor and reword intra-doc link errors
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-20 18:44:15 -04:00
RoccoDev
b85c64c3ea
rustc: Add a warning count upon completion 2020-04-11 16:15:24 +02:00
Eduard-Mihai Burtescu
4c7eb59e81 rustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros. 2020-02-06 21:46:38 +02:00
Guillaume Gomez
c1ea1fd2b0 Update error messages 2019-11-25 14:24:53 +01:00
Tomasz Miąsko
70b146c2cb Add warning annotations to rustdoc-ui tests 2019-11-10 21:01:02 +01:00
Samy Kacimi
e5e1397adb
normalize use of backticks in compiler messages for librustc/lint
https://github.com/rust-lang/rust/issues/60532
2019-07-17 22:49:48 +02:00
Andy Russell
695dfe7dff
compiletest: make path normalization smarter 2019-03-25 01:06:45 -04:00
Andy Russell
906ec8acce
move collapse and unindent docs passes earlier 2019-02-23 14:53:51 -05:00
Mark Rousskov
2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Andy Russell
56413ecffc
fix intra-link resolution spans in block comments
This commit improves the calculation of code spans for intra-doc
resolution failures. All sugared doc comments should now have the
correct spans, including those where the comment is longer than the
docs.

It also fixes an issue where the spans were calculated incorrectly for
certain unsugared doc comments. The diagnostic will now always use the
span of the attributes, as originally intended.

Fixes #55964.
2018-12-10 21:08:26 -05:00
QuietMisdreavus
93321671ca add -Zui-testing to rustdoc 2018-09-19 18:39:39 -05:00
Guillaume Gomez
d2a4e42959 Rename intra-doc lint 2018-06-13 23:30:34 +02:00
Guillaume Gomez
e6c7868fb2 Update help message to escape square brackets 2018-06-13 21:18:56 +02:00
Guillaume Gomez
2e343f384f Add help for intra-link lint 2018-06-13 21:18:55 +02:00
Guillaume Gomez
8c43c93e6d Fix options issues 2018-06-13 21:18:55 +02:00
Esteban Küber
7d0b6b75f0 When unable to sinthesize link span, fallback to previous behavior 2018-06-06 09:38:47 -07:00
Esteban Küber
507dfd2148 Use spans pointing at the inside of a rustdoc attribute 2018-06-06 08:49:42 -07:00
kennytm
2886aca232
Show which line the link is coming from. 2018-06-03 18:25:04 +08:00
kennytm
bc20eb6fbc
Point to the rustdoc attribute where intralink resolution failed. 2018-06-03 15:51:31 +08:00
Guillaume Gomez
b2192ae157 Add rustdoc-ui test suite 2018-04-16 23:37:11 +02:00