about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
AgeCommit message (Collapse)AuthorLines
2022-01-23Remove DiagnosticBuilder.quietmark-16/+1
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-3/+3
`Decoder` has two impls: - opaque: this impl is already partly infallible, i.e. in some places it currently panics on failure (e.g. if the input is too short, or on a bad `Result` discriminant), and in some places it returns an error (e.g. on a bad `Option` discriminant). The number of places where either happens is surprisingly small, just because the binary representation has very little redundancy and a lot of input reading can occur even on malformed data. - json: this impl is fully fallible, but it's only used (a) for the `.rlink` file production, and there's a `FIXME` comment suggesting it should change to a binary format, and (b) in a few tests in non-fundamental ways. Indeed #85993 is open to remove it entirely. And the top-level places in the compiler that call into decoding just abort on error anyway. So the fallibility is providing little value, and getting rid of it leads to some non-trivial performance improvements. Much of this commit is pretty boring and mechanical. Some notes about a few interesting parts: - The commit removes `Decoder::{Error,error}`. - `InternIteratorElement::intern_with`: the impl for `T` now has the same optimization for small counts that the impl for `Result<T, E>` has, because it's now much hotter. - Decodable impls for SmallVec, LinkedList, VecDeque now all use `collect`, which is nice; the one for `Vec` uses unsafe code, because that gave better perf on some benchmarks.
2022-01-11Auto merge of #92070 - rukai:replace_vec_into_iter_with_array_into_iter, ↵bors-1/+1
r=Mark-Simulacrum Replace usages of vec![].into_iter with [].into_iter `[].into_iter` is idiomatic over `vec![].into_iter` because its simpler and faster (unless the vec is optimized away in which case it would be the same) So we should change all the implementation, documentation and tests to use it. I skipped: * `src/tools` - Those are copied in from upstream * `src/test/ui` - Hard to tell if `vec![].into_iter` was used intentionally or not here and not much benefit to changing it. * any case where `vec![].into_iter` was used because we specifically needed a `Vec::IntoIter<T>` * any case where it looked like we were intentionally using `vec![].into_iter` to test it.
2022-01-09Compute most of Public/Exported access level in rustc_resolveLamb-3/+0
Mak DefId to AccessLevel map in resolve for export hir_id to accesslevel in resolve and applied in privacy using local def id removing tracing probes making function not recursive and adding comments Move most of Exported/Public res to rustc_resolve moving public/export res to resolve fix missing stability attributes in core, std and alloc move code to access_levels.rs return for some kinds instead of going through them Export correctness, macro changes, comments add comment for import binding add comment for import binding renmae to access level visitor, remove comments, move fn as closure, remove new_key fmt fix rebase fix rebase fmt fmt fix: move macro def to rustc_resolve fix: reachable AccessLevel for enum variants fmt fix: missing stability attributes for other architectures allow unreachable pub in rustfmt fix: missing impl access level + renaming export to reexport Missing impl access level was found thanks to a test in clippy
2022-01-09eplace usages of vec![].into_iter with [].into_iterLucas Kent-1/+1
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-12-02Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbiniMatthias Krüger-1/+0
Bump stage0 compiler r? `@pietroalbini` (or anyone else)
2021-12-01Include lint errors in error count for `-Ztreat-err-as-bug`Joshua Nelson-2/+7
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-11-30Apply cfg-bootstrap switchMark Rousskov-1/+0
2021-11-30Rollup merge of #91358 - kd-collective:fix_typo, r=cjgillotYuki Okushi-1/+1
Fix small typo Fix a typo in code commenting! `accross` -> `across`
2021-11-30Fix small typokijima-1/+1
2021-11-27Refactor EmitterWriter::emit_suggestion_defaultLucas Kent-14/+25
2021-11-23`replace_tabs` -> `normalize_whitespace`Esteban Kuber-6/+6
2021-11-23Replace ZWJ with nothing in terminal outputEsteban Kuber-0/+1
2021-11-20Align multiline messages to their label (add left margin)Esteban Kuber-1/+16
2021-11-15Stabilize format_args_captureJosh Triplett-1/+1
Works as expected, and there are widespread reports of success with it, as well as interest in it.
2021-11-08Don't abort compilation after giving a lint errorJoshua Nelson-11/+41
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-10-31Lint against RTL unicode codepoints in literals and commentsEsteban Küber-1/+19
Address CVE-2021-42574.
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-1/+0
2021-10-24Auto merge of #89427 - estebank:collect-overlapping-impls, r=jackh726bors-3/+7
Point at overlapping impls when type annotations are needed Address https://github.com/rust-lang/rust/issues/89254.
2021-10-24Always sort suggestions before emitting themEsteban Kuber-3/+7
2021-10-24Rollup merge of #89558 - lcnr:query-stable-lint, r=estebankMatthias Krüger-0/+1
Add rustc lint, warning when iterating over hashmaps r? rust-lang/wg-incr-comp
2021-10-23Rollup merge of #89468 - FabianWolff:issue-89358, r=jackh726Matthias Krüger-4/+17
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/a678e3191197f145451c97c6cc884e15cae38186; 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/edebf77e0090195bf80c0d8cda821e1bf9d03053/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-19Auto merge of #89933 - est31:let_else, r=michaelwoeristerbors-5/+2
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-16Adopt let_else across the compilerest31-5/+2
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-15emitter: current substitution can be multi-lineDavid Wood-1/+1
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-15allow `potential_query_instability` everywherelcnr-0/+1
2021-10-07use structured fields in some existing warningsEliza Weisman-1/+1
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-02Report fatal lexer errors in `--cfg` command line argumentsFabian Wolff-4/+17
2021-09-22Rollup merge of #89046 - oli-obk:fix_oflo, r=estebankthe8472-1/+3
"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-20Add some more tracingOli Scherer-1/+3
2021-09-20Workaround ICE with if-let and RFC 2229Mark Rousskov-4/+2
2021-09-17Make diagnostics clearer for `?` operatorsYuki Okushi-0/+12
2021-09-13Auto merge of #87915 - estebank:fancy-spans, r=oli-obkbors-0/+29
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-08Bump stage0 compiler to 1.56Mark Rousskov-1/+0
2021-09-06Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebankbors-1/+49
Fix #88256 remove duplicated diagnostics Fix #88256
2021-09-04Fix #88256, remove duplicated diagnosticyukang-1/+49
2021-08-27Path remapping: Make behavior of diagnostics output dependent on presence of ↵Michael Woerister-6/+6
--remap-path-prefix.
2021-08-25Use if-let guards in the codebaseLéo Lanteri Thauvin-7/+9
2021-08-23review commentsEsteban Kuber-5/+26
2021-08-23remove unnecessary `info!()` loggingEsteban Kuber-2/+1
2021-08-23Fixes to span locationsEsteban Kuber-11/+9
2021-08-23wipEsteban Kuber-20/+13
2021-08-23Account for tabs when highlighting multiline code suggestionsEsteban Kuber-25/+45
2021-08-12Use smaller spans for some structured suggestionsEsteban Kuber-0/+29
Use more accurate suggestion spans for * argument parse error * fully qualified path * missing code block type * numeric casts * E0212
2021-08-11Modify structured suggestion outputEsteban Küber-25/+180
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-08-05Remove warnings/errors from compiler when using typeck_body in rustdoc span ↵Guillaume Gomez-1/+16
map builder
2021-08-04Remove trailing whitespace from error messagesFabian Wolff-2/+5
2021-07-30Use multispan suggestions more oftenEsteban Küber-0/+38
* Use more accurate span for `async move` suggestion * Use more accurate span for deref suggestion * Use `multipart_suggestion` more often
2021-07-19Various diagnostics clean ups/tweaksEsteban Küber-8/+19
* Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition