Commit Graph

26 Commits

Author SHA1 Message Date
The 8472 f3bc08adbd ignore/fix layout-sensitive tests 2024-08-31 23:56:45 +02:00
Noah Lev 37ed7a4438 Add `ConstArgKind::Path` and make `ConstArg` its own HIR node
This is a very large commit since a lot needs to be changed in order to
make the tests pass. The salient changes are:

- `ConstArgKind` gets a new `Path` variant, and all const params are now
  represented using it. Non-param paths still use `ConstArgKind::Anon`
  to prevent this change from getting too large, but they will soon use
  the `Path` variant too.

- `ConstArg` gets a distinct `hir_id` field and its own variant in
  `hir::Node`. This affected many parts of the compiler that expected
  the parent of an `AnonConst` to be the containing context (e.g., an
  array repeat expression). They have been changed to check the
  "grandparent" where necessary.

- Some `ast::AnonConst`s now have their `DefId`s created in
  rustc_ast_lowering rather than `DefCollector`. This is because in some
  cases they will end up becoming a `ConstArgKind::Path` instead, which
  has no `DefId`. We have to solve this in a hacky way where we guess
  whether the `AnonConst` could end up as a path const since we can't
  know for sure until after name resolution (`N` could refer to a free
  const or a nullary struct). If it has no chance as being a const
  param, then we create a `DefId` in `DefCollector` -- otherwise we
  decide during ast_lowering. This will have to be updated once all path
  consts use `ConstArgKind::Path`.

- We explicitly use `ConstArgHasType` for array lengths, rather than
  implicitly relying on anon const type feeding -- this is due to the
  addition of `ConstArgKind::Path`.

- Some tests have their outputs changed, but the changes are for the
  most part minor (including removing duplicate or almost-duplicate
  errors). One test now ICEs, but it is for an incomplete, unstable
  feature and is now tracked at #127009.
2024-07-16 19:27:28 -07:00
Vadim Petrochenkov ba3f6812c1 ast: Standardize visiting order
Id, attributes, inner nodes in source order if possible, tokens, span.

Also always use exhaustive matching in visiting infra, and visit some missing nodes.
2024-06-26 17:41:24 +03:00
bors 09cd00fea4 Auto merge of #124401 - oli-obk:some_hir_cleanups, r=cjgillot
Some hir cleanups

It seemed odd to not put `AnonConst` in the arena, compared with the other types that we did put into an arena. This way we can also give it a `Span` without growing a lot of other HIR data structures because of the extra field.

r? compiler
2024-05-04 00:32:27 +00:00
Santiago Pastorino f06e0f7837
Add StaticForeignItem and use it on ForeignItemKind 2024-04-29 13:15:51 -03:00
Oli Scherer 90704199fa Bless ui tests 2024-04-29 08:30:05 +00:00
Guillaume Gomez ac1b8575c0 Update `tests/ui/stats/hir-stats.stderr` output 2024-03-14 12:42:04 +01:00
Esteban Küber bde2dfb127 Detect more cases of `=` to `:` typo
When a `Local` is fully parsed, but not followed by a `;`, keep the `:` span
arround and mention it. If the type could continue being parsed as an
expression, suggest replacing the `:` with a `=`.

```
error: expected one of `!`, `+`, `->`, `::`, `;`, or `=`, found `.`
 --> file.rs:2:32
  |
2 |     let _: std::env::temp_dir().join("foo");
  |          -                     ^ expected one of `!`, `+`, `->`, `::`, `;`, or `=`
  |          |
  |          while parsing the type for `_`
  |          help: use `=` if you meant to assign
```

Fix #119665.
2024-03-01 02:03:00 +00:00
许杰友 Jieyou Xu (Joe) ec2cc761bc
[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
Michael Goulet 0eb2adb7e8 Add async bound modifier to enable async Fn bounds 2024-01-31 16:59:19 +00:00
Matthew Jasper 407cb24142 Remove `hir::Guard`
Use Expr instead. Use `ExprKind::Let` to represent if let guards.
2024-01-05 10:56:59 +00:00
Michael Goulet 909dd864f1 Make closures carry their own ClosureKind, rather than deducing what it is from movability 2023-12-25 16:29:15 +00:00
León Orell Valerian Liehr 5e4f12b41a
Refactor AST trait bound modifiers 2023-12-20 19:39:46 +01:00
Deadbeef 16040a1628 Add `Span` to `TraitBoundModifier` 2023-11-24 14:32:05 +00:00
Matthias Krüger efee13ab33
Rollup merge of #116067 - saethlin:meta-stats-ice, r=WaffleLapkin
Open the FileEncoder file for reading and writing

Maybe I just don't know `File` well enough, but the previous comment didn't make it clear enough to me that we can't use `File::create`. This one does.

Fixes https://github.com/rust-lang/rust/issues/116055

r? `@WaffleLapkin`
2023-09-22 23:12:38 +02:00
Ben Kimock 09960e0319 Open the FileEncoder file for reading and writing 2023-09-22 16:13:25 -04:00
Michael Goulet 087a571e70 Record asyncness span in HIR 2023-09-21 19:18:14 +00:00
Oli Scherer 373807a95c Rename `ast::Static` to `ast::StaticItem` to match `ast::ConstItem` 2023-04-04 15:34:40 +00:00
Nicholas Nethercote 7e855d5f31 Use `ThinVec` in a few more AST types. 2023-02-21 11:51:56 +11:00
Nicholas Nethercote 912b825002 Use `ThinVec` in `ast::PatKind::Struct`. 2023-02-21 11:51:56 +11:00
Nicholas Nethercote b14b7ba5dd Use `ThinVec` in `ast::Block`. 2023-02-21 11:51:56 +11:00
Nicholas Nethercote 4143b101f9 Use `ThinVec` in various AST types.
This commit changes the sequence parsers to produce `ThinVec`, which
triggers numerous conversions.
2023-02-21 11:51:56 +11:00
Nicholas Nethercote 068db466e8 Use `ThinVec` in `ast::WhereClause`. 2023-02-21 11:51:55 +11:00
Nicholas Nethercote dd7aff5cc5 Use `ThinVec` in `ast::Generics` and related types. 2023-02-21 11:51:55 +11:00
Nicholas Nethercote e30cd18fcc Reinstate the `hir-stats.rs` tests on stage 1. 2023-02-02 10:24:30 +11:00
Albert Larsan cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00