summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/expr.rs
AgeCommit message (Collapse)AuthorLines
2022-02-12Rollup merge of #93595 - compiler-errors:ice-on-lifetime-arg, r=jackh726Matthias Krüger-3/+3
fix ICE when parsing lifetime as function argument I don't really like this, but we basically need to emit an error instead of just delaying an bug, because there are too many places in the AST that aren't covered by my previous PRs... cc: https://github.com/rust-lang/rust/issues/93282#issuecomment-1028052945
2022-02-03clippy::perf fixesMatthias Krüger-3/+3
single_char_pattern and to_string_in_format_args
2022-02-02fix ICE when parsing lifetime as function argumentMichael Goulet-3/+3
2022-01-31Write UI tests, tweak message5225225-3/+2
2022-01-27Suggest making base prefix lowercase if parsing fails5225225-0/+26
2022-01-25delay the bug once again, generalize turbofish suggestionMichael Goulet-4/+3
2022-01-25Remove delayed bug when encountering label in bad turbofishMichael Goulet-2/+3
2022-01-22Fix let_chains and if_let_guard feature flagsCaio-3/+17
2022-01-17Rollup merge of #92876 - compiler-errors:fix-turbofish-lifetime-suggestion, ↵Matthias Krüger-1/+7
r=nagisa Fix suggesting turbofish with lifetime arguments Now we suggest turbofish correctly given exprs like `foo<'_>`. Also fix suggestion when we have `let x = foo<bar, baz>;` which was broken.
2022-01-13Fix suggesting turbofish with lifetime argumentsMichael Goulet-1/+7
2022-01-14Parse `Ty?` as `Option<Ty>` and provide structured suggestionEsteban Kuber-2/+2
Swift has specific syntax that desugars to `Option<T>` similar to our `?` operator, which means that people might try to use it in Rust. Parse it and gracefully recover.
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-4/+6
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-2/+2
2021-12-14Stabilize `destructuring_assignment`Jacob Pratt-2/+0
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-2/+4
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-14Rollup merge of #91597 - r00ster91:lessthangreaterthan, r=oli-obkMatthias Krüger-1/+33
Recover on invalid operators `<>` and `<=>` Thanks to #89871 for showing me how to do this. Next, I think it'd be nice to recover on `<=>` too, like #89871 intended, if this even works.
2021-12-14Recover on invalid operators <> and <=>r00ster91-1/+33
2021-12-08Do not attempt to suggest help for overly malformed struct/function callthreadexception-20/+27
2021-12-01Improve diagnostic for missing half of binary operator in `if` conditionFabian Wolff-10/+41
2021-11-25Auto merge of #85346 - estebank:issue-84946, r=nagisa,varkorbors-1/+1
Account for incorrect `impl Foo<const N: ty> {}` syntax Fix #84946
2021-11-24Account for incorrect `impl Foo<const N: ty> {}` syntaxEsteban Küber-1/+1
Fix #84946
2021-11-22Split inline const to two feature gatesGary Guo-1/+1
2021-11-20Fix float ICEthreadexception-0/+2
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2021-10-07some clippy::perf fixesMatthias Krüger-1/+1
2021-10-04Use `TokenKind::similar_tokens()`Fabian Wolff-1/+4
2021-10-03Try to recover from a `=>` -> `=` or `->` typo in a match armFabian Wolff-1/+15
2021-09-23Rollup merge of #89023 - Wardenfar:issue-85066, r=nagisaJubilee-0/+14
Resolve issue : Somewhat confusing error with extended_key_value_attributes Fixes #85066
2021-09-22Rollup merge of #89046 - oli-obk:fix_oflo, r=estebankthe8472-0/+1
"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-0/+1
2021-09-19Suggest replacing braces for brackets on array-esque invalid block exprHirochika Matsumoto-4/+54
Newcomers may write `{1, 2, 3}` for making arrays, and the current error message is not informative enough to quickly convince them what is needed to fix the error. This PR implements a diagnostic for this case, and its output looks like this: ```text error: this code is interpreted as a block expression, not an array --> src/lib.rs:1:22 | 1 | const FOO: [u8; 3] = { | ______________________^ 2 | | 1, 2, 3 3 | | }; | |_^ | = note: to define an array, one would use square brackets instead of curly braces help: try using [] instead of {} | 1 | const FOO: [u8; 3] = [ 2 | 1, 2, 3 3 | ]; | ``` Fix #87672
2021-09-19Resolve issue 85066Theo-0/+14
Fix : use struct_dummy Fix different os messages
2021-09-17Use `multipart_suggestion`Yuki Okushi-1/+1
2021-09-16Rollup merge of #88729 - estebank:struct-literal-using-parens, r=oli-obkManish Goregaokar-10/+91
Recover from `Foo(a: 1, b: 2)` Detect likely `struct` literal using parentheses as delimiters and emit targeted suggestion instead of type ascription parse error. Fix #61326.
2021-09-14review comment: move recovery code to its own functionEsteban Kuber-2/+19
2021-09-09Emit proper errors on missing closure bracesSasha Pourcelot-4/+26
This commit focuses on emitting clean errors for the following syntax error: ``` Some(42).map(|a| dbg!(a); a ); ``` Previous implementation tried to recover after parsing the closure body (the `dbg` expression) by replacing the next `;` with a `,`, which made the next expression belong to the next function argument. As such, the following errors were emitted (among others): - the semicolon token was not expected, - a is not in scope, - Option::map is supposed to take one argument, not two. This commit allows us to gracefully handle this situation by adding giving the parser the ability to remember when it has just parsed a closure body inside a function call. When this happens, we can treat the unexpected `;` specifically and try to parse as much statements as possible in order to eat the whole block. When we can't parse statements anymore, we generate a clean error indicating that the braces are missing, and return an ExprKind::Err.
2021-09-08Rollup merge of #88553 - theo-lw:issue-88276, r=estebankJack Huey-0/+20
Improve diagnostics for unary plus operators (#88276) This pull request improves the diagnostics emitted on parsing a unary plus operator. See #88276. Before: ``` error: expected expression, found `+` --> src/main.rs:2:13 | 2 | let x = +1; | ^ expected expression ``` After: ``` error: leading `+` is not supported --> main.rs:2:13 | 2 | let x = +1; | ^ | | | unexpected `+` | help: try removing the `+` ```
2021-09-07Recover from `Foo(a: 1, b: 2)`Esteban Kuber-10/+74
Detect likely `struct` literal using parentheses as delimiters and emit targeted suggestion instead of type ascription parse error. Fix #61326.
2021-09-04Use verbose suggestions and only match if the + is seen before a numeric literalTheodore Luo Wang-4/+3
2021-09-01Undo debug statementsTheodore Luo Wang-11/+1
2021-09-01Update formattingTheodore Luo Wang-1/+1
2021-09-01Add checks for a block before a unary plus. Fix failing testsTheodore Luo Wang-8/+22
2021-08-31Apply formattingTheodore Luo Wang-1/+6
2021-08-31Improve error checking on unary plusTheodore Luo Wang-0/+12
2021-08-31Rollup merge of #88450 - notriddle:notriddle/maybe_whole_expr, r=cjgillotMara Bos-2/+2
fix(rustc_parse): correct span in `maybe_whole_expr!` Fixes #87812
2021-08-29Auto merge of #88262 - klensy:pprust-cow, r=nagisabors-1/+1
Cow'ify some pprust methods Reduce number of potential needless de/allocations by using `Cow<'static, str>` instead of explicit `String` type.
2021-08-28fix(rustc_parse): incorrect span information for macro path exprMichael Howell-1/+1
Old error output: 3 | let _: usize = $f; | ----- ^ expected `usize`, found struct `Baz` | | | expected due to this New error output: 3 | let _: usize = $f; | ----- ^^ expected `usize`, found struct `Baz` | | | expected due to this
2021-08-28fix(rustc_parse): incorrect span information for macro block exprMichael Howell-1/+1
Old error output: = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap this expression in parentheses | 4 | break '_l $f(;) | ^ ^ New error output: = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) help: wrap this expression in parentheses | 4 | break '_l ($f); | ^ ^
2021-08-25Convert some functions to return Cow<'static,str> instead of String to ↵klensy-1/+1
reduce potential reallocations
2021-08-22Fix typos “a”→“an”Frank Steffahn-1/+1
2021-08-15Introduce hir::ExprKind::Let - Take 2Caio-1/+1