| Age | Commit message (Collapse) | Author | Lines |
|
|
|
Incorporate distance limit from `find_best_match_for_name` directly into
Levenshtein distance computation.
Use the string size difference as a lower bound on the distance and exit
early when it exceeds the specified limit.
After finding a candidate within a limit, lower the limit further to
restrict the search space.
|
|
This makes it more uniform with other expanded nodes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Add a suggestion if `macro_rules` is misspelled
Fixes #91227.
|
|
Also add a test case for inserting a semicolon on extern fns.
Without this fix, we got an error like this:
error: expected one of `->`, `where`, or `{`, found `}`
--> chk.rs:3:1
|
2 | fn foo()
| --- - expected one of `->`, `where`, or `{`
| |
| while parsing this `fn`
3 | }
| ^ unexpected token
Since this is inside an extern block, you're required to write function
prototypes with no body. This fixes a regression, and adds a test case
for it.
|
|
|
|
There's a few spots where semicolons are checked for to do error recovery,
and should not be suggested (or checked for other stuff).
Fixes #87647
|
|
|
|
And stop creating a fake `mod` item for the crate root when expanding a crate.
|
|
Fix #84946
|
|
TraitKind -> Trait
TyAliasKind -> TyAlias
ImplKind -> Impl
FnKind -> Fn
All `*Kind`s in AST are supposed to be enums.
Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order.
Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
|
|
Give better error for `macro_rules name`
follow up to #89221
r? ``@estebank``
``@rustbot`` modify labels: +A-diagnostics +A-parser
|
|
The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s.
|
|
|
|
|
|
Revert anon union parsing
Revert PR #84571 and #85515, which implemented anonymous union parsing in a manner that broke the context-sensitivity for the `union` keyword and thus broke stable Rust code.
Fix #88583.
|
|
|
|
|
|
This reverts commit 059b68dd677808e14e560802d235ad40beeba71e.
Note that this was manually adjusted to retain some of the refactoring
introduced by commit 059b68dd677808e14e560802d235ad40beeba71e, so that it could
likewise retain the correction introduced in commit
5b4bc05fa57be19bb5962f4b7c0f165e194e3151
|
|
|
|
|
|
Improve diagnostics for wrongly ordered keywords in function declaration
Fix #87217
`@rustbot` label A-diagnostics T-compiler
|
|
Fix a parser ICE on invalid `fn` body
Fixes #87635
A better fix would add a check for `fn` body on `expected_one_of_not_found` but I haven't come up with a graceful way. Any idea?
r? ```@oli-obk``` ```@estebank```
|
|
After this commit, `unsafe async fn ...` now suggests the `async unsafe` fix
instead of misunderstanding the issue.
This is not perfect for repeated keywords (`const async const`) and for
keywords that are misplaced after `extern "some abi"` because of the way
`check_fn_font_matter` works, but changing it breaks so many tests and
diagnostics it has been judged too high a cost for this PR.
|
|
|
|
|
|
|
|
|
|
|
|
Add unnamed_fields feature gate and gate unnamed fields on parsing
|
|
Parse unsupported "default field const values":
```rust
struct S {
field: Type = const_val,
}
```
Recover from small `:` typo and provide suggestion:
```rust
struct S {
field; Type,
field2= Type,
}
```
|
|
The name was misleading, it wasn't actually a fatal error.
|
|
|
|
|
|
This reverts commit e2561c58a41023a14e0e583113dcf55e1ecb236a, reversing
changes made to 2982ba50fc4bb629b8fe4108a81cb2f9b053510b.
|
|
|
|
This PR modifies the macro expansion infrastructure to handle attributes
in a fully token-based manner. As a result:
* Derives macros no longer lose spans when their input is modified
by eager cfg-expansion. This is accomplished by performing eager
cfg-expansion on the token stream that we pass to the derive
proc-macro
* Inner attributes now preserve spans in all cases, including when we
have multiple inner attributes in a row.
This is accomplished through the following changes:
* New structs `AttrAnnotatedTokenStream` and `AttrAnnotatedTokenTree` are introduced.
These are very similar to a normal `TokenTree`, but they also track
the position of attributes and attribute targets within the stream.
They are built when we collect tokens during parsing.
An `AttrAnnotatedTokenStream` is converted to a regular `TokenStream` when
we invoke a macro.
* Token capturing and `LazyTokenStream` are modified to work with
`AttrAnnotatedTokenStream`. A new `ReplaceRange` type is introduced, which
is created during the parsing of a nested AST node to make the 'outer'
AST node aware of the attributes and attribute target stored deeper in the token stream.
* When we need to perform eager cfg-expansion (either due to `#[derive]` or `#[cfg_eval]`),
we tokenize and reparse our target, capturing additional information about the locations of
`#[cfg]` and `#[cfg_attr]` attributes at any depth within the target.
This is a performance optimization, allowing us to perform less work
in the typical case where captured tokens never have eager cfg-expansion run.
|
|
Detect async visibility wrong order, `async pub`
Partially address #76437.
|
|
async-pub check created a regression for default
|
|
Redirects `const? async? unsafe? pub` to `pub const? async? unsafe?`.
Fix #76437
|
|
StructField -> FieldDef ("field definition")
Field -> ExprField ("expression field", not "field expression")
FieldPat -> PatField ("pattern field", not "field pattern")
Also rename visiting and other methods working on them.
|
|
|
|
AST: Remove some unnecessary boxes
|
|
Support `pub` on `macro_rules`
This rebases and updates `since` version of #78166 from ``@petrochenkov``
r? ``@nikomatsakis``
|