| Age | Commit message (Collapse) | Author | Lines |
|
r=compiler-errors
use correct edition when warning for unsafe attributes
fixes https://github.com/rust-lang/rust/issues/142182
If an attribute is re-emitted by a macro, the incorrect edition was used to emit warnings for unsafe attributes.
This logic was introduced in https://github.com/rust-lang/rust/pull/139718
cc `@compiler-errors` `@ehuss`
|
|
|
|
If an attribute is re-emitted by a macro, the incorrect edition was used to emit warnings for unsafe attributes
|
|
|
|
Reduce `ast::ptr::P` to a typedef of `Box`
As per the MCP at https://github.com/rust-lang/compiler-team/issues/878.
r? `@fee1-dead`
|
|
This solve a stack overflow found on Fedora s390x when building
`tests/ui/associated-consts/issue-93775.rs`.
|
|
Fix incorrect eq_unspanned in TokenStream
Fixes rust-lang/rust#141522
r? ``@workingjubilee``
should we remove this function?
since it's used in several places, i'd prefer to keep it.
|
|
Remove `Path::is_ident`.
It checks that a path has a single segment that matches the given symbol, and that there are zero generic arguments. It has a single use.
We also have `impl PartialEq<Symbol> for Path` which does exactly the same thing *except* it doesn't check for zero generic arguments, which seems like an oversight. It has numerous uses.
This commit removes `Path::is_ident`, adds a test for zero generic arguments to `PartialEq<Symbol> for Path`, and changes the single use of `is_ident` to instead use `==`.
r? `@wesleywiser`
|
|
This adds an `iter!` macro that can be used to create movable
generators.
This also adds a yield_expr feature so the `yield` keyword can be used
within iter! macro bodies. This was needed because several unstable
features each need `yield` expressions, so this allows us to stabilize
them separately from any individual feature.
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
Co-authored-by: Travis Cross <tc@traviscross.com>
|
|
It checks that a path has a single segment that matches the given
symbol, and that there are zero generic arguments. It has a single use.
We also have `impl PartialEq<Symbol> for Path` which does exactly the
same thing *except* it doesn't check for zero generic arguments, which
seems like an oversight. It has numerous uses.
This commit removes `Path::is_ident`, adds a test for zero generic
arguments to `PartialEq<Symbol> for Path`, and changes the single use of
`is_ident` to instead use `==`.
|
|
Fix the issue of typo of comma in arm parsing
Fixes #140991
I also checked is it a '/', since it's near from ',' from keyboard.
|
|
Report text_direction_codepoint_in_literal when parsing
The lint is now reported in code that gets removed/modified/duplicated by macro expansion, and spans are more accurate so we don't get ICEs from trying to split a span in the middle of a character.
This removes support for lint level attributes for `text_direction_codepoint_in_literal` except at the crate level, I don't think that there's an easy way around this when the lint can be reported on code that's removed by `cfg` or that is only in the input of a macro.
Fixes #140281
|
|
Reorder `ast::ItemKind::{Struct,Enum,Union}` fields.
So they match the order of the parts in the source code, e.g.:
```
struct Foo<T, U> { t: T, u: U }
<-><----> <------------>
/ | \
ident generics variant_data
```
r? `@fee1-dead`
|
|
r=nnethercote
Fix ICE in tokenstream with contracts from parser recovery
Fixes rust-lang/rust#140683
After two times of parsing error, the `recover_stmt_` constructs an error ast, then when we expand macors, the invalid tokenstream triggered ICE because of mismatched delims.
Expected `{` and get other tokens is an obvious error message, too much effort on recovery may introduce noise.
r? ```@nnethercote```
|
|
So they match the order of the parts in the source code, e.g.:
```
struct Foo<T, U> { t: T, u: U }
<-><----> <------------>
/ | \
ident generics variant_data
```
|
|
|
|
- The lint is now reported in code that gets removed/modified/duplicated
by macro expansion.
- Spans are more accurate
- Fixes #140281
|
|
|
|
Keep the `P` constructor function for now, to minimize immediate churn.
All the `into_inner` calls are removed, which is nice.
|
|
A `Vec` is fine, the additional word (vector vs. boxed slice) doesn't
matter here.
|
|
|
|
|
|
Improve ternary operator recovery
This
- Improves the span of the error to not point at the next token
- Where possible, we use the span of the condition to further improve the span of the error to include the cond, and suggest a maybe-incorrect fix
Currently this works on free expressions, not let statements; some more refactoring would be needed to pass the span down, which I'm not sure is worth doing.
### Old

### New

|
|
|
|
|
|
|
|
All uses have been removed. And it's nonsensical: an identifier by
definition has at least one char.
The commits adds an is-non-empty assertion to `Ident::new` to enforce
this, and converts some `Ident` constructions to use `Ident::new`.
Adding the assertion requires making `Ident::new` and
`Ident::with_dummy_span` non-const, which is no great loss.
The commit amends a couple of places that do path splitting to ensure no
empty identifiers are created.
|
|
Parser: Recover error from named params while parse_path
Fixes #140169
I added test to the first commit and the second added the code and changes to test.
r? `@petrochenkov`
|
|
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
|
|
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.
|
|
Supercedes #137193
|
|
|
|
|
|
Parser: Document restrictions
I had trouble easily understanding what these various flags do. This is my attempt to try to explain what these do.
|
|
It's no longer necessary after the removal of nonterminal tokens in #124141.
|
|
I had trouble easily understanding what these various flags do. This is
my attempt to try to explain what these do.
|
|
|
|
This commit does the following.
- Changes it from `Lrc<Box<dyn ToAttrTokenStream>>` to
`Lrc<LazyAttrTokenStreamInner>`.
- Reworks `LazyAttrTokenStreamImpl` as `LazyAttrTokenStreamInner`, which
is a two-variant enum.
- Removes the `ToAttrTokenStream` trait and the two impls of it.
The recursion limit must be increased in some crates otherwise rustdoc
aborts.
|
|
Specifically: `TokenCursor`, `TokenTreeCursor`,
`LazyAttrTokenStreamImpl`, `FlatToken`, `make_attr_token_stream`,
`ParserRange`, `NodeRange`. `ParserReplacement`, and `NodeReplacement`.
These are all related to token streams, rather than actual parsing.
This will facilitate the simplifications in the next commit.
|
|
Improve error message for `||` (or) in let chains
**Description**
This PR improves the error message when using `||` in an if let chain expression, addressing #140263.
**Changes**
1. Creates a dedicated error message specifically for `||` usage in let chains
2. Points the primary span directly at the `||` operator
3. Removes confusing secondary notes about "let statements" and unsupported contexts
5. Adds UI tests verifying the new error message and valid cases
**Before**
```rust
error: expected expression, found let statement
--> src/main.rs:2:8
|
2 | if let true = true || false {}
| ^^^^^^^^^^^^^^^
|
= note: only supported directly in conditions of if and while expressions
note: || operators are not supported in let chain expressions
--> src/main.rs:2:24
|
2 | if let true = true || false {}
|
```
**After**
```rust
error: `||` operators are not supported in let chain conditions
--> src/main.rs:2:24
|
2 | if let true = true || false {}
| ^^
```
**Implementation details**
1. Added new `OrInLetChain` diagnostic in errors.rs
2. Modified `CondChecker` in expr.rs to prioritize the `||` error
3. Updated fluent message definitions to use clearer wording
**Related issue**
Fixes #140263
cc ```@ehuss``` (issue author)
|
|
|
|
Make #![feature(let_chains)] bootstrap conditional in compiler/
Let chains have been stabilized recently in #132833, so we can remove the gating from our uses in the compiler (as the compiler uses edition 2024).
|
|
Revert overzealous parse recovery for single colons in paths
Basically manually reverts #136808, cc ``@chenyukang`` ``@estebank.``
Reopens #129273.
Fixes [after beta backport] #140227.
|
|
|
|
Rollup of 7 pull requests
Successful merges:
- #140142 (Some more graphviz tweaks)
- #140146 (Update `compiler_builtins` to 0.1.156)
- #140147 (Clean: rename `open_braces` to `open_delimiters` in lexer and move `make_unclosed_delims_error` into `diagnostics.rs`.)
- #140160 (Use `is_lang_item` and `as_lang_item` instead of handrolling their logic)
- #140163 (Validate extension in `PathBuf::add_extension`)
- #140173 (Ping Mara when touching format_args!() internals.)
- #140175 (`rc""` more clear error message)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
|
|
`rc""` more clear error message
here is small fix that provides better error message when user is trying to use `rc""` the same way it was made for `rb""`
example of it's work
```rust
|
2 | rc"\n";
| ^^ unknown prefix
|
= note: prefixed identifiers and literals are reserved since Rust 2021
help: use `cr` for a raw C-string
|
2 - rc"\n";
2 + cr"\n";
|
```
**related issue**
fixes #140170
cc `@cyrgani` (issue author)
|
|
Clean: rename `open_braces` to `open_delimiters` in lexer and move `make_unclosed_delims_error` into `diagnostics.rs`.
Clean code prepared for resolving #138401. To avoid having too many extraneous changes in one PR, I cleaned up some of the naming and method placement in lexer in this PR.
1. For the make_unclosed_delims_error function defined in mod.rs is only used in lexer, so moved into lexer, which enhances encapsulation.
2. For open_braces in TokenTreeDiagInfo the naming is not canonical, as Brace refers to `{...} ` and this variable can store all kinds of different Delimiters. so I named it open_delimiters.
r? `@chenyukang`
|
|
|
|
Handle another negated literal in `eat_token_lit`.
Extends the change from #139653, which was on expressions, to literals.
Fixes #140098.
r? ``@petrochenkov``
|