about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
AgeCommit message (Collapse)AuthorLines
2024-12-14Don't make a def id for impl_trait_in_bindingsMichael Goulet-0/+10
2024-12-13Rollup merge of #134140 - compiler-errors:unsafe-binders-ast, r=oli-obkMatthias Krüger-0/+22
Add AST support for unsafe binders I'm splitting up #130514 into pieces. It's impossible for me to keep up with a huge PR like that. I'll land type system support for this next, probably w/o MIR lowering, which will come later. r? `@oli-obk` cc `@BoxyUwU` and `@lcnr` who also may want to look at this, though this PR doesn't do too much yet
2024-12-12Lower AST and resolve lifetimes for unsafe binder typesMichael Goulet-0/+22
2024-12-10Silence `use foo::Bar;` error if `Bar` isn't found in `foo` and `foo.rs` has ↵Esteban Küber-1/+6
parse errors
2024-12-10Keep track of parse errors in `mod`s and don't emit resolve errors for paths ↵Esteban Küber-32/+74
involving them When we expand a `mod foo;` and parse `foo.rs`, we now track whether that file had an unrecovered parse error that reached the end of the file. If so, we keep that information around. When resolving a path like `foo::bar`, we do not emit any errors for "`bar` not found in `foo`", as we know that the parse error might have caused `bar` to not be parsed and accounted for. When this happens in an existing project, every path referencing `foo` would be an irrelevant compile error. Instead, we now skip emitting anything until `foo.rs` is fixed. Tellingly enough, we didn't have any test for errors caused by `mod` expansion. Fix #97734.
2024-12-09review comments: rewordingsEsteban Küber-1/+1
2024-12-09Introduce `default_field_values` featureEsteban Küber-4/+23
Initial implementation of `#[feature(default_field_values]`, proposed in https://github.com/rust-lang/rfcs/pull/3681. Support default fields in enum struct variant Allow default values in an enum struct variant definition: ```rust pub enum Bar { Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Allow using `..` without a base on an enum struct variant ```rust Bar::Foo { .. } ``` `#[derive(Default)]` doesn't account for these as it is still gating `#[default]` only being allowed on unit variants. Support `#[derive(Default)]` on enum struct variants with all defaulted fields ```rust pub enum Bar { #[default] Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Check for missing fields in typeck instead of mir_build. Expand test with `const` param case (needs `generic_const_exprs` enabled). Properly instantiate MIR const The following works: ```rust struct S<A> { a: Vec<A> = Vec::new(), } S::<i32> { .. } ``` Add lint for default fields that will always fail const-eval We *allow* this to happen for API writers that might want to rely on users' getting a compile error when using the default field, different to the error that they would get when the field isn't default. We could change this to *always* error instead of being a lint, if we wanted. This will *not* catch errors for partially evaluated consts, like when the expression relies on a const parameter. Suggestions when encountering `Foo { .. }` without `#[feature(default_field_values)]`: - Suggest adding a base expression if there are missing fields. - Suggest enabling the feature if all the missing fields have optional values. - Suggest removing `..` if there are no missing fields.
2024-12-03Rollup merge of #133545 - clubby789:symbol-intern-lit, r=jieyouxuMatthias Krüger-1/+2
Lint against Symbol::intern on a string literal Disabled in tests where this doesn't make much sense
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)-3/+31
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-3/+31
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)