Commit Graph

134 Commits

Author SHA1 Message Date
PFPoitras 2ca95b6134 Stabilize iter::zip. 2021-12-14 18:50:31 -04:00
Matthias Krüger 0108e4b70b Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbini
Bump stage0 compiler

r? `@pietroalbini` (or anyone else)
2021-12-02 15:52:03 +01:00
Joshua Nelson e0df6db4fa Include lint errors in error count for -Ztreat-err-as-bug
This was a regression from https://github.com/rust-lang/rust/pull/87337;
the `panic_if_treat_err_as_bug` function only checked the number of hard
errors, not the number of lint errors.
2021-12-01 16:39:55 +00:00
Mark Rousskov f68ce1a624 Apply cfg-bootstrap switch 2021-11-30 10:51:42 -05:00
Yuki Okushi 50d617ab7c Rollup merge of #91358 - kd-collective:fix_typo, r=cjgillot
Fix small typo

Fix a typo in code commenting!
`accross` -> `across`
2021-11-30 17:29:10 +09:00
kijima 402112a4ff Fix small typo 2021-11-30 01:31:10 +09:00
Lucas Kent 914fd292eb Refactor EmitterWriter::emit_suggestion_default 2021-11-27 01:13:37 +11:00
Esteban Kuber 754fc0313b replace_tabs -> normalize_whitespace 2021-11-23 20:37:21 +00:00
Esteban Kuber 370ab5c20d Replace ZWJ with nothing in terminal output 2021-11-23 20:36:14 +00:00
Esteban Kuber fd5e4b915a Align multiline messages to their label (add left margin) 2021-11-20 19:19:33 +00:00
Josh Triplett 32a26a3b0d Stabilize format_args_capture
Works as expected, and there are widespread reports of success with it,
as well as interest in it.
2021-11-15 10:14:29 +01:00
Joshua Nelson 877b9ff5dd Don't abort compilation after giving a lint error
The only reason to use `abort_if_errors` is when the program is so broken that either:
1. later passes get confused and ICE
2. any diagnostics from later passes would be noise

This is never the case for lints, because the compiler has to be able to deal with `allow`-ed lints.
So it can continue to lint and compile even if there are lint errors.
2021-11-08 01:22:28 +00:00
Esteban Küber 63e29d591c Lint against RTL unicode codepoints in literals and comments
Address CVE-2021-42574.
2021-10-31 13:14:04 +01:00
Mark Rousskov ed9ff1b8fc Revert "Add rustc lint, warning when iterating over hashmaps" 2021-10-28 11:01:42 -04:00
bors b443710e2a Auto merge of #89427 - estebank:collect-overlapping-impls, r=jackh726
Point at overlapping impls when type annotations are needed

Address https://github.com/rust-lang/rust/issues/89254.
2021-10-24 22:26:41 +00:00
Esteban Kuber 8d647780ec Always sort suggestions before emitting them 2021-10-24 20:28:44 +00:00
Matthias Krüger 290dc3fea6 Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank
Add rustc lint, warning when iterating over hashmaps

r? rust-lang/wg-incr-comp
2021-10-24 15:48:42 +02:00
Matthias Krüger a9d96448c1 Rollup merge of #89468 - FabianWolff:issue-89358, r=jackh726
Report fatal lexer errors in `--cfg` command line arguments

Fixes #89358. The erroneous behavior was apparently introduced by `@Mark-Simulacrum` in https://github.com/rust-lang/rust/commit/7f24abea5fa1d29c4e568c8fe2535f718f9737f4; the idea is to silence individual parser errors and instead emit one catch-all error message after parsing. However, for the example in #89358, a fatal lexer error is created here:
https://github.com/rust-lang/rust/blob/1f593a0f998ec67c6dc3a08b2ab8a2824b1a1340/compiler/rustc_parse/src/lexer/mod.rs#L340-L349

This fatal error aborts the compilation, and so the call to `new_parser_from_source_str()` never returns and the catch-all error message is never emitted. I have therefore changed the `SilentEmitter` to silence only non-fatal errors; with my changes, for the rustc invocation described in #89358:
```sh
rustc --cfg "abc\""
```
I get the following output:
```
error[E0765]: unterminated double quote string
  |
  = note: this error occurred on the command line: `--cfg=abc"`
```
2021-10-23 05:28:22 +02:00
bors d5c56b58f0 Auto merge of #89933 - est31:let_else, r=michaelwoerister
Adopt let_else across the compiler

This performs a substitution of code following the pattern:

```
let <id> = if let <pat> = ... { identity } else { ... : ! };
```

To simplify it to:

```
let <pat> = ... { identity } else { ... : ! };
```

By adopting the `let_else` feature (cc #87335).

The PR also updates the syn crate because the currently used version of the crate doesn't support `let_else` syntax yet.

Note: Generally I'm the person who *removes* usages of unstable features from the compiler, not adds more usages of them, but in this instance I think it hopefully helps the feature get stabilized sooner and in a better state. I have written a [comment](https://github.com/rust-lang/rust/issues/87335#issuecomment-944846205) on the tracking issue about my experience and what I feel could be improved before stabilization of `let_else`.
2021-10-19 14:41:39 +00:00
est31 20353504e9 Adopt let_else across the compiler
This performs a substitution of code following the pattern:

let <id> = if let <pat> = ... { identity } else { ... : ! };

To simplify it to:

let <pat> = ... { identity } else { ... : ! };

By adopting the let_else feature.
2021-10-16 07:18:05 +02:00
David Wood 7b961d4d17 emitter: current substitution can be multi-line
In `splice_lines`, there is some arithmetic to compute the required
alignment such that future substitutions in a suggestion are aligned
correctly. However, this assumed that the current substitution's span
was only on a single line. In circumstances where this was not true, it
could result in a arithmetic overflow when the substitution's end
column was less than the substitution's start column.

Signed-off-by: David Wood <david.wood@huawei.com>
2021-10-15 15:30:43 +00:00
lcnr a55adf3606 allow potential_query_instability everywhere 2021-10-15 10:58:18 +02:00
Eliza Weisman 89f48c7663 use structured fields in some existing warnings
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07 10:48:48 -07:00
Fabian Wolff 4a6ee2ca2d Report fatal lexer errors in --cfg command line arguments 2021-10-02 19:15:55 +02:00
the8472 0dea283e42 Rollup merge of #89046 - oli-obk:fix_oflo, r=estebank
"Fix" an overflow in byte position math

r? `@estebank`

help! I fixed the ICE only to brick the diagnostic.

I mean, it was wrong previously (using an already expanded macro span), but it is really bad now XD
2021-09-22 19:03:22 +02:00
Mark Rousskov f5a19f35c1 Migrate to 2021 2021-09-20 22:21:42 -04:00
Oli Scherer a7bd64e2ba Add some more tracing 2021-09-20 15:24:47 +00:00
Mark Rousskov eff1c0c723 Workaround ICE with if-let and RFC 2229 2021-09-20 08:45:39 -04:00
Yuki Okushi 44275d5f6f Make diagnostics clearer for ? operators 2021-09-17 13:13:28 +09:00
bors 4d9b215b1a Auto merge of #87915 - estebank:fancy-spans, r=oli-obk
Use smaller spans for some structured suggestions

Use more accurate suggestion spans for

* argument parse error
* fully qualified path
* missing code block type
* numeric casts
2021-09-13 16:31:12 +00:00
Mark Rousskov 82c064933c Bump stage0 compiler to 1.56 2021-09-08 20:51:05 -04:00
bors f3c2ec1c26 Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank
Fix #88256 remove duplicated diagnostics

Fix #88256
2021-09-06 00:14:41 +00:00
yukang 634efde052 Fix #88256, remove duplicated diagnostic 2021-09-04 19:26:25 +08:00
Michael Woerister 56cc8e775a Path remapping: Make behavior of diagnostics output dependent on presence of --remap-path-prefix. 2021-08-27 11:50:44 +02:00
Léo Lanteri Thauvin 40f1dd91c1 Use if-let guards in the codebase 2021-08-25 20:24:35 +02:00
Esteban Kuber 99dcdd880a review comments 2021-08-23 14:31:48 +00:00
Esteban Kuber a21c208934 remove unnecessary info!() logging 2021-08-23 11:58:19 +00:00
Esteban Kuber dd5f6f8f90 Fixes to span locations 2021-08-23 11:58:19 +00:00
Esteban Kuber 559b875842 wip 2021-08-23 11:58:19 +00:00
Esteban Kuber 1ce2259b6a Account for tabs when highlighting multiline code suggestions 2021-08-23 11:58:18 +00:00
Esteban Kuber 458506c88e Use smaller spans for some structured suggestions
Use more accurate suggestion spans for

* argument parse error
* fully qualified path
* missing code block type
* numeric casts
* E0212
2021-08-12 09:52:38 +00:00
Esteban Küber 8e2e27083a Modify structured suggestion output
* On suggestions that include deletions, use a diff inspired output format
* When suggesting addition, use `+` as underline
* Color highlight modified span
2021-08-11 09:46:24 +00:00
Guillaume Gomez 3a1804867e Remove warnings/errors from compiler when using typeck_body in rustdoc span map builder 2021-08-05 23:08:29 +02:00
Fabian Wolff a451c9cc38 Remove trailing whitespace from error messages 2021-08-04 10:48:30 +02:00
bors 123cdb3a20 Auto merge of #87535 - lf-:authors, r=Mark-Simulacrum
rfc3052 followup: Remove authors field from Cargo manifests

Since RFC 3052 soft deprecated the authors field, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information for contributors, we may as well
remove it from crates in this repo.
2021-08-02 05:49:17 +00:00
Esteban Küber dc295510f0 Use multispan suggestions more often
* Use more accurate span for `async move` suggestion
* Use more accurate span for deref suggestion
* Use `multipart_suggestion` more often
2021-07-30 09:26:31 -07:00
Jade c72215df19 rfc3052: Remove authors field from Cargo manifests
Since RFC 3052 soft deprecated the authors field anyway, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information, we should remove it from
crates in this repo.
2021-07-29 14:56:05 -07:00
Esteban Küber 4adce7bd2c Various diagnostics clean ups/tweaks
* Always point at macros, including derive macros
* Point at non-local items that introduce a trait requirement
* On private associated item, point at definition
2021-07-19 08:43:35 -07:00
Eric Huss 8deb34fb72 Simplify future incompatible reporting. 2021-07-11 13:08:58 -07:00
Vadim Petrochenkov 891d674d36 rustc_span: Revert addition of proc_macro field to ExpnKind::Macro
The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.
2021-07-10 23:03:35 +03:00