summary refs log tree commit diff
path: root/compiler/rustc_resolve
AgeCommit message (Collapse)AuthorLines
2024-11-20Store resolution for self and crate root module segmentsMichael Goulet-4/+10
2024-11-19Auto merge of #132761 - nnethercote:resolve-tweaks, r=petrochenkovbors-92/+51
Resolve tweaks A couple of small perf improvements, and some minor refactorings, all in `rustc_resolve`. r? `@petrochenkov`
2024-11-16Rollup merge of #132787 - maxcabrajac:fnctxt, r=petrochenkovMatthias Krüger-1/+1
Unify FnKind between AST visitors and make WalkItemKind more straight forward Unifying `FnKind` requires a bunch of changes to `WalkItemKind::walk` signature so I'll change them in one go related to #128974 r? `@petrochenkov`
2024-11-15Make WalkItemKind::walk signature compatible between Visitor versionsmaxcabrajac-1/+1
2024-11-15Add WalkItemKind::Ctxt so AssocCtxt is not sent to non-Assoc ItemKindsmaxcabrajac-1/+1
2024-11-14Remove `Resolver::empty_disambiguator`.Nicholas Nethercote-6/+0
It was added in #115367 for anonymous ADTs. Those changes were then reverted in #131045, but `empty_disambiguator` was left behind, perhaps by mistake. It seems to be unnecessary.
2024-11-14Replace the `restricted_shadowing` boolean argument with an enum.Nicholas Nethercote-12/+22
It makes the code clearer.
2024-11-14Move a call outside a loop.Nicholas Nethercote-1/+1
This path isn't hot enough for this to affect performance, but there's no point repeating the same computation multiple times.
2024-11-14Remove two `_ext` methods.Nicholas Nethercote-56/+13
`resolve_ident_in_module` is a very thin wrapper around `resolve_ident_in_module_ext`, and `resolve_ident_in_module_unadjusted` is a very thin wrapper around `resolve_ident_in_module_unadjusted_ext`. The wrappers make the call sites slightly more concise, but I don't think that's worth the extra code and indirection. This commit removes the two wrappers and removes the `_ext` suffixes from the inner methods.
2024-11-14Use an atom comparison for a keyword check.Nicholas Nethercote-1/+3
Instead of a string comparison.
2024-11-14Use `for_each_child` in a suitable place.Nicholas Nethercote-7/+5
`for_each_child` exists for this exact pattern.
2024-11-14Tweak a `resolutions` loop.Nicholas Nethercote-6/+5
In this case field access is more concise and easier to read than destructuring, and it matches how other similar loops are done elsewhere.
2024-11-13Use iteration instead of indexing to access ribs.Nicholas Nethercote-6/+5
This gives a small but noticeable performance improvement.
2024-11-12Rollup merge of #132653 - BoxyUwU:const_arg_stmt_mac_call, r=compiler-errorsMatthias Krüger-19/+10
Don't use `maybe_unwrap_block` when checking for macro calls in a block expr Fixes #131915 Using `maybe_unwrap_block` to determine if we are looking at a `{ mac_call!{} }` will fail sometimes as `mac_call!{}` could be a `StmtKind::MacCall` not a `StmtKind::Expr`. This caused the def collector to think that `{ mac_call!{} }` was a non-trivial const argument and create a definition for it even though it should not. r? `@compiler-errors` cc `@camelid`
2024-11-08use verbose for path separator suggestionMichael Goulet-1/+1
2024-11-05Rollup merge of #132567 - estebank:bad-suggestion, r=NadrierilMatthias Krüger-10/+36
Properly suggest `E::assoc` when we encounter `E::Variant::assoc` Use the right span when encountering an enum variant followed by an associated item so we don't lose the associated item in the resulting code. Do not suggest the thing twice, once as a removal of the associated item and a second time as a typo suggestion.
2024-11-05Check for both `StmtKind::MacCall` and `ExprKind::MacCall`Boxy-19/+10
2024-11-03Properly suggest `E::assoc` when we encounter `E::Variant::assoc`Esteban Küber-10/+36
Use the right span when encountering an enum variant followed by an associated item so we don't lose the associated item in the resulting code. Do not suggest the thing twice, once as a removal of the associated item and a second time as a typo suggestion.
2024-11-02Suggest fixing typos and let bindings at the same timeuellenberg-3/+6
Fixes #132483
2024-10-30Review comments.Camille GILLOT-1/+1
2024-10-30Remap impl-trait lifetimes on HIR instead of AST lowering.Camille GILLOT-39/+1
2024-10-29Rollup merge of #131375 - klensy:clone_on_ref_ptr, r=cjgillotJubilee-4/+4
compiler: apply clippy::clone_on_ref_ptr for CI Apply lint https://rust-lang.github.io/rust-clippy/master/index.html#/clone_on_ref_ptr for compiler, also see https://github.com/rust-lang/rust/pull/131225#discussion_r1790109443. Some Arc's can be misplaced with Lrc's, sorry. https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/enable.20more.20clippy.20lints.20for.20compiler.20.28and.5Cor.20std.29
2024-10-28fix clippy::clone_on_ref_ptr for compilerklensy-4/+4
2024-10-26expand: Stop using artificial `ast::Item` for macros loaded from metadataVadim Petrochenkov-18/+32
2024-10-24Pass Ident by reference in ast Visitormaxcabrajac-3/+3
2024-10-23nightly feature tracking: get rid of the per-feature bool fieldsRalf Jung-12/+12
2024-10-22terminology: #[feature] *enables* a feature (instead of "declaring" or ↵Ralf Jung-4/+2
"activating" it)
2024-10-20Stop relying on hashmap iteration for unused macro rules armsNoratrieb-14/+27
2024-10-18Fix #131471, range misleading field accessFalco Hirschenberger-0/+1
Fixes #131471 by checking if the range-start is a literal.
2024-10-16compiler: use `is_none_or` where it is clearly betterJubilee Young-2/+2
heuristic was: if it easily allows removing bangs entirely? worth it. if it requires more effort or just moves the bang? not.
2024-10-15Auto merge of #131723 - matthiaskrgr:rollup-krcslig, r=matthiaskrgrbors-18/+19
Rollup of 9 pull requests Successful merges: - #122670 (Fix bug where `option_env!` would return `None` when env var is present but not valid Unicode) - #131095 (Use environment variables instead of command line arguments for merged doctests) - #131339 (Expand set_ptr_value / with_metadata_of docs) - #131652 (Move polarity into `PolyTraitRef` rather than storing it on the side) - #131675 (Update lint message for ABI not supported) - #131681 (Fix up-to-date checking for run-make tests) - #131702 (Suppress import errors for traits that couldve applied for method lookup error) - #131703 (Resolved python deprecation warning in publish_toolstate.py) - #131710 (Remove `'apostrophes'` from `rustc_parse_format`) r? `@ghost` `@rustbot` modify labels: rollup
2024-10-15Rollup merge of #130635 - eholk:pin-reborrow-sugar, r=compiler-errorsMatthias Krüger-3/+3
Add `&pin (mut|const) T` type position sugar This adds parser support for `&pin mut T` and `&pin const T` references. These are desugared to `Pin<&mut T>` and `Pin<&T>` in the AST lowering phases. This PR currently includes #130526 since that one is in the commit queue. Only the most recent commits (bd450027eb4a94b814a7dd9c0fa29102e6361149 and following) are new. Tracking: - #130494 r? `@compiler-errors`
2024-10-14Move trait bound modifiers into ast::PolyTraitRefMichael Goulet-18/+19
2024-10-11Auto merge of #131045 - compiler-errors:remove-unnamed_fields, r=wesleywiserbors-41/+0
Retire the `unnamed_fields` feature for now `#![feature(unnamed_fields)]` was implemented in part in #115131 and #115367, however work on that feature has (afaict) stalled and in the mean time there have been some concerns raised (e.g.[^1][^2]) about whether `unnamed_fields` is worthwhile to have in the language, especially in its current desugaring. Because it represents a compiler implementation burden including a new kind of anonymous ADT and additional complication to field selection, and is quite prone to bugs today, I'm choosing to remove the feature. However, since I'm not one to really write a bunch of words, I'm specifically *not* going to de-RFC this feature. This PR essentially *rolls back* the state of this feature to "RFC accepted but not yet implemented"; however if anyone wants to formally unapprove the RFC from the t-lang side, then please be my guest. I'm just not totally willing to summarize the various language-facing reasons for why this feature is or is not worthwhile, since I'm coming from the compiler side mostly. Fixes #117942 Fixes #121161 Fixes #121263 Fixes #121299 Fixes #121722 Fixes #121799 Fixes #126969 Fixes #131041 Tracking: * https://github.com/rust-lang/rust/issues/49804 [^1]: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Unnamed.20struct.2Funion.20fields [^2]: https://github.com/rust-lang/rust/issues/49804#issuecomment-1972619108
2024-10-07Add sugar for &pin (const|mut) typesEric Holk-3/+3
2024-10-07Auto merge of #131235 - ↵bors-13/+14
codemountains:rename-nestedmetaitem-to-metaitemlnner, r=nnethercote Rename `NestedMetaItem` to `MetaItemInner` Fixes #131087 r? `@nnethercote`
2024-10-07Rename nested_meta to meta_item_innercodemountains-10/+12
2024-10-06Rename NestedMetaItem to MetaItemInnercodemountains-3/+2
2024-10-06Auto merge of #131259 - ↵bors-3/+3
ismailarilik:handle-potential-query-instability-lint-for-librustdoc, r=notriddle Handle `librustdoc` cases of `rustc::potential_query_instability` lint This PR removes `#![allow(rustc::potential_query_instability)]` line from [`src/librustdoc/lib.rs`](https://github.com/rust-lang/rust/blob/master/src/librustdoc/lib.rs#L23) and converts `FxHash{Map,Set}` types into `FxIndex{Map,Set}` to suppress lint errors. A somewhat tracking issue: https://github.com/rust-lang/rust/issues/84447 r? `@compiler-errors`
2024-10-06Handle `librustdoc` cases of `rustc::potential_query_instability` lintismailarilik-3/+3
2024-10-06On function and method calls in patterns, link to the bookEsteban Küber-0/+13
``` error: expected a pattern, found an expression --> f889.rs:3:13 | 3 | let (x, y.drop()) = (1, 2); //~ ERROR | ^^^^^^^^ not a pattern | = note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html> error[E0532]: expected a pattern, found a function call --> f889.rs:2:13 | 2 | let (x, drop(y)) = (1, 2); //~ ERROR | ^^^^ not a tuple struct or tuple variant | = note: function calls are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html> ``` Fix #97200.
2024-10-03rustdoc: prevent ctors from resolvingMichael Howell-1/+3
2024-10-03Handle `rustc_metadata` cases of `rustc::potential_query_instability` lintismailarilik-2/+2
2024-10-02Handle `rustc-hir-analysis` cases of `rustc::potential_query_instability` lintismailarilik-1/+1
2024-10-01Remove anon struct and union typesMichael Goulet-41/+0
2024-09-29cleanup: don't clone types that are CopyMatthias Krüger-5/+1
2024-09-24Separate collection of crate-local inherent impls from error reportingMichael Goulet-2/+4
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-207/+170
2024-09-22Auto merge of #130337 - BoxyUwU:anon_const_macro_call, r=camelidbors-20/+93
Fix anon const def-creation when macros are involved take 2 Fixes #130321 There were two cases that #129137 did not handle correctly: - Given a const argument `Foo<{ bar!() }>` in which `bar!()` expands to `N`, we would visit the anon const and then visit the `{ bar() }` expression instead of visiting the macro call. This meant that we would build a def for the anon const as `{ bar!() }` is not a trivial const argument as `bar!()` is not a path. - Given a const argument `Foo<{ bar!() }>` is which `bar!()` expands to `{ qux!() }` in which `qux!()` expands to `N`, it should not be considered a trivial const argument as `{{ N }}` has two pairs of braces. If we only looked at `qux`'s expansion it would *look* like a trivial const argument even though it is not. We have to track whether we have "unwrapped" a brace already when recursing into the expansions of `bar`/`qux`/any macro r? `@camelid`
2024-09-21Handle macro calls in anon const def creation take 2Boxy-20/+93