214 Commits

Author SHA1 Message Date
Esteban Küber
10a9ea4c26 Do not ICE on malformed suggestion spans 2020-01-16 18:14:26 -08:00
Esteban Küber
d558f6a570 Fix invalid bounding box 2020-01-10 11:03:26 -08:00
Vadim Petrochenkov
41a93cba38 Remove -Z continue-parse-after-error 2020-01-08 21:48:04 +03:00
Vadim Petrochenkov
5bf8105993 Address review comments + Fix rebase 2020-01-03 18:03:28 +04:00
Vadim Petrochenkov
4feeceecd1 Introduce an option for disabling deduplication of diagnostics 2020-01-03 18:03:28 +04:00
Vadim Petrochenkov
70f1d57048 Rename syntax_pos to rustc_span in source code 2020-01-01 09:15:18 +03:00
bors
774a4bd4f4 Auto merge of #67614 - Mark-Simulacrum:global-callbacks, r=Zoxc
Set callbacks globally

This sets the callbacks from syntax and rustc_errors just once, utilizing static (rather than thread-local) storage.
2019-12-29 04:30:56 +00:00
Mark Rousskov
b98633b94c Store callbacks in global statics
The callbacks have precisely two states: the default, and the one
present throughout almost all of the rustc run (the filled in value
which has access to TyCtxt).

We used to store this as a thread local, and reset it on each thread to
the non-default value. But this is somewhat wasteful, since there is no
reason to set it globally -- while the callbacks themselves access TLS,
they do not do so in a manner that fails in when we do not have TLS to
work with.
2019-12-25 14:10:46 -05:00
David Tolnay
4646a88b7a
Deprecate Error::description for real
`description` has been documented as soft-deprecated since 1.27.0 (17
months ago). There is no longer any reason to call it or implement it.

This commit:

- adds #[rustc_deprecated(since = "1.41.0")] to Error::description;

- moves description (and cause, which is also deprecated) below the
  source and backtrace methods in the Error trait;

- reduces documentation of description and cause to take up much less
  vertical real estate in rustdocs, while preserving the example that
  shows how to render errors without needing to call description;

- removes the description function of all *currently unstable* Error
  impls in the standard library;

- marks #[allow(deprecated)] the description function of all *stable*
  Error impls in the standard library;

- replaces miscellaneous uses of description in example code and the
  compiler.
2019-12-24 22:39:49 -08:00
Mark Rousskov
a06baa56b9 Format the world 2019-12-22 17:42:47 -05:00
Mark Rousskov
2299586ffc Move ErrorReported to rustc_errors 2019-11-26 14:57:07 -05:00
bors
0ccee30773 Auto merge of #58281 - mark-i-m:synthesis, r=estebank
Add outlives suggestions for some lifetime errors

This PR implements suggestion diagnostics for some lifetime mismatch errors. When the borrow checker finds that some lifetime 'a doesn't outlive some other lifetime 'b that it should outlive, then in addition to the current lifetime error, we also emit a suggestion for how to fix the problem by adding a bound:

- If a and b are normal named regions, suggest to add the bound `'a: 'b`
- If b is static, suggest to replace a with static
- If b also needs to outlive a, they must be the same, so suggest unifying  them

We start with a simpler implementation that avoids diagnostic regression or implementation complexity:
- We only makes suggestions for lifetimes the user can already name (eg not closure regions or elided regions)
- For now, we only emit a help note, not an actually suggestion because it is significantly easier.

Finally, there is one hack: it seems that implicit regions in async fn are given the name '_ incorrectly. To avoid suggesting '_: 'x, we simply filter out such lifetimes by name.

For more info, see this internals thread:

https://internals.rust-lang.org/t/mechanical-suggestions-for-some-borrow-checker-errors/9049/3

TL;DR Make suggestions to add a `where 'a: 'b` constraint for some lifetime errors. Details are in the paper linked from the internals thread above.

r? @estebank

TODO
- [x] Clean up code
- [x] Only make idiomatic suggestions
     - [x] don't suggest naming `&'a self`
     - [x] rather than `'a: 'static`, suggest replacing `'a` with `'static`
     - [x] rather than `'a: 'b, 'b: 'a`, suggest replacing `'a` with `'b` or vice versa
- [x] Performance (maybe need a perf run when this is closer to the finish line?)
     - perf run was clean...
     - EDIT: perf run seems to only check non-error performance... How do we check that error performance didn't regress?
- [x] Needs ui tests
- [x] Integrate the `help` message into the main lifetime `error`
2019-11-18 22:08:31 +00:00
Esteban Küber
2fe8371268 review comments and fix rebase 2019-11-16 16:12:22 -08:00
Mark Rousskov
c31a8754e3 Move JSON emitter to rustc_errors 2019-11-15 08:45:49 -05:00
Mark Rousskov
3f93ffc333 Remove SourceMapper trait
SourceMap is now in the root of all rustc-specific crates, syntax_pos,
so there's no need for the trait object to decouple the dependencies
between librustc_errors and libsyntax as was needed previously.
2019-11-15 08:45:43 -05:00
Mark Rousskov
e1a87ca17a Move FatalError to syntax_pos
This is a bit unfortunate, but code needs to be able to fatally error
early on (in particular, syntax_pos after we move SourceMap there). It's
also a tiny bit of code, which means it's ultimately not that bad.
2019-11-15 08:21:23 -05:00
Vadim Petrochenkov
e7c42f0cf0 Tiny cleanup to size assertions 2019-11-11 22:23:25 +03:00
Mazdak Farrokhzad
3667e6248e move PResult to librustc_errors 2019-11-07 13:58:36 +01:00
Andy Russell
ad550b8ef3
use American spelling for pluralize! 2019-11-05 15:10:24 -05:00
Mark Mansi
19122ab981 add and use struct_help 2019-10-27 08:47:22 -05:00
Quentin Boyer
5930551f6a Check if there are any delayed_span_bugs and abort incremental compilation in this case 2019-10-16 13:13:13 +02:00
Esteban Küber
6dd718ca79 Use heuristics for capitalization warning in suggestions 2019-10-14 14:32:10 -07:00
Esteban Küber
4bb771615e Bring attention to suggestions when the only difference is capitalization 2019-10-13 21:48:39 -07:00
Esteban Küber
02f57f83a9 review comments 2019-10-03 13:22:18 -07:00
AnthonyMikh
bd7cd80299
Fully clear HandlerInner in Handler::reset_err_count 2019-10-02 04:13:02 +03:00
Mazdak Farrokhzad
f70665a846 cleanup librustc_errors Handler code. 2019-09-23 22:28:14 +02:00
Mazdak Farrokhzad
62fc4d36df stash_diagnostic: ICE in a different way 2019-09-23 19:29:02 +02:00
Mazdak Farrokhzad
ae8b3e8fc6 Introduce a diagnostic stashing API. 2019-09-23 17:50:06 +02:00
bors
66bf391c3a Auto merge of #64272 - Mark-Simulacrum:parallel-handler, r=estebank
Refactor librustc_errors::Handler API

This should be reviewed by-commit.

The last commit moves all fields into an inner struct behind a single lock; this is done to prevent possible deadlocks in a multi-threaded compiler, as well as inconsistent state observation.
2019-09-23 06:38:23 +00:00
Mark Rousskov
4cc5aaada2 Protect error handler fields with single lock
This avoids concurrency-related bugs when locks are acquired for too
short a time and similar cases.
2019-09-17 09:30:45 -04:00
Mark Rousskov
2a767eec0c Remove unused methods from Handler 2019-09-17 09:30:45 -04:00
Mark Rousskov
b304e60131 Remove Handler::{emit, emit_with_code} 2019-09-17 09:30:45 -04:00
Mark Rousskov
998df0d70b Remove Handler::cancel 2019-09-17 09:30:44 -04:00
Mark Rousskov
2a3930d43c Privatize DiagnosticBuilder constructors 2019-09-17 09:30:44 -04:00
Mark Rousskov
0b586b436d Take Diagnostic in Handler::emit_diagnostic 2019-09-17 09:30:44 -04:00
Mark Rousskov
cdd805506e Replace DiagnosticBuilder with Diagnostic when emitting error 2019-09-17 09:29:46 -04:00
Afnan Enayet
02c1b892c1
Fix failure note to_str implementation
* Serialize the level to something a little more useful for a failure note
  struct
* Update tests accordingly
2019-09-16 22:30:59 -07:00
V1shvesh
7457ef8580 Dedent macro definition 2019-09-08 23:01:43 +05:30
V1shvesh
fc4375a895 Remove extra trailing newline 2019-09-08 22:58:28 +05:30
V1shvesh
38ab20dbf7 Add pluralise macro
Adress issue #64238. Create a macro to be used for pluralisation check
throughout rustc codebase.
2019-09-08 15:09:50 +05:30
Esteban Küber
21f2e93345 Add terminal_width debugging flag 2019-08-21 11:58:24 -07:00
Vadim Petrochenkov
67d6ce4206 syntax_pos: NO_EXPANSION/SyntaxContext::empty() -> SyntaxContext::root()
For consistency with `ExpnId::root`.

Also introduce a helper `Span::with_root_ctxt` for creating spans with `SyntaxContext::root()` context
2019-08-15 20:38:12 +03:00
Aleksey Kladov
ed7317cebe remove unused Level::PhaseFatal 2019-08-14 22:22:46 +03:00
bors
c7312fe4ff Auto merge of #63090 - Centril:rollup-xnjwm2h, r=Centril
Rollup of 8 pull requests

Successful merges:

 - #61856 (Lint attributes on function arguments)
 - #62360 (Document that ManuallyDrop::drop should not called more than once)
 - #62392 (Update minifier-rs version)
 - #62871 (Explicit error message for async recursion.)
 - #62995 (Avoid ICE when suggestion span is at Eof)
 - #63053 (SystemTime docs: recommend Instant for elapsed time)
 - #63081 (tidy: Cleanup the directory whitelist)
 - #63088 (Remove anonymous_parameters from unrelated test)

Failed merges:

r? @ghost
2019-07-28 20:22:42 +00:00
Mazdak Farrokhzad
a3cae5740c
Rollup merge of #62995 - estebank:issue-62973, r=varkor
Avoid ICE when suggestion span is at Eof

Fix #62973.
2019-07-28 21:19:58 +02:00
Vadim Petrochenkov
676d282dd3 Deny unused_lifetimes through rustbuild 2019-07-28 18:47:02 +03:00
Vadim Petrochenkov
434152157f Remove lint annotations in specific crates that are already enforced by rustbuild
Remove some random unnecessary lint `allow`s
2019-07-28 18:46:24 +03:00
Esteban Küber
eeb1bd18dc Avoid ICE when suggestion span is at Eof 2019-07-25 16:06:24 -07:00
Vadim Petrochenkov
614037171b cleanup: Remove extern crate serialize as rustc_serializes 2019-07-23 19:20:16 +03:00
Mazdak Farrokhzad
485a084b45
Rollup merge of #61545 - flip1995:internal_lints, r=oli-obk
Implement another internal lints

cc #49509

This adds ~~two~~ one internal lint~~s~~:
1. LINT_PASS_IMPL_WITHOUT_MACRO: Make sure, that the `{declare,impl}_lint_pass` macro is used to implement lint passes. cc #59669
2. ~~USAGE_OF_TYCTXT_AND_SPAN_ARGS: item 2 on the list in #49509~~

~~With 2. I wasn't sure, if this lint should be applied everywhere. That means a careful review of 0955835 would be great. Also 73fb9b4 allows this lint on some functions. Should I also apply this lint there?~~

TODO (not directly relevant for review):
- [ ] https://github.com/rust-lang/rust/pull/59316#discussion_r280186517 (not sure yet, if this works or how to query for `rustc_private`, since it's not in [`Features`](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/feature_gate/struct.Features.html) 🤔 cc @eddyb)
- [x] https://github.com/rust-lang/rust/pull/61735#discussion_r292389870
- [x] Check explicitly for the `{declare,impl}_lint_pass!` macros

r? @oli-obk
2019-07-05 20:26:51 +02:00