about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2024-07-18Rollup merge of #127886 - estebank:as-rename-suggestion, r=compiler-errorsMatthias Krüger-8/+10
Accurate `use` rename suggestion span When suggesting to rename an import with `as`, use a smaller span to render the suggestion with a better format: ``` error[E0252]: the name `baz` is defined multiple times --> $DIR/issue-25396.rs:4:5 | LL | use foo::baz; | -------- previous import of the module `baz` here LL | use bar::baz; | ^^^^^^^^ `baz` reimported here | = note: `baz` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | LL | use bar::baz as other_baz; | ++++++++++++ ```
2024-07-18Accurate `use` rename suggestion spanEsteban Küber-8/+10
When suggesting to rename an import with `as`, use a smaller span to render the suggestion with a better format: ``` error[E0252]: the name `baz` is defined multiple times --> $DIR/issue-25396.rs:4:5 | LL | use foo::baz; | -------- previous import of the module `baz` here LL | use bar::baz; | ^^^^^^^^ `baz` reimported here | = note: `baz` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | LL | use bar::baz as other_baz; | ++++++++++++ ```
2024-07-16Add `ConstArgKind::Path` and make `ConstArg` its own HIR nodeNoah Lev-2/+13
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-16Update method name to reflect changes to its internalsOli Scherer-3/+3
2024-07-12Rollup merge of #127310 - chenyukang:yukang-fix-suggest-import-ice, r=estebankJubilee-5/+5
Fix import suggestion ice Fixes #127302 #127302 only crash in edition 2015 #120074 can only reproduced in edition 2021 so I added revisions in test file.
2024-07-12When finding item gated behind a `cfg` flat, point at itEsteban Küber-1/+16
Previously we would only mention that the item was gated out, and opportunisitically mention the feature flag name when possible. We now point to the place where the item was gated, which can be behind layers of macro indirection, or in different modules. ``` error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` --> $DIR/diagnostics-cross-crate.rs:18:23 | LL | cfged_out::inner::doesnt_exist::hello(); | ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner` | note: found an item that was configured out --> $DIR/auxiliary/cfged_out.rs:6:13 | LL | pub mod doesnt_exist { | ^^^^^^^^^^^^ note: the item is gated here --> $DIR/auxiliary/cfged_out.rs:5:5 | LL | #[cfg(FALSE)] | ^^^^^^^^^^^^^ ```
2024-07-12Auto merge of #127382 - estebank:const-let, r=compiler-errorsbors-25/+55
Use verbose style when suggesting changing `const` with `let`
2024-07-11Account for `let foo = expr`; to suggest `const foo: Ty = expr;`Esteban Küber-22/+51
2024-07-11Use verbose style when suggesting changing `const` with `let`Esteban Küber-4/+5
2024-07-10Fix diagnostic and add a test for itMichael Goulet-1/+1
2024-07-08Rollup merge of #127431 - oli-obk:feed_item_attrs, r=compiler-errors许杰友 Jieyou Xu (Joe)-37/+41
Use field ident spans directly instead of the full field span in diagnostics on local fields This improves diagnostics and avoids having to store the `DefId`s of fields
2024-07-07Rollup merge of #127308 - nnethercote:Attribute-cleanups, r=petrochenkovMatthias Krüger-1/+1
Attribute cleanups More refactoring done while trying to fix the final remaining test failure for #124141. r? `@petrochenkov`
2024-07-07Remove `HasSpan` trait.Nicholas Nethercote-1/+1
The only place it is meaningfully used is in a panic message in `TokenStream::from_ast`. But `node.span()` doesn't need to be printed because `node` is also printed and it must contain the span.
2024-07-06Use field ident spans directly instead of the full field span in diagnostics ↵Oli Scherer-37/+41
on local fields
2024-07-06out_of_scope_macro_calls: Detect calls inside attributes more preciselyVadim Petrochenkov-12/+25
2024-07-04Fix import suggestion iceyukang-5/+5
2024-07-04Auto merge of #127127 - notriddle:notriddle/pulldown-cmark-0.11, ↵bors-5/+9
r=GuillaumeGomez rustdoc: update to pulldown-cmark 0.11 r? rustdoc This pull request updates rustdoc to the latest version of pulldown-cmark. Along with adding new markdown extensions (which this PR doesn't enable), the new pulldown-cmark version also fixes a large number of bugs. Because all text files successfully parse as markdown, these bugfixes change the output, which can break people's existing docs. A crater run, https://github.com/rust-lang/rust/pull/121659, has already been run for this change. The first commit upgrades and fixes rustdoc. The second commit adds a lint for the footnote and block quote parser changes, which break the largest numbers of docs in the Crater run. The strikethrough change was mitigated in pulldown-cmark itself. Unblocks https://github.com/rust-lang/rust-clippy/pull/12876
2024-07-03Rollup merge of #127092 - compiler-errors:rtn-dots-redux, r=estebankMatthias Krüger-0/+2
Change return-type-notation to use `(..)` Aligns the syntax with the current wording of [RFC 3654](https://github.com/rust-lang/rfcs/pull/3654). Also implements rustfmt support (along with making a match exhaustive). Tracking: * https://github.com/rust-lang/rust/issues/109417
2024-07-01Fix import suggestion error when failed not from startingyukang-1/+11
2024-06-30rustdoc: update to pulldown-cmark 0.11Michael Howell-5/+9
2024-06-28Change RTN to use .. againMichael Goulet-0/+2
2024-06-27Tighten spans for async blocksMichael Goulet-1/+1
2024-06-25resolve: Tweak some naming around import ambiguitiesVadim Petrochenkov-50/+42
2024-06-25Auto merge of #125741 - petrochenkov:atvisord, r=davidtwcobors-12/+87
ast: Standardize visiting order for attributes and node IDs This should only affect `macro_rules` scopes and order of diagnostics. Also add a deprecation lint for `macro_rules` called outside of their scope, like in https://github.com/rust-lang/rust/issues/124535.
2024-06-24resolve: Implement a lint for out-of-scope use of `macro_rules`Vadim Petrochenkov-12/+87
2024-06-24Rollup merge of #125241 - Veykril:tool-rust-analyzer, r=davidtwcoMatthias Krüger-3/+4
Add `rust_analyzer` as a predefined tool Given all the other rust-lang tools have it, I'd expect r-a to have it too. (we have a few ideas for using this https://github.com/rust-lang/rust-analyzer/issues/11556).
2024-06-21Add `rust_analyzer` as a predefined toolLukas Wirth-3/+4
2024-06-21Rollup merge of #126767 - compiler-errors:static-foreign-item, r=spastorinoMatthias Krüger-6/+1
`StaticForeignItem` and `StaticItem` are the same The struct `StaticItem` and `StaticForeignItem` are the same, so remove `StaticForeignItem`. Having them be separate is unique to `static` items -- unlike `ForeignItemKind::{Fn,TyAlias}`, which use the normal AST item. r? ``@spastorino`` or ``@oli-obk``
2024-06-20StaticForeignItem and StaticItem are the sameMichael Goulet-6/+1
2024-06-20collect attrs in const block exprbohan-0/+3
2024-06-19Rollup merge of #124135 - petrochenkov:deleglob, r=fmease许杰友 Jieyou Xu (Joe)-32/+172
delegation: Implement glob delegation Support delegating to all trait methods in one go. Overriding globs with explicit definitions is also supported. The implementation is generally based on the design from https://github.com/rust-lang/rfcs/pull/3530#issuecomment-2020869823, but unlike with list delegation in https://github.com/rust-lang/rust/pull/123413 we cannot expand glob delegation eagerly. We have to enqueue it into the queue of unexpanded macros (most other macros are processed this way too), and then a glob delegation waits in that queue until its trait path is resolved, and enough code expands to generate the identifier list produced from the glob. Glob delegation is only allowed in impls, and can only point to traits. Supporting it in other places gives very little practical benefit, but significantly raises the implementation complexity. Part of https://github.com/rust-lang/rust/issues/118212.
2024-06-18Remove redundant argument from `subdiagnostic` methodOli Scherer-58/+42
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-2/+2
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-17Rework precise capturing syntaxMichael Goulet-3/+3
2024-06-17Rollup merge of #126568 - bvanjoi:fix-126376, r=petrochenkovMatthias Krüger-9/+16
mark undetermined if target binding in current ns is not got Fixes #126376 Fixes #126389 Add a branch to handle more cases... r? `@petrochenkov`
2024-06-17Rollup merge of #125258 - compiler-errors:static-if-no-lt, r=nnethercote许杰友 Jieyou Xu (Joe)-53/+89
Resolve elided lifetimes in assoc const to static if no other lifetimes are in scope Implements the change to elided lifetime resolution in *associated consts* subject to FCP here: https://github.com/rust-lang/rust/issues/125190#issue-2301532282 Specifically, walk the enclosing lifetime ribs in an associated const, and if we find no other lifetimes, then resolve to `'static`. Also make it work for traits, but don't lint -- just give a hard error in that case.
2024-06-17mark undetermined if target binding in current ns is not gotbohan-9/+16
2024-06-15delegation: Fix hygiene for `self`Vadim Petrochenkov-20/+28
And fix diagnostics for `self` from a macro.
2024-06-14delegation: Implement glob delegationVadim Petrochenkov-43/+185
2024-06-14Resolve const lifetimes to static in trait tooMichael Goulet-22/+34
2024-06-14Resolve elided lifetimes in assoc const to static if no other lifetimes are ↵Michael Goulet-40/+64
in scope
2024-06-13Tweak output of import suggestionsEsteban Küber-7/+39
When both `std::` and `core::` items are available, only suggest the `std::` ones. We ensure that in `no_std` crates we suggest `core::` items. Ensure that the list of items suggested to be imported are always in the order of local crate items, `std`/`core` items and finally foreign crate items. Tweak wording of import suggestion: if there are multiple items but they are all of the same kind, we use the kind name and not the generic "items". Fix #83564.
2024-06-11Rollup merge of #126234 - Bryanskiy:delegation-no-entry-ice, r=petrochenkov许杰友 Jieyou Xu (Joe)-2/+5
Delegation: fix ICE on late diagnostics fixes https://github.com/rust-lang/rust/issues/124342
2024-06-11Rollup merge of #125913 - fmease:early-lints-spruce-up-some-diags, r=Nadrieril许杰友 Jieyou Xu (Joe)-8/+16
Spruce up the diagnostics of some early lints Implement the various "*(note to myself) in a follow-up PR we should turn parts of this message into a subdiagnostic (help msg or even struct sugg)*" drive-by comments I left in #124417 during my review. For context, before #124417, only a few early lints touched/decorated/customized their diagnostic because the former API made it a bit awkward. Likely because of that, things that should've been subdiagnostics were just crammed into the primary message. This PR rectifies this.
2024-06-10Delegation: fix ICE on late diagnosticsBryanskiy-2/+5
2024-06-10Elision: consider lifetimes from &T iff T has SelfAdrian Taylor-19/+45
Change the algorithm which determines whether a self lifetime can be used for return type lifetime elision, such that we consider lifetimes attached to any reference in the self type, so long as Self can be found anywhere inside the type of that reference.
2024-06-07mark binding undetermined if target name exist and not obtainedbohan-5/+5
2024-06-07Revert "Create const block DefIds in typeck instead of ast lowering"Oli Scherer-4/+12
This reverts commit ddc5f9b6c1f21da5d4596bf7980185a00984ac42.
2024-06-06Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obkbors-3/+18
Unsafe extern blocks This implements RFC 3484. Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484 This is better reviewed commit by commit.
2024-06-05Auto merge of #126038 - matthiaskrgr:rollup-h4rm3x2, r=matthiaskrgrbors-4/+29
Rollup of 9 pull requests Successful merges: - #124840 (resolve: mark it undetermined if single import is not has any bindings) - #125622 (Winnow private method candidates instead of assuming any candidate of the right name will apply) - #125648 (Remove unused(?) `~/rustsrc` folder from docker script) - #125672 (Add more ABI test cases to miri (RFC 3391)) - #125800 (Fix `mut` static task queue in SGX target) - #125871 (Orphanck[old solver]: Consider opaque types to never cover type parameters) - #125893 (Handle all GVN binops in a single place.) - #126008 (Port `tests/run-make-fulldeps/issue-19371` to ui-fulldeps) - #126032 (Update description of the `IsTerminal` example) r? `@ghost` `@rustbot` modify labels: rollup