Rollup of 17 pull requests - #163043
Open
mu001999 wants to merge 41 commits into
Open
Rollup of 17 pull requests#163043mu001999 wants to merge 41 commits into
mu001999 wants to merge 41 commits into
Conversation
rust-analyzer has a query for this, so we want to use it there. I don't know if using a query for this will be a perf win for rustc, but rust-analyzer already has this query for other reasons, so it feels a waste to not use it.
…or the long removed type ascription
Previously we would trigger on
1. `unsafe { 1, 2, 3 }` and suggest `[ { 1, 2, 3 ]` (sic!)
2. `'label: { 1, 2, 3 }` and suggest `[: { 1, 2, 3 ]` (sic!)
3. `X::<{ 1, 2, 3 }>` and suggest `X::<[ 1, 2, 3]>` (wrong)
4. `|| -> i32 { 1, 2, 3 }` and suggest `|| -> i32 [ 1, 2, 3 ]` (wrong)
5. `await { 1, 2, 3 }` and suggest `await [ 1, 2, 3 ]` (wrong)
Moreover, stop looking for identifiers after the `{` as that case can no
longer be reached anyway as `maybe_recover_bad_struct_literal_path`
will always snatch it first.
When in a method trying to access `Self` on its own, suggest `self`.
When in any assoc fn trying to access `Self()`, suggest `Self { fields }` or using an enum variant. When enum has no variants, mention it.
``` error[E0061]: this method takes 0 arguments but 1 argument was supplied --> $DIR/shadowed-intrinsic-method.rs:18:7 | LL | a.borrow(()); | ^^^^^^ -- unexpected argument of type `()` | note: the `borrow` call is resolved to the method in `std::borrow::Borrow`, shadowing the method of the same name on the inherent impl for `A` --> $DIR/shadowed-intrinsic-method.rs:18:7 | LL | use std::borrow::Borrow; | ------------------- `std::borrow::Borrow` imported here ... LL | a.borrow(()); | ^^^^^^ refers to `std::borrow::Borrow::borrow` note: method defined here --> $SRC_DIR/core/src/borrow.rs:LL:COL help: you might have meant to call the other method; you can use the fully-qualified path to call it explicitly | LL - a.borrow(()); LL + A::borrow(&mut a, ()); | help: remove the extra argument | LL - a.borrow(()); LL + a.borrow(); | ``` Account for inherent methods Tweak wording on "other methods available" note Handle correct gramar in the face of a single other option, or many.
…ified path on ambiguous assoc item
Use ModId more for visibility checks from TypeckRootCtxt. This just simplifies things a bit and adds consistency.
We generally expect Visibility to have ModId or LocalModId, so it seems good to restrict the impls as such. There is just one error path needing adjustment to check that we actually have a ModId. It should be okay since, if it is not a module, an error will be emitted elsewhere.
Especially in adjust_ident_and_get_scope and is_accessible_from.
…leExt * First pass at windows::fs::FileExt.seek_read_exact() * First pass at windows::fs::FileExt.seek_write_all() * Fix function signature in seek_read_exact(), duh * First pass at tests for .seek_read_exact(), seek_write_all() * Whitespace fix * Use hypothetical seek_read_exact_seek_write_all feature also for .seek_read_exact() * Tracking issues 162868 * Oops, fix seek_write_all() doc example, was using write_all_at() still * Add mocked test for windows FileExt trait * Spelling fixes * Expand test for windows FileExt trait to include almost all scenarios * Split three tests out of file_test_windows_fileext_trait() * Remove old versions of those 3 tests * Split remaining file_test_windows_fileext_trait() into case 4, 5 * More test cleanup, always test expected_offset where possible * Test read first for consistency * Use same doctsring examples as seek_read(), seek_write() * Missing period * Oops: actually call _exact(), _all() methods in case 2, 3 * Add missing seek_read_exact_seek_write_all feature flags in doc examples
…limiter, r=jackh726 Make let-else respect macro_rules expr metavariable grouping Fixes rust-lang#147899
Better account for `Self` that might be a typo of `self`
When in a method trying to access `Self` on its own, suggest `self`. When in any assoc fn trying to access `Self()`, suggest `Self { fields }` or using an enum variant. When enum has no variants, mention it.
Fix rust-lang#91525.
…op, r=jackh726 fix const_item_mutation lint to use needs_drop instead of has_dtor Description: The const_item_mutation lint was only checking if the outer type has a direct Drop impl (has_dtor). But if a field inside the type has a Drop impl, that drop logic can also observe the mutation — so the warning should be suppressed in that case too. This fixes a false positive where the lint would warn on code like: ```O.inner.val = 42;``` even when Inner has a Drop impl that prints the value — meaning the mutation IS observable and the warning is wrong. Fix: replace has_dtor check with needs_drop, which checks the whole type including all fields inside it.
… r=jackh726 Provide a `supertrait_def_ids()` function in rustc_type_ir's interner rust-analyzer has a query for this, so we want to use it there. I don't know if using a query for this will be a perf win for rustc, but rust-analyzer already has this query for other reasons, so it feels a waste to not use it. r? types
…-145558, r=jackh726 Do not suppress the fn item uniqueness note for late bound lifetimes Fixes rust-lang#145558 `same_type_modulo_infer` compared the bound regions by identity, so the note was suppressed for late bound lifetimes and anonymizing the binders fixes it.
post GH comment on types nominations This feature is cool, we want it for types nominations, as seen in https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/a.20.23zulip-stream.20topic.20was.20opened.20to.20discuss.20this.20issue r? @Mark-Simulacrum
…ath, r=davidtwco Suggest fully qualified path on method name collision Provide suggestion for using a fully qualified path when method names collide between traits and inherent impl. ``` error[E0061]: this method takes 0 arguments but 1 argument was supplied --> $DIR/shadowed-intrinsic-method.rs:20:7 | LL | a.borrow(()); | ^^^^^^ -- unexpected argument of type `()` | note: the `borrow` call is resolved to the method in `std::borrow::Borrow`, shadowing the method of the same name on the inherent impl for `A` --> $DIR/shadowed-intrinsic-method.rs:20:7 | LL | use std::borrow::Borrow; | ------------------- `std::borrow::Borrow` imported here ... LL | a.borrow(()); | ^^^^^^ refers to `std::borrow::Borrow::borrow` note: method defined here --> $SRC_DIR/core/src/borrow.rs:LL:COL help: you might have meant to call the other method; you can use the fully-qualified path to call it explicitly | LL - a.borrow(()); LL + A::borrow(&mut a, ()); | help: remove the extra argument | LL - a.borrow(()); LL + a.borrow(); | ``` Fix rust-lang#54103.
add safety section for mem::zeroed This pull request adds Safety section for `mem::zeroed`.
Prefer ModId in more places Simplifying code a bit and adding consistency. Generally prefer passing around `ModId` instead of a more specific ID when a `ModId` will do.
…dead Remove incorrect parse error recovery code that mistakes `as` casts for the long removed type ascription Back when we still had type ascription syntax `$expr : $ty`, `parse_assoc_op_cast` would parse both `as` casts & type ascription. During that time (namely in commit rust-lang@8c5dafd), parse error recovery from code like `label: loop {}` was added (label lacks leading apostrophe). However, it never checked if we did actually parse a `:` and not an `as` meaning *to this day* we emit a nonsensical diagnostic for expressions like `label as loop {}`! This PR does away with this code & further cleans up in the area (thanks to type ascription being gone). In case you're wondering, we do still recover from expr *stmts* like `label: loop {}` as we have some code in the stmt parser for this. Since the removal of the type ascription syntax we do indeed no longer provide that recovery for arbitrary exprs (e.g, `(label: loop {})`) which I find absolutely acceptable. <sub>(No LLM was or will be used by me during the entire creation process of this PR)</sub>
…nBrouwer
Trigger "C array" parse error recovery in far fewer cases
Previously we would trigger on
1. `unsafe { 1, 2, 3 }` and suggest `[ { 1, 2, 3 ]` (sic!)
2. `'label: { 1, 2, 3 }` and suggest `[: { 1, 2, 3 ]` (sic!)
3. `X::<{ 1, 2, 3 }>` and suggest `X::<[ 1, 2, 3]>` (wrong)
4. `|| -> i32 { 1, 2, 3 }` and suggest `|| -> i32 [ 1, 2, 3 ]` (wrong)
5. `await { 1, 2, 3 }` and suggest `await [ 1, 2, 3 ]` (wrong)
Moreover, stop looking for identifiers after the `{` as that case can no longer be reached anyway as `maybe_recover_bad_struct_literal_path` will always snatch it first.
I haven't added any regression tests as I don't think it'd be worth it / proportionate (it's a niche parse error recovery gone awry in very odd cases). Let me know if you think otherwise.
<sub>(No LLM was or will be used by me during the entire creation process of this PR)</sub>
…they Add .seek_read_exact(), .seek_write_all() to std::os::windows::fs::FileExt Tracking issue: rust-lang#162868 This adds `.seek_read_exact()` to `std::os::windows::fs::FileExt`, an exact port of `read_exact_at()` for `std::os::unix::fs::FileExt`. And it adds `.seek_write_all()` to `std::os::windows::fs::FileExt`, an exact port of `write_all_at()` for `std::os::unix::fs::FileExt`. Finally, it adds six tests. First there is a smoke test for `seek_read_exact()`, `seek_write_all()`, an exact port of the test for the `.seek_read()`, `.seek_write()` methods. This is to make sure we are getting the same pass-through behavior through the lens of established tests. Then there are five tests for the `windows::fs::FileExt` trait itself, covering all `seek_read_exact()`, `seek_write_all()` corner cases except `io::ErrorKind::Interrupted` (advise welcome on that one). These tests use mock implementations of the traits `seek_read()` and `seek_write()` methods. No LLMs were used in writing this PR.
…chenyukang recover `true` and `false` in type position as `bool` Fixes rust-lang#162947 I asked for a bit of help in [#t-compiler/help > parser help with issue 162947](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/parser.20help.20with.20issue.20162947/with/625278094) and was advised to this solution. This doesn't help if another keyword instead of `true` or `false` is used in type position, but i assume this is rare (don't think it has ever happened to me). I also think this could lead to confusing error messages if the user has a type called `True` or `False`. When this then is typoed as lowercase it would be made to a bool. I assume this is also rare. No AI used.
…, r=jhpratt Constify `impl FromStr for NonZero<T>` `<integer>::from_str` has been `const`. `NonZero::from_str` can also be `const`. rust-lang#143773
…e, r=folkertdev
Use `end_point` for trailing brace in `let...else` diagnostics
The following ICEs because `}` is a fullwidth lookalike of `}`:
```rs
fn main() {
let x = {1} else { return; };
}
```
The diagnostic for a trailing curly brace before else in a let...else statement computed the brace span with `span.hi() - BytePos(1)`. That assumes the brace is a single ASCII byte.
add Dir::try_clone There's no `try_clone` listed on rust-lang#120426 but I assume that's a standard operation for all kinds of file descriptors? Cc @the8472 @ChrisDenton
Use verbose suggestion for parenthetical `Fn` notation and fully-qualified path on ambiguous assoc item Tweak two hir analysis diagnostics to use verbose suggestions. CC rust-lang#141973
Member
Author
|
@bors r+ p=5 |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Successful merges:
Selfthat might be a typo ofself#160028 (Better account forSelfthat might be a typo ofself)supertrait_def_ids()function in rustc_type_ir's interner #161435 (Provide asupertrait_def_ids()function in rustc_type_ir's interner)ascasts for the long removed type ascription #162700 ( Remove incorrect parse error recovery code that mistakesascasts for the long removed type ascription)trueandfalsein type position asbool#162988 (recovertrueandfalsein type position asbool)impl FromStr for NonZero<T>#162995 (Constifyimpl FromStr for NonZero<T>)end_pointfor trailing brace inlet...elsediagnostics #163006 (Useend_pointfor trailing brace inlet...elsediagnostics)Fnnotation and fully-qualified path on ambiguous assoc item #163039 (Use verbose suggestion for parentheticalFnnotation and fully-qualified path on ambiguous assoc item)r? @ghost
Create a similar rollup