about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/item.rs
AgeCommit message (Collapse)AuthorLines
2023-08-02Add test for enum with fieldsCatherine Flores-6/+1
2023-08-03Remove `MacDelimiter`.Nicholas Nethercote-2/+2
It's the same as `Delimiter`, minus the `Invisible` variant. I'm generally in favour of using types to make impossible states unrepresentable, but this one feels very low-value, and the conversions between the two types are annoying and confusing. Look at the change in `src/tools/rustfmt/src/expr.rs` for an example: the old code converted from `MacDelimiter` to `Delimiter` and back again, for no good reason. This suggests the author was confused about the types.
2023-07-28Parse generic const itemsLeón Orell Valerian Liehr-20/+128
2023-07-24Recover from some macrosCatherine Flores-11/+35
2023-07-24Specify macro is invalid in certain contextsCatherine-8/+18
2023-07-05Fix the issue of wrong diagnosis for extern pub fnyukang-1/+5
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-1/+1
2023-05-13improve error for `impl<..> impl Trait for Type`y21-4/+18
2023-05-09Rollup merge of #110694 - est31:builtin, r=petrochenkovDylan DPC-0/+8
Implement builtin # syntax and use it for offset_of!(...) Add `builtin #` syntax to the parser, as well as a generic infrastructure to support both item and expression position builtin syntaxes. The PR also uses this infrastructure for the implementation of the `offset_of!` macro, added by #106934. cc `@petrochenkov` `@DrMeepster` cc #110680 `builtin #` tracking issue cc #106655 `offset_of!` tracking issue
2023-05-08make it more accurate by parsing tyyukang-9/+19
2023-05-08suggest struct when we get colon in fileds in enumyukang-0/+9
2023-05-05Add parsing for builtin # in expression and item contextest31-0/+8
2023-05-04Rollup merge of #110791 - compiler-errors:negative-bounds, r=oli-obkDylan DPC-7/+3
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-10/+10
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-7/+3
2023-05-01Rip it outNilstrieb-1/+1
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-27Migrate trivially translatable `rustc_parse` diagnosticsclubby789-90/+29
2023-04-16use matches! macro in more placesMatthias Krüger-8/+6
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-03-20feat: implement error recovery in `expected_ident_found`Ezra Shaw-4/+4
2023-03-19refactor: refactor identifier parsing somewhatEzra Shaw-1/+1
2023-03-03Remove unclosed_delims from parseryukang-18/+6
2023-02-24Replace parse_[sth]_expr with parse_expr_[sth] function namesest31-2/+2
This resolves an inconsistency in naming style for functions on the parser, between functions parsing specific kinds of items and those for expressions, favoring the parse_item_[sth] style used by functions for items. There are multiple advantages of that style: * functions of both categories are collected in the same place in the rustdoc output. * it helps with autocompletion, as you can narrow down your search for a function to those about expressions. * it mirrors rust's path syntax where less specific things come first, then it gets more specific, i.e. std::collections::hash_map::Entry The disadvantage is that it doesn't "read like a sentence" any more, but I think the advantages weigh more greatly. This change was mostly application of this command: sed -i -E 's/(fn |\.)parse_([[:alnum:]_]+)_expr/\1parse_expr_\2/' compiler/rustc_parse/src/parser/*.rs Plus very minor fixes outside of rustc_parse, and an invocation of x fmt.
2023-02-21Use `ThinVec` in a few more AST types.Nicholas Nethercote-2/+2
2023-02-21Use `ThinVec` in various AST types.Nicholas Nethercote-7/+7
This commit changes the sequence parsers to produce `ThinVec`, which triggers numerous conversions.
2023-02-21Use `ThinVec` in `ast::Impl` and related types.Nicholas Nethercote-3/+3
2023-02-19Reduce limit on `macro_rules!` diagnosticJacob Pratt-1/+1
2023-02-19Make public API, docs algorithm-agnosticJacob Pratt-2/+3
2023-02-06Migrate `rustc_parse` to derive diagnosticsclubby789-62/+62
2023-02-02Rename `rust_2015` => `is_rust_2015`Maybe Waffle-1/+1
2023-02-01Make "use latest edition" subdiagnostic translatableXiretza-3/+3
2023-02-01rustc_parse: revert conversion of "non-item in item list" diagnosticXiretza-18/+25
#[derive(Subdiagnostic)] does not allow multiple subdiagnostics on one variant, as in NonItemInItemListSub::Other.
2023-02-01rustc_parse: migrate more to diagnostic structsXiretza-260/+153
2023-02-01Fix condition for "missing `struct`" diagnostic on tuple structsXiretza-1/+1
The check previously matched this, and suggested adding a missing `struct`: pub Foo(...): It was probably intended to match this instead (semicolon instead of colon): pub Foo(...);
2023-02-01Use AddToDiagnostic for "use latest edition" helpXiretza-5/+10
2023-02-01rustc_parse: avoid creating unnecessary intermediate stringsXiretza-1/+2
2023-01-12Auto merge of #106537 - ↵bors-3/+11
fmease:recover-where-clause-before-tuple-struct-body, r=estebank Recover from where clauses placed before tuple struct bodies Open to any suggestions regarding the phrasing of the diagnostic. Fixes #100790. `@rustbot` label A-diagnostics r? diagnostics
2023-01-11parser: recover from where clauses placed before tuple struct bodiesLeón Orell Valerian Liehr-3/+11
2023-01-11Detect struct literal needing parenthesesEsteban Küber-1/+2
Fix #82051.
2022-12-29Auto merge of #106266 - matthiaskrgr:rollup-cxrdbzy, r=matthiaskrgrbors-1/+1
Rollup of 9 pull requests Successful merges: - #104531 (Provide a better error and a suggestion for `Fn` traits with lifetime params) - #105899 (`./x doc library --open` opens `std`) - #106190 (Account for multiple multiline spans with empty padding) - #106202 (Trim more paths in obligation types) - #106234 (rustdoc: simplify settings, help, and copy button CSS by not reusing) - #106236 (docs/test: add docs and a UI test for `E0514` and `E0519`) - #106259 (Update Clippy) - #106260 (Fix index out of bounds issues in rustdoc) - #106263 (Formatter should not try to format non-Rust files) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-12-29Provide a better error for `Fn` traits with lifetime paramsYutaro Ohno-1/+1
Currently, given `Fn`-family traits with lifetime params like `Fn<'a>(&'a str) -> bool`, many unhelpful errors show up. These are a bit confusing. This commit allows these situations to suggest simply using higher-ranked trait bounds like `for<'a> Fn(&'a str) -> bool`.
2022-12-28Tweak wordingEsteban Küber-1/+1
2022-12-28Account for ADT bodies and struct expressionsEsteban Küber-2/+29
2022-12-28Detect diff markers in the parserEsteban Küber-2/+9
Partly address #32059.
2022-12-26Auto merge of #103020 - lyming2007:issue-102598-fix, r=jackh726bors-1/+0
error parsing lifetime following by Sized and message + between them Fixes #102598
2022-12-26remove unused importsTakayuki Maeda-1/+0