about summary refs log tree commit diff
path: root/src/tools/rust-analyzer/crates/syntax
AgeCommit message (Collapse)AuthorLines
2024-08-26Fix Return Type Syntax to include `..` (i.e. `method(..)` and not ↵Chayim Refael Friedman-1/+41
`method()`) as specified in the RFC
2024-08-24Impl PartialEq and Eq for `IndentLevel`Chayim Refael Friedman-1/+1
We can impl PartialOrd and Ord too, but I didn't need that.
2024-08-24Provide `impl From<ast::TypeOrConstParam> for ast::GenericParam`Chayim Refael Friedman-1/+10
2024-08-24Modify `hacks::parse_expr_from_str()` to take an edition tooChayim Refael Friedman-2/+2
This will be needed as we parse unknown identifiers and want to insert them into source code.
2024-08-24Add `gen` modifier to functionsChayim Refael Friedman-2/+6
We don't yet lower or maybe even parse them, but blocks already have `gen`, so why not.
2024-08-17Pin `rowan` to `0.15.15`Shoyu Vanilla-1/+1
2024-08-16Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword, r=Veykrilbors-0/+1
fix: Properly account for editions in names This PR touches a lot of parts. But the main changes are changing `hir_expand::Name` to be raw edition-dependently and only when necessary (unrelated to how the user originally wrote the identifier), and changing `is_keyword()` and `is_raw_identifier()` to be edition-aware (this was done in #17896, but the FIXMEs were fixed here). It is possible that I missed some cases, but most IDE parts should properly escape (or not escape) identifiers now. The rules of thumb are: - If we show the identifier to the user, its rawness should be determined by the edition of the edited crate. This is nice for IDE features, but really important for changes we insert to the source code. - For tests, I chose `Edition::CURRENT` (so we only have to (maybe) update tests when an edition becomes stable, to avoid churn). - For debugging tools (helper methods and logs), I used `Edition::LATEST`. Reviewing notes: This is a really big PR but most of it is mechanical translation. I changed `Name` displayers to require an edition, and followed the compiler errors. Most methods just propagate the edition requirement. The interesting cases are mostly in `ide-assists`, as sometimes the correct crate to fetch the edition from requires awareness (there may be two). `ide-completions` and `ide-diagnostics` were solved pretty easily by introducing an edition field to their context. `ide` contains many features, for most of them it was propagated to the top level function and there the edition was fetched based on the file. I also fixed all FIXMEs from #17896. Some required introducing an edition parameter (usually not for many methods after the changes to `Name`), some were changed to a new method `is_any_identifier()` because they really want any possible keyword. Fixes #17895. Fixes #17774.
2024-08-16Properly account for editions in namesChayim Refael Friedman-0/+1
This PR touches a lot of parts. But the main changes are changing `hir_expand::Name` to be raw edition-dependently and only when necessary (unrelated to how the user originally wrote the identifier), and changing `is_keyword()` and `is_raw_identifier()` to be edition-aware (this was done in #17896, but the FIXMEs were fixed here). It is possible that I missed some cases, but most IDE parts should properly escape (or not escape) identifiers now. The rules of thumb are: - If we show the identifier to the user, its rawness should be determined by the edition of the edited crate. This is nice for IDE features, but really important for changes we insert to the source code. - For tests, I chose `Edition::CURRENT` (so we only have to (maybe) update tests when an edition becomes stable, to avoid churn). - For debugging tools (helper methods and logs), I used `Edition::LATEST`.
2024-08-16Auto merge of #17907 - ChayimFriedman2:no-once_cell, r=Veykrilbors-3/+3
internal: Replace once_cell with std's recently stabilized OnceCell/Lock and LazyCell/Lock This doesn't get rid of the once_cell dependency, unfortunately, since we have dependencies that use it, but it's a nice to do cleanup. And when our deps will eventually get rid of once_cell we will get rid of it for free.
2024-08-16Replace once_cell with std's recently stabilized OnceCell/Lock and LazyCell/LockChayim Refael Friedman-3/+3
This doesn't get rid of the once_cell dependency, unfortunately, since we have dependencies that use it, but it's a nice to do cleanup. And when our deps will eventually get rid of once_cell we will get rid of it for free.
2024-08-15internal: Properly check the edition for edition dependent syntax kindsLukas Wirth-17/+15
2024-08-06Replace `[package.repository] = "…"` of published crates with ↵Vincent Esche-1/+1
`[package.repository.workspace] = true`
2024-08-06Apply Veykril's change suggestionsVincent Esche-1/+1
2024-08-06Replace `"TBD"` with more helpful desciptions in published crates' ↵Vincent Esche-1/+1
`[package.description]` fields
2024-08-02internal: Remove AbsPathBuf::TryFrom impl that checks too many things at onceLukas Wirth-2/+2
2024-07-25Auto merge of #17676 - winstxnhdw:precise-capturing, r=Veykrilbors-0/+9
feat: add preliminary support for `+ use<..>` `precise_capturing` syntax ## Summary This PR adds basic support for the following syntax. ```rs fn captures<'a: 'a, 'b: 'b, T>() -> impl Sized + use<'b, T> {} // ~~~~~~~~~~~~~~~~~~~~~~~ // This opaque type does not capture `'a`. fn outlives<'o, T: 'o>(_: T) {} fn caller<'o, 'a, 'b: 'o, T: 'o>() { // ~~ // ^ Note that we don't need `'a: 'o`. outlives::<'o>(captures::<'a, 'b, T>()); } ``` Related to #17598
2024-07-25Generate From impls for Any* nodesLukas Wirth-18/+624
2024-07-25fix: temporarily use `ast::GenericParamList`winstxnhdw-0/+4
2024-07-24fix: `use` cannot have optional genericsWinston H.-1/+1
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2024-07-23feat: add `use` type bound grammarwinstxnhdw-0/+5
2024-07-20Auto merge of #17641 - nyurik:optimize-refs, r=Veykrilbors-5/+5
Avoid ref when using format! in compiler Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse. See https://github.com/rust-lang/rust-clippy/issues/10851
2024-07-19Avoid ref when using format! in compilerYuri Astrakhan-5/+5
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
2024-07-19Fix edition used for include macro parsingLukas Wirth-3/+3
2024-07-18Encode edition within FileId in the hir layerLukas Wirth-11/+12
2024-07-17string is not a keywordLukas Wirth-1/+1
2024-07-17Add always disabled gen parse supportLukas Wirth-12/+61
2024-07-17Derive kinds information from ungrammar fileLukas Wirth-209/+74
2024-07-16Remove Name::to_smol_strLukas Wirth-1/+1
2024-07-10Add `f16` and `f128` supportbeetrees-9/+16
2024-07-08fix: Fix double rounding of `f32` literalsbeetrees-15/+10
2024-07-07Inline all the thingsLukas Wirth-0/+1019
2024-07-07HasGenericArgs syntax traitLukas Wirth-7/+39
2024-07-07Run codegen commands as tests if their results are commitedLukas Wirth-2/+2
2024-07-03Fix up the syntax tree for macro 2.0Lukas Wirth-9/+56
2024-06-30Remove inline `rust_2018_idioms, unused_lifetimes` lint warn, Cargo.toml ↵Lukas Wirth-1/+0
already enforces this
2024-06-21fix: don't remove parentheses for calls of function-like pointers that are ↵davidsemakula-0/+8
members of a struct or union
2024-06-18Update lib.rsabdullathedruid-1/+1
2024-06-06chore: Prefer tracing span shorthand macrosWilfred Hughes-8/+8
2024-06-03Auto merge of #17315 - hamirmahal:style/simplify-string-interpolation, r=Veykrilbors-2/+2
style: simplify string interpolation
2024-06-02fix typos & formattingDropDemBits-1/+5
2024-06-02Make `extract_expressions_from_format_string` only use snippets when availableDropDemBits-1/+1
2024-06-02Add `ast::Expr::parse`DropDemBits-0/+32
2024-06-02minor: tidy up `Parse` a little bitDropDemBits-11/+10
- Add doc comments to some `Parse` methods - Uses `Parse::new` more
2024-05-30style: simplify string interpolationHamir Mahal-2/+2
2024-05-23Auto merge of #17140 - harrysarson:harry-unused-self, r=Veykrilbors-2/+19
handle {self} when removing unused imports Fixes #17139 On master ```rs mod inner { pub struct X(); pub struct Y(); } mod z { use super::inner::{self, X}$0; fn f() { let y = inner::Y(); } } ``` becomes ```rs mod inner { pub struct X(); pub struct Y(); } mod z { use super::inner:self; fn f() { let y = inner::Y(); } } ``` with this fix it instead becomes ``` ```rs mod inner { pub struct X(); pub struct Y(); } mod z { use super::inner; fn f() { let y = inner::Y(); } } ```
2024-05-18Allow hir::Param to refer to other entity params aside from functionsLukas Wirth-9/+10
2024-05-14Auto merge of #17224 - Veykril:lock-bump, r=Veykrilbors-1/+1
Bump Cargo.lock
2024-05-14Bump Cargo.lockLukas Wirth-1/+1
2024-05-13Render literal escaping errors in hoversLukas Wirth-56/+45
2024-05-06Implement unsafe attribute parsingLukas Wirth-3/+7