564 Commits

Author SHA1 Message Date
Lukas Wirth
9d58a93602
Merge pull request #20439 from A4-Tacks/t-macro-bracket-doc
Add guess braces doc `T![]` for `T_`
2025-12-21 14:19:06 +00:00
The rustc-josh-sync Cronjob Bot
f6c67ed0a4 Format code 2025-12-15 04:30:49 +00:00
Jieyou Xu
acb575c6ab
rust-analyzer: prep crates for testing against in-tree rustc_private 2025-12-11 20:22:49 +08:00
Wilfred Hughes
86bc07e91a Fix rustdoc warnings and add CI
rustdoc has a separate environment variable for banning warnings, so
set that in the GitHub action configuration.

https://github.com/rust-lang/cargo/issues/8424#issuecomment-1070988443

Fix all the rustdoc warnings on unknown types or functions. I've
updated references wherever it's obvious, otherwise I've replaced the
rustdoc link with plain backticks.

There were also some cases where rustdoc links referred to private
APIs. I've disabled the rustdoc private API warning in those crates.
2025-12-01 13:06:15 +00:00
Lukas Wirth
1ea2498b49
Merge pull request #20163 from ChayimFriedman2/parser-per-token-edition
fix: Use per-token, not global, edition in the parser
2025-11-28 08:11:38 +00:00
Louis Maddox
2443cce41a fix: no unused tracing/attributes feature
- Discussed in https://github.com/rust-lang/rust-analyzer/issues/21107
- Avoids activating an `attributes` feature to crates that do not use it
- Updates the 6 crates that use attributes feature to specify it in
  their Cargo.toml: {hir,hir-def,hir-ty,ide-assists,ide-db,project-model}
2025-11-23 13:37:42 +00:00
dfireBird
d24a6319db
fix: allow equality expressions in parsing of format_args 2025-11-19 07:12:16 +05:30
Hegui Dai
1e1849f74e format T_ 2025-11-18 21:33:19 +08:00
Shoyu Vanilla (Flint)
ca83ff37d7 Merge pull request #20972 from A4-Tacks/impl-never-type
Fix not parse never type in inherent impl
2025-11-15 09:17:33 +02:00
Shoyu Vanilla
3d636a6ca6 fix: Do not make false positive syntax errors on frontmatter 2025-10-31 00:45:26 +09:00
Lukas Wirth
47c5af2f16 fix: Improve error recovery when parsing malformed function return types 2025-10-29 12:33:35 +01:00
A4-Tacks
891391a6e5
Improve parsing of missing name in MethodCallExpr
Usually, this occurs when preparing to input a method name

However, once an identifier is entered, it is not reasonable for the parsing result to change from `CallExpr(FieldExpr())` to `MethodCallExpr()`

Example
---
```rust
fn foo() {
    x.
    ()
}
```

**Before this PR**:

```text
SOURCE_FILE
  FN
    FN_KW "fn"
    WHITESPACE " "
    NAME
      IDENT "foo"
    PARAM_LIST
      L_PAREN "("
      R_PAREN ")"
    WHITESPACE " "
    BLOCK_EXPR
      STMT_LIST
        L_CURLY "{"
        WHITESPACE "\n    "
        CALL_EXPR
          FIELD_EXPR
            PATH_EXPR
              PATH
                PATH_SEGMENT
                  NAME_REF
                    IDENT "x"
            DOT "."
          WHITESPACE "\n    "
          ARG_LIST
            L_PAREN "("
            R_PAREN ")"
        WHITESPACE "\n"
        R_CURLY "}"
  WHITESPACE "\n"
error 17: expected field name or number
```

**After this PR**:

```text
SOURCE_FILE
  FN
    FN_KW "fn"
    WHITESPACE " "
    NAME
      IDENT "foo"
    PARAM_LIST
      L_PAREN "("
      R_PAREN ")"
    WHITESPACE " "
    BLOCK_EXPR
      STMT_LIST
        L_CURLY "{"
        WHITESPACE "\n    "
        METHOD_CALL_EXPR
          PATH_EXPR
            PATH
              PATH_SEGMENT
                NAME_REF
                  IDENT "x"
          DOT "."
          WHITESPACE "\n    "
          ARG_LIST
            L_PAREN "("
            R_PAREN ")"
        WHITESPACE "\n"
        R_CURLY "}"
  WHITESPACE "\n"
error 17: expected method name, field name or number
```
2025-10-22 14:37:12 +08:00
Ed Page
8231a2b01c feat(parser): Don't error on frontmatter 2025-10-16 11:07:05 -05:00
Ed Page
fff06bc181 test(parser): Show current frontmatter behavior 2025-10-16 11:06:41 -05:00
Ed Page
d57f543373 refactor(parser): Push higher level content 2025-10-16 10:58:31 -05:00
A4-Tacks
2707cf7ce6
Allow generic_param_list for static items 2025-10-09 09:45:42 +08:00
A4-Tacks
216db6d5b4
Improve parsing error for static and const
Example
---
```rust
static C<i32>: u32 = 0;
```
->
```diff
-error 8: missing type for `const` or `static`
+error 8: `static` may not have generic parameters
```

---

```rust
const C = 0;
```
->
```diff
-error 7: missing type for `const` or `static`
+error 7: missing type for `const`
```

---

```rust
static C = 0;
```
->
```diff
-error 8: missing type for `const` or `static`
+error 8: missing type for `static`
```
2025-10-06 12:48:38 +08:00
Lukas Wirth
aed0fec1a9 Auto-attach database in Analysis calls 2025-08-18 09:52:23 +02:00
Ralf Anton Beier
e7c3fe1978
feat: hint at unterminated strings in unknown prefix errors
When encountering 'unknown literal prefix' errors, check for unbalanced
quotes in recent code and suggest checking for unterminated string literals.
2025-08-14 19:30:29 +02:00
Chayim Refael Friedman
9bc940a23c Use per-token edition in the parser 2025-08-13 20:37:46 +03:00
Chayim Refael Friedman
1637ff777e Include a per-token edition in the parser input
Because, as it turns out, this is necessary to determine the correct edition (it is not global).

The next commits will make use of it.
2025-08-13 20:35:16 +03:00
Deadbeef
82f174fbd9 Merge Trait and TraitAlias handling 2025-08-13 15:28:08 +08:00
A4-Tacks
883c5fc191
Add guess braces doc T![] for T_ 2025-08-12 11:46:45 +08:00
Nathaniel McCallum
943b42f743 parser: fix parsing of trait bound polarity and for-binders
The rustc AST allows both `for<>` binders and `?` polarity
modifiers in trait bounds, but they are parsed in a specific
order and validated for correctness:

  1. `for<>` binder is parsed first.
  2. Polarity modifiers (`?`, `!`) are parsed second.
  3. The parser validates that binders and polarity modifiers
     do not conflict:

```rust
if let Some(binder_span) = binder_span {
    match modifiers.polarity {
        BoundPolarity::Maybe(polarity_span) => {
            // Error: "for<...> binder not allowed with ? polarity"
        }
    }
}
```

This implies:

- `for<> ?Sized` → Valid syntax. Invalid semantics.
- `?for<> Sized` → Invalid syntax.

However, rust-analyzer incorrectly had special-case logic that
allowed `?for<>` as valid syntax. This fix removes that incorrect
special case, making rust-analyzer reject `?for<> Sized` as a
syntax error, matching rustc behavior.

This has caused confusion in other crates (such as syn) which
rely on these files to implement correct syntax evaluation.
2025-08-10 02:21:11 -04:00
Lukas Wirth
8ce30264c8 cargo clippy --fix 2025-07-31 10:55:10 +02:00
Chayim Refael Friedman
c7ceb39f67 Parse for<'a> [const]
And also refactor parsing of HRTB.
2025-07-22 16:24:42 +03:00
Laurențiu Nicola
0e2e6e7a8a Format and bump rustc crates 2025-07-15 17:41:08 +03:00
Laurențiu Nicola
f373437c22 Merge from rust-lang/rust 2025-07-15 17:27:46 +03:00
Shoyu Vanilla (Flint)
e9968fc555
Merge pull request #20210 from ChayimFriedman2/naked-asm-safe
fix: Inline asm fixes
2025-07-10 06:28:49 +00:00
Ed Page
f4d9018a48 feat(lexer): Allow including frontmatter with 'tokenize' 2025-07-09 16:42:27 -05:00
Chayim Refael Friedman
95c04c4503 Make global_asm!() work
Because apparently, we were not accepting inline asm in item position, completely breaking it.
2025-07-09 18:55:27 +03:00
Chayim Refael Friedman
bd8087e86e Differentiate between asm!(), global_asm!() and naked_asm!(), and make only asm!() unsafe 2025-07-09 17:37:27 +03:00
Chayim Refael Friedman
87cddda2d8 Always bump in the parser in err_and_bump()
Even when at curly braces, otherwise the parser can get stuck.

This has happened in the past in #18625, but it was just worked around instead of handling the root of the problem. Now this happened again in #20171. IMO we can't let `err_and_bump()` not bump, that's too confusing and invites errors. We can (as I did) workaround the worse recovery instead.
2025-07-06 03:21:43 +03:00
Lukas Wirth
5924b38e3d Parse new const trait syntax 2025-06-26 11:08:30 +02:00
Lukas Wirth
70cbf8332a
Merge pull request #20012 from lnicola/bump-literal-escaper
Update to literal-escaper 0.0.4
2025-06-24 08:21:36 +00:00
Chayim Refael Friedman
de312d0c71 Don't run doctests 2025-06-23 00:50:22 +03:00
Marijn Schouten
13a46eab7d update to literal-escaper 0.0.4 for better API without unreachable and faster string parsing 2025-06-16 15:12:24 +03:00
Lukas Wirth
5d3001795a Better parser recovery for macro calls in type bound position 2025-06-05 16:11:30 +02:00
Lukas Wirth
7c3de05e3a Give path segment type anchors their own grammar rule 2025-06-04 11:40:05 +02:00
Arthur Baars
55328ba9b4 Update expected test output 2025-05-30 21:16:38 +00:00
Arthur Baars
a91b67e682 Run 'cargo codegen' to update tests 2025-05-30 21:05:12 +00:00
Arthur Baars
7f7079f2bf
Add test for closure_binder
Co-authored-by: Lukas Wirth <me@lukaswirth.dev>
2025-05-30 22:58:13 +02:00
Arthur Baars
fb16d3b7f8
Produce ClosureBinder node in atom.rs 2025-05-30 22:38:31 +02:00
Laurențiu Nicola
ac8c057d87 Bump rustc crates 2025-05-20 10:03:14 +03:00
Laurențiu Nicola
9e86544698 Merge from rust-lang/rust 2025-05-20 10:01:00 +03:00
Chayim Refael Friedman
5ed11234cc Improve asm support
Including:

 - Infer `label {}` and `const` operands.
 - Correctly handle unsafe check inside `label {}`.
 - Fix an embarrassing parser typo that cause labels to never be part of the AST
2025-05-15 23:36:00 +03:00
Stuart Cook
9f4e2cc51d
Rollup merge of #140035 - fee1-dead-contrib:push-oszwkkvmpkks, r=jieyouxu,wesleywiser
Implement RFC 3503: frontmatters

Tracking issue: #136889

Supercedes #137193. This implements [RFC 3503](https://github.com/rust-lang/rfcs/blob/master/text/3503-frontmatter.md).

This might break rust-analyzer. Will look into how to fix that.

Suggestions welcome for how to improve diagnostics.
2025-05-06 16:28:39 +10:00
Deadbeef
9fce1dfac5 Implement RFC 3503: frontmatters
Supercedes #137193
2025-05-05 23:10:08 +08:00
Lukas Wirth
e0dca847ad fix: Improve parser recovery a bit 2025-04-30 16:40:01 +02:00
Laurențiu Nicola
1f727edb2d Format code 2025-04-28 11:11:47 +03:00