Commit Graph

37 Commits

Author SHA1 Message Date
Vadim Petrochenkov 7b021aacb5 resolve: Reduce scope of `pub_use_of_private_extern_crate` deprecation lint 2021-02-11 10:15:29 +03:00
Vadim Petrochenkov cee5521a03 Calculate visibilities once in resolve
Then use them through a query based on resolver outputs
2020-10-19 11:57:50 +03:00
Dan Aloni 07e7823c01 pretty: trim paths of unique symbols
If a symbol name can only be imported from one place for a type, and
as long as it was not glob-imported anywhere in the current crate, we
can trim its printed path and print only the name.

This has wide implications on error messages with types, for example,
shortening `std::vec::Vec` to just `Vec`, as long as there is no other
`Vec` importable anywhere.

This adds a new '-Z trim-diagnostic-paths=false' option to control this
feature.

On the good path, with no diagnosis printed, we should try to avoid
issuing this query, so we need to prevent trimmed_def_paths query on
several cases.

This change also relies on a previous commit that differentiates
between `Debug` and `Display` on various rustc types, where the latter
is trimmed and presented to the user and the former is not.
2020-09-02 22:26:37 +03:00
Yuki Okushi ec31b4e3a8
Audit uses of `span_suggestion_short` 2020-07-02 15:18:33 +09:00
Mazdak Farrokhzad fde5939d1c parse: tweak diagnostic wordings 2020-02-24 00:59:38 +01:00
Mazdak Farrokhzad ab84914fe4 parser: tweak unmatched wording 2020-02-24 00:59:38 +01:00
Mazdak Farrokhzad aaaf0ba072 parser: misc small item related improvements & cleanups. 2020-02-13 16:29:10 +01:00
Mazdak Farrokhzad 73d5970cdc parser: introduce `parse_item_kind` as central `ItemInfo` logic.
this also extracts macro item parsers.
2020-02-13 15:16:36 +01:00
Guillaume Gomez 9869e5b969 Change E0741 into E0742 2019-10-29 13:59:40 +01:00
Guillaume Gomez 6c7fe5a94e Update ui tests 2019-10-29 13:56:19 +01:00
Esteban Küber 0baf61bfdb Increase spacing for suggestions in diagnostics
Make the spacing between the code snippet and verbose structured
suggestions consistent with note and help messages.
2019-10-24 12:26:01 -07: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
Mazdak Farrokhzad 6a86be9fca
Rollup merge of #60429 - estebank:pub-path, r=michaelwoerister
Account for paths in incorrect pub qualifier help

Handle case where incorrect pub qualifier with a mod path is used and provide the same help given for all other incorrect qualifiers by making the `pub(crate)` parse check more specific.
2019-05-04 09:21:21 +02:00
Mazdak Farrokhzad eabdce578b
Rollup merge of #59634 - DevQps:explain-E0704, r=estebank
Added an explanation for the E0704 error.

# Description
Adds an explanation on the E0704 error. I tried to stick as closely to the message that the compiler generates. It's the first time I am fixing error messages here, so if there is something I did wrong or should improve, please let me know.

closes #55398
2019-05-02 01:09:23 +02:00
Christian 2be37ad421 Added the E0704 error with a link to the Rust reference. 2019-05-01 12:01:52 +02:00
Esteban Küber a3aafea68f Account for paths in incorrect pub qualifier help 2019-04-30 17:48:18 -07:00
Esteban Küber 30b779f398 Remove assumption from recovery code 2019-04-19 11:04:41 -07:00
Andy Russell b6f148c8bd
hide `--explain` hint if error has no extended info 2019-04-18 13:29:28 -04:00
Vadim Petrochenkov fa72a81bea Update tests 2019-03-11 23:10:26 +03:00
Mark Rousskov 2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Esteban Küber 2645871111 Use appropriate terminology based on heuristic 2018-11-30 15:09:39 -08:00
Esteban Küber 0952856e6c Suggest an appropriate token when encountering `pub Ident<'a>` 2018-11-30 11:48:08 -08:00
David Wood 3fc7ab2373
Merged migrated compile-fail tests and ui tests. Fixes #46841. 2018-08-14 11:12:09 +02:00
Zack M. Davis c2d44b2286 in which the private/restricted-in-public error messaging gets specific
April 2016's Issue #33174 called out the E0446 diagnostics as
confusing. While adding the name of the restricted type to the message
(548e681f) clarified matters somewhat, Esteban Küber pointed out that we
could stand to place a secondary span on the restricted type.

Here, we differentiate between crate-visible, truly private, and
otherwise restricted types, and place a secondary span specifically on
the visibility modifier of the restricted type's declaration (which we
can do now that HIR visibilities have spans!).

At long last, this resolves #33174.
2018-06-30 22:48:05 -07:00
Esteban Küber 28cea50a46 Update error code numbers 2018-06-19 17:33:14 -07:00
Esteban Küber b3a1d56ebe Add code to incorrect `pub` restriction error 2018-06-19 11:37:33 -07:00
Vadim Petrochenkov fa2d9fc4b9 Update UI tests 2018-02-26 20:24:02 +03:00
Esteban Küber d17e38f4bf `struct` pattern parsing and diagnostic tweaks
- Recover from struct parse error on match and point out missing match
   body.
 - Point at struct when finding non-identifier while parsing its fields.
 - Add label to "expected identifier, found {}" error.
2018-01-07 17:04:36 -08:00
bors d1364a65c0 Auto merge of #45997 - estebank:pub-ident, r=nikomatsakis
Account for missing keyword in fn/struct definition

Fix #38911.
2017-12-01 06:06:06 +00:00
Esteban Küber c82e9e8e1e Do not attemt to continue parsing after `pub ident`
Try to identify the following code in order to provide better
diagnostics, but return the error to bail out early during the parse.
2017-11-24 07:34:32 -08:00
Oliver Schneider 8937d6a6cf
Merge cfail and ui tests into ui tests 2017-11-24 11:32:35 +01:00
Ariel Ben-Yehuda 77f4022303 Revert "Change error count messages"
This reverts commit 5558c64f33.
2017-07-02 13:49:30 +03:00
Michael Kohl 5558c64f33 Change error count messages
See #33525 for details.
2017-05-24 16:14:38 +07:00
Oliver Schneider d64af4a627 Rebase and address comments 2017-04-25 13:35:04 +02:00
Oliver Schneider 3a5567bad4
Address PR comments 2017-04-25 11:07:42 +02:00
Oliver Schneider b857a1a39f
Update affected tests 2017-04-25 11:04:35 +02:00
Esteban Küber 769b95dc9f Add diagnostic for incorrect `pub (restriction)`
Given the following statement

```rust
pub (a) fn afn() {}
```

Provide the following diagnostic:

```rust
error: incorrect restriction in `pub`
  --> file.rs:15:1
   |
15 | pub (a) fn afn() {}
   | ^^^^^^^
   |
   = help: some valid visibility restrictions are:
           `pub(crate)`: visible only on the current crate
           `pub(super)`: visible only in the current module's parent
           `pub(in path::to::module)`: visible only on the specified path
help: to make this visible only to module `a`, add `in` before the path:
   | pub (in a) fn afn() {}
```

Remove cruft from old `pub(path)` syntax.
2017-03-22 22:51:45 -07:00