| Age | Commit message (Collapse) | Author | Lines |
|
Pass struct field HirId when check_expr_struct_fields
Fixes #138319
r? compiler
cc ``@Mark-Simulacrum``
|
|
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
|
|
The place previously used here was that of the temporary holding the
reference returned by `Deref::deref` or `DerefMut::deref_mut`. However,
since the inner pattern of `deref!(inner)` expects the deref-target type
itself, this would ICE when that type was inspected (e.g. by the EUV
case for slice patterns). This adds a deref projection to fix that.
Since current in-tree consumers of EUV (upvar inference and clippy)
don't care about Rvalues, the place could be simplified to
`self.cat_rvalue(pat.hir_id, self.pat_ty_adjusted(subpat)?)` to save
some cycles. I personally find EUV to be a bit fragile, so I've opted
for pedantic correctness. Maybe a `HACK` comment would suffice though?
|
|
|
|
```
error[E0614]: type `(..., ..., ..., ...)` cannot be dereferenced
--> $DIR/long-E0614.rs:10:5
|
LL | *x;
| ^^ can't be dereferenced
|
= note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt'
= note: consider using `--verbose` to print the full type name to the console
```
|
|
|
|
|
|
Rollup of 9 pull requests
Successful merges:
- #135296 (interpret: adjust vtable validity check for higher-ranked types)
- #137106 (Add customized compare for Link in rustdoc)
- #137253 (Restrict `bevy_ecs` `ParamSet` hack)
- #137262 (Make fewer crates depend on `rustc_ast_ir`)
- #137263 (Register `USAGE_OF_TYPE_IR_INHERENT`, remove inherent usages)
- #137266 (MIR visitor tweaks)
- #137269 (Pattern Migration 2024: properly label `&` patterns whose subpatterns are from macro expansions)
- #137277 (stabilize `inherent_str_constructors`)
- #137281 (Tweak "expected ident" parse error to avoid talking about doc comments)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
|
|
|
|
My reasoning: the ruleset implemented by the same feature gate in
Edition 2024 always tries to eat the inherited reference first. For
consistency, it makes sense to me to say across all editions that users
should consider the inherited reference's mutability when wondering if a
`&mut` pattern will type.
|
|
|
|
|
|
deref rules
|
|
These are superseded by the old-edition revisions on the shared tests.
|
|
This also adds `#[cfg]` attributes to tests for bindings' types,
to make it visually clearer which revisions type successfully.
|
|
r=Nadrieril
Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions
See the diff between the two commits for how this affected the error message and suggestion. In order to decide how to format those, the pattern migration diagnostic keeps track of which parts of the user's pattern cause problems in Edition 2024. However, it neglected to do some of this bookkeeping when pointing to macro expansion sites. This fixes that.
|
|
|
|
|
|
For consistency with `recursion_limit`, `move_size_limit`, and
`type_length_limit`.
|
|
|
|
|
|
|
|
```
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
--> $DIR/attempted-access-non-fatal.rs:7:15
|
LL | let _ = 2.l;
| ^
|
help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix
|
LL - let _ = 2.l;
LL + let _ = 2.0f64;
|
```
|
|
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
|
|
r=Nadrieril
Pattern Migration 2024: try to suggest eliding redundant binding modifiers
This is based on #136475. Only the last commit is new.
This is a simpler, more restrictive alternative to #136496, meant to partially address #136047. If a pattern can be migrated to Rust 2024 solely by removing redundant binding modifiers, this will make that suggestion; otherwise, it uses the old suggestion of making the pattern fully explicit.
Relevant tracking issue: #131414
``@rustbot`` label A-diagnostics A-patterns A-edition-2024
r? ``@Nadrieril``
|
|
Most of these are meant to test possible future improvements, but since
they cover cases the existing test suite didn't, I figure including them
now may be helpful.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mode
|
|
|
|
|
|
This aligns the main error message a bit more with the phrasing in the
Edition Guide and provides a bit more information on the labels to
(hopefully!) aid in understanding.
|
|
Match Ergonomics 2024: update edition 2024 behavior of feature gates
This updates the edition 2024 behavior of the feature gates `ref_pat_eat_one_layer_2024_structural` and `ref_pat_eat_one_layer_2024` to correspond to the left and right typing rules compared [here](https://nadrieril.github.io/typing-rust-patterns/?compare=true&opts2=AQEBAAABAQABAgIAAQEBAAEBAAABAAA%3D&opts1=AQEBAgEBAQEBAgIAAAAAAAAAAAAAAAA%3D&mode=rules&do_cmp=true&ty_d=3&style=SequentBindingMode), respectively. I'll implement the proposed new behavior for editions ≤ 2021 in another PR.
The tests are split up a bit awkwardly for practical reasons, but I've added new tests from 3 places:
- I got tests for where the typing rules differ from the "Compare" tab of the page linked above. These had to be split up based on where the errors are emitted and how rustfixable they are, so they've ended up in different files to keep tidy. Within each file, though, the order of the tests matches the order the typing differences appear in that comparison (as of when this was written).
- I used [this other comparison](https://nadrieril.github.io/typing-rust-patterns/?q=%5B%26mut+%26%28mut+x%29%5D%3A+%26mut+%5B%26CT%5D&compare=true&opts2=AQEBAgABAQEBAgIAAQEBAAEBAAABAAA%3D&opts1=AQEBAgEBAQEBAgIAAAAAAAAAAAAAAAA%3D&mode=compare&do_cmp=true&ty_d=3&style=SequentBindingMode) to test the `Deref(EatInner, FallbackToOuter)` rule of the left/"structural"/eat-inner ruleset. These are all in `well-typed-edition-2024.rs`.
- I added some select tests for cases where the new typing rules differ from current stable Rust. I had to be pickier about what I included here, but I tried to make sure each typing rule got some coverage. That said, my approach for these tests was a bit ad-hoc, so I may have missed something.
Relevant tracking issue: #123076
r? ````@ghost````
|
|
|
|
|
|
|
|
Since there are so many ways to write these, I've opted to only include
two sorts of test: simple tests that directly target the rules differing
between rulesets and nuanced tests that produce different errors under
different rulesets. I've also tried not to add any duplicate tests.
`well-typed-edition-2024.rs` already has tests disagreeing with stable,
so I've opted not to include any in this commit that are well-typed
under the new rules.
|
|
This doesn't (or at least shouldn't!) add, remove, or change any test
cases. I've grouped them by which rule variants they test.
|
|
This serves two purposes.
First, they're additional tests that stable Rust behavior hasn't been
messed with. There's plenty of other pattern tests, so this is less
important, but these at least are targeted at what's being changed.
Second, this helps document exactly where the new rulesets agree and
disagree with stable pattern typing. This will be especially important
after the new rules for old editions are updated, since they need to be
strictly more permissive; any patterns well-typed on stable should also
be well-typed with the same resultant bindings on the (upcoming) new new
old-edition rules.
The unusual test ordering on `borrowck-errors.rs` and
`ref-binding-on-inh-ref-errors.rs` are to hopefully reduce how much
adding new tests will mess with line numbers in their stderr.
|
|
|
|
- Removes some excess parens
- Removes 3 duplicated tests
|
|
|
|
pattern doesn't match the mutability of an inner reference
This is the `Deref(EatInner, FallbackToOuter)` rule in Typing Rust Patterns.
|
|
for inherited ref mutability mismatches
I think the diagnostic could use some work, but it's more helpful than
the alternative. The previous error was misleading, since it ignored the
inherited reference altogether.
|