Commit Graph

236 Commits

Author SHA1 Message Date
Matthew Jasper cbcef3effc Rework `rustc_serialize`
- Move the type parameter from `encode` and `decode` methods to
  the trait.
- Remove `UseSpecialized(En|De)codable` traits.
- Remove blanket impls for references.
- Add `RefDecodable` trait to allow deserializing to arena-allocated
  references safely.
- Remove ability to (de)serialize HIR.
- Create proc-macros `(Ty)?(En|De)codable` to help implement these new
  traits.
2020-08-14 17:34:30 +01:00
Mark Rousskov 647d9b525f apply bootstrap cfgs 2020-07-16 19:36:49 -04:00
Adam Perry f07d10db7c Stabilize `#[track_caller]`.
Does not yet make its constness stable, though. Use of
`Location::caller` in const contexts is still gated by
`#![feature(const_caller_location)]`.
2020-06-30 22:22:32 -07:00
mark e855b90a8e track caller for delay_span_bug 2020-06-15 18:25:58 -05:00
Amanieu d'Antras 5541f689e9 Handle assembler warnings properly 2020-06-09 15:01:02 +01:00
Santiago Pastorino 230e40644b
Fix off by one error for delay_span_bug
delay_span_bug bumps error_count after checking treat_err_as_bug
2020-04-27 09:14:30 -03:00
David Renshaw 57ed3d378d fix issue 69130 2020-04-12 11:36:37 -04:00
RoccoDev b85c64c3ea
rustc: Add a warning count upon completion 2020-04-11 16:15:24 +02:00
Mazdak Farrokhzad 7710f2dd5c rustc -> rustc_middle part 1 2020-03-30 07:02:56 +02:00
Niko Matsakis fda3378e3f introduce `negative_impls` feature gate and document
They used to be covered by `optin_builtin_traits` but negative impls
are now applicable to all traits, not just auto traits.

This also adds docs in the unstable book for the current state of auto traits.
2020-03-26 06:52:55 -04:00
Felix S. Klock II ebf27fac81 Revised span-to-lines conversion to produce an empty vec on DUMMY_SP.
This required revising some of the client code to stop relying on
the returned set of lines being non-empty.
2020-03-20 14:11:16 -04:00
Ana-Maria Mihalache 4809be0137 rustc_errors: Use ensure_source_file_source_present where necessary. 2020-03-10 07:26:27 +01:00
Matthias Krüger d8d2004c6f Don't use "if let" bindings to only check a value and not actually bind anything.
For example:  `if let Some(_) = foo() {}`	can be reduced to	`if foo().is_some() {}`   (clippy::redundant_pattern_matching)
2020-03-04 20:41:03 +01:00
Dylan DPC 0255561dea
Rollup merge of #69623 - Centril:fix-69396-tmp, r=petrochenkov
stash API: remove panic to fix ICE.

Implements the temporary solution suggested in https://github.com/rust-lang/rust/pull/69537#issuecomment-593143975.
Fixes https://github.com/rust-lang/rust/issues/69396.

r? @petrochenkov
2020-03-02 13:42:41 +01:00
Mazdak Farrokhzad df20036848 stash API: remove panic to fix ICE. 2020-03-02 00:07:23 +01:00
Jake Vossen 5f3ffee6b7
added `try_find_description` to distinguish no desc from invalid code 2020-02-29 11:53:51 -07:00
Maxim Zholobak 20c9a40fec Rename CodeMap to SourceMap follow up 2020-02-22 16:17:31 +02:00
Dylan DPC ec0cfd1d01
Rollup merge of #66498 - bjorn3:less_feature_flags, r=Dylan-DPC
Remove unused feature gates

I think many of the remaining unstable things can be easily be replaced with stable things. I have kept the `#![feature(nll)]` even though it is only necessary in `libstd`, to make regressions of it harder.
2020-02-11 16:36:54 +01:00
Eduard-Mihai Burtescu f6fc80206e rustc: rename -Zexternal-macro-backtrace to -Zmacro-backtrace. 2020-02-06 21:32:07 +02:00
bjorn3 3e61d52784 Remove unused feature gates from librustc_errors 2020-02-04 19:18:11 +01:00
Esteban Küber b626202087 Do not ICE on multipart suggestions touching multiple files
When encountering a multipart suggestion with spans belonging to
different contexts, skip that suggestion.
2020-01-24 18:03:09 -08:00
Esteban Küber 03240e1359 review comments 2020-01-16 18:55:23 -08:00
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