about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
AgeCommit message (Collapse)AuthorLines
2023-05-04Rollup merge of #110791 - compiler-errors:negative-bounds, r=oli-obkDylan DPC-90/+53
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-35/+35
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-90/+53
2023-05-01soften the wording for removing type ascriptionyukang-11/+4
2023-05-01fix testsyukang-20/+5
2023-05-01fix parser sizeyukang-1/+1
2023-05-01clean up debug codeyukang-15/+1
2023-05-01Rip it outNilstrieb-192/+274
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-05-01Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naberMatthias Krüger-3/+3
Tweak await span to not contain dot Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue. Fixes #110761 This mostly touches a bunch of tests to tighten their `await` span.
2023-04-27Tweak await spanMichael Goulet-3/+3
2023-04-27Migrate trivially translatable `rustc_parse` diagnosticsclubby789-158/+60
2023-04-25Fix static string lintsclubby789-72/+29
2023-04-17Rollup merge of #110404 - matthiaskrgr:mapmap, r=NilstriebMatthias Krüger-3/+3
fix clippy::toplevel_ref_arg and ::manual_map r? ``@Nilstrieb``
2023-04-16fix clippy::toplevel_ref_arg and ::manual_mapMatthias Krüger-3/+3
2023-04-16use matches! macro in more placesMatthias Krüger-14/+10
2023-04-15remove redundant clonesMatthias Krüger-5/+3
2023-04-12Rollup merge of #110203 - compiler-errors:rtn-dots, r=eholkMatthias Krüger-9/+16
Remove `..` from return type notation `@nikomatsakis` and I decided that using `..` in the return-type notation syntax is probably overkill. r? `@eholk` since you reviewed the last one Since this is piggybacking now totally off of a pre-existing syntax (parenthesized generics), let me know if you need any explanation of the logic here, since it's a bit more complicated now.
2023-04-10Remove `..` from return type notationMichael Goulet-9/+16
2023-04-10Fix typos in compilerDaniPopes-1/+1
2023-04-09Fix some clippy::complexityNilstrieb-1/+1
2023-04-07fix: fix regression in #109203Ezra Shaw-2/+2
2023-04-05Auto merge of #109117 - oli-obk:locks, r=michaelwoeristerbors-2/+5
Avoid a few locks We can use atomics or datastructures tuned for specific access patterns instead of locks. This may be an improvement for parallel rustc, but it's mostly a cleanup making various datastructures only usable in the way they are used right now (append data, never mutate), instead of having a general purpose lock.
2023-04-04Rename `ast::Static` to `ast::StaticItem` to match `ast::ConstItem`Oli Scherer-3/+3
2023-04-04box a bunch of large typesOli Scherer-6/+6
2023-04-04Split out ast::ItemKind::Const into its own structOli Scherer-5/+9
2023-04-04rust-analyzer guided tuple field to named fieldOli Scherer-2/+2
2023-04-04rust-analyzer guided enum variant structificationOli Scherer-2/+3
2023-04-04Use a simpler atomic operation than the `compare_exchange` hammerOli Scherer-3/+1
2023-04-04Replace a lock with an atomicOli Scherer-2/+7
2023-03-28Add `(..)` syntax for RTNMichael Goulet-8/+31
2023-03-28RTNMichael Goulet-1/+5
2023-03-27Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errorsGuillaume Gomez-1/+1
Remove the `NodeId` of `ast::ExprKind::Async` This is a followup to https://github.com/rust-lang/rust/pull/104833#pullrequestreview-1314537416. In my original attempt, I was using `LoweringContext::expr`, which was not correct as it creates a fresh `DefId`. It now uses the correct `DefId` for the wrapping `Expr`, and also makes forwarding `#[track_caller]` attributes more explicit.
2023-03-22Rollup merge of #109203 - Ezrashaw:refactor-ident-parsing, r=NilstriebMatthias Krüger-60/+121
refactor/feat: refactor identifier parsing a bit \+ error recovery for `expected_ident_found` Prior art: #108854
2023-03-21Refactor `handle_missing_lit`.Nicholas Nethercote-14/+8
2023-03-20feat: implement error recovery in `expected_ident_found`Ezra Shaw-36/+79
2023-03-19Remove the `NodeId` of `ast::ExprKind::Async`Arpad Borsos-1/+1
2023-03-19refactor: improve "ident starts with number" errorEzra Shaw-15/+25
2023-03-19refactor: refactor identifier parsing somewhatEzra Shaw-19/+27
2023-03-13Auto merge of #108471 - clubby789:unbox-the-syntax, r=Nilstrieb,est31bors-3/+21
Remove `box_syntax` r? `@Nilstrieb` This removes the feature `box_syntax`, which allows the use of `box <expr>` to create a Box, and finalises removing use of the feature from the compiler. `box_patterns` (allowing the use of `box <pat>` in a pattern) is unaffected. It also removes `ast::ExprKind::Box` - the only way to create a 'box' expression now is with the rustc-internal `#[rustc_box]` attribute. As a temporary measure to help users move away, `box <expr>` now parses the inner expression, and emits a `MachineApplicable` lint to replace it with `Box::new` Closes #49733
2023-03-12Add recovery for use of removed `box` syntaxclubby789-0/+28
2023-03-12Remove `box_syntax` from AST and use in toolsclubby789-10/+0
2023-03-11Gate const closures even when they appear in macrosMichael Goulet-4/+8
2023-03-11Gate all usages of dyn*, even in macrosMichael Goulet-0/+2
2023-03-09feat/refactor: improve errors in case of ident with number at startEzra Shaw-26/+31
2023-03-04Rollup merge of #108715 - chenyukang:yukang/cleanup-parser-delims, ↵Matthias Krüger-158/+12
r=compiler-errors Remove unclosed_delims from parser After landing https://github.com/rust-lang/rust/pull/108297 we could remove `unclosed_delims` from the parser now.
2023-03-04Rollup merge of #108298 - TaKO8Ki:fix-104440, r=cjgillotDylan DPC-2/+7
Fix ICE: check if snippet is `)` Fixes #107705
2023-03-03Remove unclosed_delims from parseryukang-158/+12
2023-03-03Match unmatched backticks in comments in compiler/est31-3/+3
2023-03-03check if snippet is `)`Takayuki Maeda-2/+7
2023-03-01recover from for-else and while-elsey21-0/+22