about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/diagnostics.rs
AgeCommit message (Collapse)AuthorLines
2023-10-20Move where doc comment meant as comment checkEsteban Küber-1/+21
The new place makes more sense and covers more cases beyond individual statements. ``` error: expected one of `.`, `;`, `?`, `else`, or an operator, found doc comment `//!foo --> $DIR/doc-comment-in-stmt.rs:25:22 | LL | let y = x.max(1) //!foo | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected one of `.`, `;`, `?`, `else`, or an operator | help: add a space before `!` to write a regular comment | LL | let y = x.max(1) // !foo | + ``` Fix #65329.
2023-10-15Auto merge of #116688 - compiler-errors:rustfmt-up, r=WaffleLapkin,Nilstriebbors-42/+50
Format all the let-chains in compiler crates Since rust-lang/rustfmt#5910 has landed, soon we will have support for formatting let-chains (as soon as rustfmt syncs and beta gets bumped). This PR applies the changes [from master rustfmt to rust-lang/rust eagerly](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/out.20formatting.20of.20prs/near/374997516), so that the next beta bump does not have to deal with a 200+ file diff and can remain concerned with other things like `cfg(bootstrap)` -- #113637 was a pain to land, for example, because of let-else. I will also add this commit to the ignore list after it has landed. The commands that were run -- I'm not great at bash-foo, but this applies rustfmt to every compiler crate, and then reverts the two crates that should probably be formatted out-of-tree. ``` ~/rustfmt $ ls -1d ~/rust/compiler/* | xargs -I@ cargo run --bin rustfmt -- `@/src/lib.rs` --config-path ~/rust --edition=2021 # format all of the compiler crates ~/rust $ git checkout HEAD -- compiler/rustc_codegen_{gcc,cranelift} # revert changes to cg-gcc and cg-clif ``` cc `@rust-lang/rustfmt` r? `@WaffleLapkin` or `@Nilstrieb` who said they may be able to review this purely mechanical PR :> cc `@Mark-Simulacrum` and `@petrochenkov,` who had some thoughts on the order of operations with big formatting changes in https://github.com/rust-lang/rust/pull/95262#issue-1178993801. I think the situation has changed since then, given that let-chains support exists on master rustfmt now, and I'm fairly confident that this formatting PR should land even if *bootstrap* rustfmt doesn't yet format let-chains in order to lessen the burden of the next beta bump.
2023-10-13Format all the let chains in compilerMichael Goulet-42/+50
2023-10-12Detect ruby-style closure in parserEsteban Küber-0/+59
When parsing a closure without a body that is surrounded by a block, suggest moving the opening brace after the closure head. Fix #116608.
2023-09-28Tweak wording of missing angle backets in qualified pathEsteban Küber-4/+3
2023-08-08inlined kinddarklyspaced-2/+1
2023-08-07always return ExprKind::Errdarklyspaced-6/+1
2023-08-04Rollup merge of #113999 - Centri3:macro-arm-expand, r=wesleywiserMatthias Krüger-16/+21
Specify macro is invalid in certain contexts Adds a note when a macro is used where it really shouldn't be. Closes #113766
2023-08-03Rollup merge of #114300 - MU001999:fix/turbofish-pat, r=estebankMatthias Krüger-3/+3
Suggests turbofish in patterns Fixes #114112 r? ```@estebank```
2023-08-03Reduce arbitrary self type suggestionsr0cky-15/+3
2023-08-03Avoid too many expected symbols and reduce `None`sr0cky-1/+1
2023-08-03Keep the suggestion for wrong arbitrary self typesMu001999-7/+19
2023-07-31parser: more friendly hints for handling `async move` in the 2015 editionbohan-4/+11
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-2/+2
2023-07-25Only early return if recoveredCatherine Flores-15/+20
2023-07-25Remove unnecessary `maybe_ternary_lo` fieldCatherine Flores-7/+3
2023-07-25Gracefully handle missing ternary operatorCatherine Flores-2/+44
2023-07-24Specify macro is invalid in certain contextsCatherine-16/+21
2023-07-20Don't translate compiler-internal bug messagesOli Scherer-1/+1
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-2/+3
2023-07-04Detect extra space in keyword for better hintyukang-0/+16
2023-06-10remove unwrapyukang-9/+12
2023-06-10take care module name for suggesting surround the struct literal in parenthesesyukang-1/+9
2023-05-24Use `is_some_and`/`is_ok_and` in less obvious spotsMaybe Waffle-1/+1
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-1/+1
2023-05-17Give a more useful location for where a span_bug was delayedjyn-0/+1
Before: ``` = note: delayed at 0: <rustc_errors::HandlerInner>::emit_diagnostic at ./compiler/rustc_errors/src/lib.rs:1335:29 1: <rustc_errors::Handler>::emit_diagnostic at ./compiler/rustc_errors/src/lib.rs:1124:9 ... ``` After: ``` = note: delayed at compiler/rustc_parse/src/parser/diagnostics.rs:2158:28 0: <rustc_errors::HandlerInner>::emit_diagnostic at ./compiler/rustc_errors/src/lib.rs:1335:29 1: <rustc_errors::Handler>::emit_diagnostic at ./compiler/rustc_errors/src/lib.rs:1124:9 ``` This both makes the relevant frame easier to find without having to dig through diagnostic internals, and avoids the weird-looking formatting for the first frame.
2023-05-09move sugg to derive session diagnosticyukang-9/+5
2023-05-08code refactor and fix wrong suggestionyukang-23/+29
2023-05-08fix ice in suggestingyukang-7/+14
2023-05-08cleanupyukang-2/+1
2023-05-08Suggest let for possible binding with tyyukang-0/+17
2023-05-04Rollup merge of #110791 - compiler-errors:negative-bounds, r=oli-obkDylan DPC-1/+1
Implement negative bounds for internal testing purposes Implements partial support the `!` negative polarity on trait bounds. This is incomplete, but should allow us to at least be able to play with the feature. Not even gonna consider them as a public-facing feature, but I'm implementing them because would've been nice to have in UI tests, for example in #110671.
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-14/+14
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-05-02Implement negative boundsMichael Goulet-1/+1
2023-05-01soften the wording for removing type ascriptionyukang-8/+1
2023-05-01fix testsyukang-1/+0
2023-05-01clean up debug codeyukang-10/+1
2023-05-01Rip it outNilstrieb-75/+44
My type ascription Oh rip it out Ah If you think we live too much then You can sacrifice diagnostics Don't mix your garbage Into my syntax So many weird hacks keep diagnostics alive Yet I don't even step outside So many bad diagnostics keep tyasc alive Yet tyasc doesn't even bother to survive!
2023-04-27Tweak await spanMichael Goulet-1/+1
2023-04-15remove redundant clonesMatthias Krüger-5/+3
2023-04-07fix: fix regression in #109203Ezra Shaw-2/+2
2023-03-28Add `(..)` syntax for RTNMichael Goulet-2/+1
2023-03-20feat: implement error recovery in `expected_ident_found`Ezra Shaw-26/+58
2023-03-19refactor: improve "ident starts with number" errorEzra Shaw-10/+24
2023-03-19refactor: refactor identifier parsing somewhatEzra Shaw-4/+13
2023-03-09feat/refactor: improve errors in case of ident with number at startEzra Shaw-14/+27
2023-03-03Remove unclosed_delims from parseryukang-113/+3
2023-03-01Auto merge of #108587 - matthiaskrgr:rollup-rw6po59, r=matthiaskrgrbors-2/+14
Rollup of 10 pull requests Successful merges: - #108376 (compiler/rustc_session: fix sysroot detection logic) - #108400 (add llvm cgu instructions stats to perf) - #108496 (fix #108495, postfix decrement and prefix decrement has no warning) - #108505 (Further unify validity intrinsics) - #108520 (Small cleanup to `one_bound_for_assoc_type`) - #108560 (Some `infer/mod.rs` cleanups) - #108563 (Make mailmap more correct) - #108564 (Fix `x clean` with specific paths) - #108571 (Add contains_key to SortedIndexMultiMap) - #108578 (Update Fuchsia platform team members) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-01Rollup merge of #108496 - nx2k3:issue-108495-dec, r=WaffleLapkinMatthias Krüger-2/+14
fix #108495, postfix decrement and prefix decrement has no warning Fixes #108495
2023-03-01Rollup merge of #108297 - chenyukang:yukang/delim-error-exit, r=petrochenkovMatthias Krüger-3/+3
Exit when there are unmatched delims to avoid noisy diagnostics From https://github.com/rust-lang/rust/pull/104012#issuecomment-1311764832 r? ``@petrochenkov``