about summary refs log tree commit diff
path: root/compiler/rustc_resolve
AgeCommit message (Collapse)AuthorLines
2024-12-02Add a helper method for extracting spans from AttrArgsEqOli Scherer-2/+2
2024-12-02Change `AttrArgs::Eq` into a struct variantOli Scherer-1/+1
2024-11-28Replace `Symbol::intern` calls with preinterned symbolsclubby789-1/+2
2024-11-28always create `DefId`s when lowering anon-constslcnr-147/+28
2024-11-27Auto merge of #133274 - ehuss:macro_rules-edition-from-pm, r=compiler-errorsbors-1/+1
Use edition of `macro_rules` when compiling the macro This changes the edition assigned to a macro_rules macro when it is compiled to use the edition of where the macro came from instead of the local crate's edition. This fixes a problem when a macro_rules macro is created by a proc-macro. Previously that macro would be tagged with the local edition, which would cause problems with using the correct edition behavior inside the macro. For example, the check for unsafe attributes would cause errors in 2024 when using proc-macros from older editions. This is partially related to https://github.com/rust-lang/rust/issues/132906. Unfortunately this is only a half fix for that issue. It fixes the error that happens in 2024, but does not fix the lint firing in 2021. I'm still trying to think of some way to fix that, but I'm running low on ideas.
2024-11-25Refactor `where` predicates, and reserve for attributes supportFrank King-24/+26
2024-11-25Rollup merge of #133105 - bvanjoi:issue-132743, r=petrochenkov许杰友 Jieyou Xu (Joe)-15/+17
only store valid proc macro item for doc link Fixes #132743 The definition item can be detected if it is exported in the doc, so store these items rather than skipping. r? `@petrochenkov`
2024-11-23Auto merge of #131859 - chriskrycho:update-trpl, r=onur-ozkanbors-1/+1
Update TRPL to add new Chapter 17: Async and Await - Add support to `rustbook` to pass through the `-L`/`--library-path` flag to `mdbook` so that references to the `trpl` crate - Build the `trpl` crate as part of the book tests. Make it straightforward to add other such book dependencies in the future if needed by implementing that in a fairly general way. - Update the submodule for the book to pull in the new chapter on async and await, as well as a number of other fixes. This will happen organically/automatically in a week, too, but this lets me group this change with the next one: - Update the compiler messages which reference the existing chapters 17–20, which are now chapters 18-21. There are only two, both previously referencing chapter 18. - Update the UI tests which reference the compiler message outputs.
2024-11-23Update tests for new TRPL chapter orderChris Krycho-1/+1
2024-11-23Rollup merge of #133286 - jieyouxu:bug-ourselves, r=compiler-errors许杰友 Jieyou Xu (Joe)-3/+3
Re-delay a resolve `bug` related to `Self`-ctor in patterns For the code pattern reported in <https://github.com/rust-lang/rust/issues/133272>, ```rs impl Foo { fn fun() { let S { ref Self } = todo!(); } } ``` <https://github.com/rust-lang/rust/pull/121208> converted this to a `span_bug` from a `span_delayed_bug` because this specific self-ctor code pattern lacked test coverage. It turns out this can be hit but we just lacked test coverage, so change it back to a `span_delayed_bug` and add a targeted test case. Follow-up to #121208, cc ``@nnethercote`` (very good exercise to expose our test coverage gaps). Fixes #133272.
2024-11-23Rollup merge of #132949 - clubby789:macro-rules-attr-derive, r=fmease许杰友 Jieyou Xu (Joe)-4/+38
Add specific diagnostic for using macro_rules macro as attribute/derive Fixes #132928
2024-11-23only store valid proc marco item for doc linkbohan-15/+17
2024-11-22Diagnostic for using macro_rules macro as attr/deriveclubby789-4/+38
2024-11-21Re-delay a resolve `bug`Jieyou Xu-3/+3
For the code pattern reported in <https://github.com/rust-lang/rust/issues/133272>, ```rs impl Foo { fn fun() { let S { ref Self } = todo!(); } } ``` <https://github.com/rust-lang/rust/pull/121208> converted this to a `span_bug` from a `span_delayed_bug` because this specific self-ctor code pattern lacked test coverage. It turns out this can be hit but we just lacked test coverage, so change it back to a `span_delayed_bug` and add a target tested case.
2024-11-20Use edition of `macro_rules` when compiling the macroEric Huss-1/+1
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