about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/collect
AgeCommit message (Collapse)AuthorLines
2025-02-12Rollup merge of #136806 - adwinwhite:cycle-in-pretty-print-rpitit, ↵Jacob Pratt-43/+45
r=compiler-errors Fix cycle when debug-printing opaque types from RPITIT Extend #66594 to opaque types from RPITIT. Before this PR, enabling debug logging like `RUSTC_LOG="[check_type_bounds]"` for code containing RPITIT produces a query cycle of `explicit_item_bounds`, as pretty printing for opaque type calls [it](https://github.com/rust-lang/rust/blob/d9a4a47b8b3dc0bdff83360cea2013200d60d49c/compiler/rustc_middle/src/ty/print/pretty.rs#L1001).
2025-02-11reduce query calls in pretty printing when finding bounds ofAdwin White-43/+45
associated types
2025-02-09Remove lifetime_capture_rules_2024 featureMichael Goulet-21/+12
2025-02-08Rustfmtbjorn3-24/+29
2025-02-05Rollup merge of #136550 - compiler-errors:rpitit-empty-body, r=oli-obkJubilee-0/+9
Fix `rustc_hidden_type_of_opaques` for RPITITs with no default body Needed this when debugging something
2025-02-04Fix rustc_hidden_type_of_opaques for RPITITs with no default bodyMichael Goulet-0/+9
2025-02-04Allow using named consts in pattern typesOli Scherer-0/+1
2025-02-03Use a different hir type for patterns in pattern types than we use in match ↵Oli Scherer-7/+18
patterns
2025-01-31Auto merge of #136331 - jhpratt:rollup-curo1f4, r=jhprattbors-68/+26
Rollup of 8 pull requests Successful merges: - #135414 (Stabilize `const_black_box`) - #136150 (ci: use windows 2025 for i686-mingw) - #136258 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 11)) - #136270 (Remove `NamedVarMap`.) - #136278 (add constraint graph to polonius MIR dump) - #136287 (LLVM changed the nocapture attribute to captures(none)) - #136291 (some test suite cleanups) - #136296 (float::min/max: mention the non-determinism around signed 0) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-31Rollup merge of #136270 - nnethercote:rm-NamedVarMap, r=jackh726Jacob Pratt-68/+26
Remove `NamedVarMap`. `NamedVarMap` is extremely similar to `ResolveBoundVars`. The former contains two `UnordMap<ItemLocalId, T>` fields (obscured behind `ItemLocalMap` typedefs). The latter contains two `SortedMap<ItemLocalId, T>` fields. We construct a `NamedVarMap` and then convert it into a `ResolveBoundVars` by sorting the `UnordMap`s, which is unnecessary busywork. This commit removes `NamedVarMap` and constructs a `ResolveBoundVars` directly. `SortedMap` and `NamedVarMap` have slightly different perf characteristics during construction (e.g. speed of insertion) but this code isn't hot enough for that to matter. A few details to note. - A `FIXME` comment is removed. - The detailed comments on the fields of `NamedVarMap` are copied to `ResolveBoundVars` (which has a single, incorrect comment). - `BoundVarContext::map` is renamed. - `ResolveBoundVars` gets a derived `Default` impl. r? `@jackh726`
2025-01-30Do not treat vtable supertraits as distinct when bound with different bound varsMichael Goulet-2/+2
2025-01-30Rework rustc_dump_vtableMichael Goulet-1/+81
2025-01-30Remove `NamedVarMap`.Nicholas Nethercote-68/+26
`NamedVarMap` is extremely similar to `ResolveBoundVars`. The former contains two `UnordMap<ItemLocalId, T>` fields (obscured behind `ItemLocalMap` typedefs). The latter contains two `SortedMap<ItemLocalId, T>` fields. We construct a `NamedVarMap` and then convert it into a `ResolveBoundVars` by sorting the `UnordMap`s, which is unnecessary busywork. This commit removes `NamedVarMap` and constructs a `ResolveBoundVars` directly. `SortedMap` and `NamedVarMap` have slightly different perf characteristics during construction (e.g. speed of insertion) but this code isn't hot enough for that to matter. A few details to note. - A `FIXME` comment is removed. - The detailed comments on the fields of `NamedVarMap` are copied to `ResolveBoundVars` (which has a single, incorrect comment). - `BoundVarContext::map` is renamed. - `ResolveBoundVars` gets a derived `Default` impl.
2025-01-28Make item self/non-self bound naming less whackMichael Goulet-6/+5
2025-01-27Use identifiers in diagnostics more oftenMichael Goulet-2/+2
2025-01-24use `fmt::from_fn` in more places, instead of using structs that impl ↵Yotam Ofek-32/+30
formatting traits
2025-01-23`visit_x_unambig`Boxy-17/+17
2025-01-23Semantic changes from new hir representationBoxy-7/+9
Always lower to `GenericArg::Infer` Update `PlaceholderCollector` Update closure lifetime binder infer var visitor Fallback visitor handle ambig infer args Ensure type infer args have their type recorded
2025-01-23Split hir `TyKind` and `ConstArgKind` in two and update `hir::Visitor`Boxy-27/+27
2025-01-23Make `hir::TyKind::TraitObject` use tagged ptrBoxy-3/+5
2025-01-16Auto merge of #134504 - oli-obk:push-rltsvnyttwll, r=compiler-errorsbors-1/+1
Use trait definition cycle detection for trait alias definitions, too fixes #133901 In general doing this for `All` is not right, but this code path is specifically for traits and trait aliases, and there we only ever use `All` for trait aliases.
2025-01-11Remove a bunch of diagnostic stashing that doesn't do anythingMichael Goulet-14/+7
2025-01-10remove more redundant into() conversionsMatthias Krüger-1/+1
2025-01-09Use trait definition cycle detection for trait alias definitions, tooOli Scherer-1/+1
2025-01-04Auto merge of #135031 - RalfJung:intrinsics-without-body, r=oli-obkbors-4/+4
rustc_intrinsic: support functions without body We synthesize a HIR body `loop {}` but such bodyless intrinsics. Most of the diff is due to turning `ItemKind::Fn` into a brace (named-field) enum variant, because it carries a `bool`-typed field now. This is to remember whether the function has a body. MIR building panics to avoid ever translating the fake `loop {}` body, and the intrinsic logic uses the lack of a body to implicitly mark that intrinsic as must-be-overridden. I first tried actually having no body rather than generating the fake body, but there's a *lot* of code that assumes that all function items have HIR and MIR, so this didn't work very well. Then I noticed that even `rustc_intrinsic_must_be_overridden` intrinsics have MIR generated (they are filled with an `Unreachable` terminator) so I guess I am not the first to discover this. ;) r? `@oli-obk`
2025-01-04turn hir::ItemKind::Fn into a named-field variantRalf Jung-4/+4
2025-01-02Fix macro shenanigansMichael Goulet-2/+11
2025-01-02Make suggestion verbose and tweak error messageMichael Goulet-2/+2
2025-01-02Suppress type param suggestion if encountering invalid const inferMichael Goulet-6/+7
2025-01-02Unconditionally lower generic_arg_inferMichael Goulet-1/+16
2025-01-02More refined spans for placeholder error in const/staticMichael Goulet-2/+11
2025-01-02Remove diagnostic_only_typeck and fix placeholder suggestion for const/staticMichael Goulet-1/+1
2025-01-02nit: Make get_infer_ret_ty name more consistent with is_suggestable_infer_tyMichael Goulet-1/+1
2024-12-18Rollup merge of #133926 - compiler-errors:const-conditions, r=lcnr许杰友 Jieyou Xu (Joe)-15/+33
Fix const conditions for RPITITs Fixes #133918 r? lcnr
2024-12-18Fix const conditions for RPITITsMichael Goulet-15/+33
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-9/+5
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-14(Re-)Implement impl_trait_in_bindingsMichael Goulet-0/+15
2024-12-12Lower AST and resolve lifetimes for unsafe binder typesMichael Goulet-0/+36
2024-12-11Rollup merge of #134105 - compiler-errors:validate-self-preds, r=wesleywiserJacob Pratt-2/+9
Validate self in host predicates correctly `assert_only_contains_predicates_from` was added to make sure that we are computing predicates for the correct self type for a given `PredicateFilter`. That was not implemented correctly for `PredicateFilter::SelfOnly` when there are const predicates. Fixes #133526
2024-12-10Validate self in host predicates correctlyMichael Goulet-2/+9
2024-12-09Introduce `default_field_values` featureEsteban Küber-0/+6
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-04Rollup merge of #133850 - oli-obk:push-xryukktpyooq, r=compiler-errorsMatthias Krüger-2/+12
Avoid `opaque type not constrained` errors in the presence of other errors pulled out of https://github.com/rust-lang/rust/pull/128440 These errors carry no new information if the opaque type was actually used in a constraining (but erroneous) way somewhere.
2024-12-04Avoid `opaque type not constrained` errors in the presence of other errorsOli Scherer-2/+12
2024-12-03Don't try and handle unfed `type_of` on anon constsBoxy-235/+8
2024-12-03Rollup merge of #133545 - clubby789:symbol-intern-lit, r=jieyouxuMatthias Krüger-1/+1
Lint against Symbol::intern on a string literal Disabled in tests where this doesn't make much sense
2024-12-02Move `Const::{from_anon_const,try_from_lit}` to hir_ty_loweringNoah Lev-43/+64
These operations are much more about lowering the HIR than about `Const`s themselves. They fit better in hir_ty_lowering with `lower_const_arg` (formerly `Const::from_const_arg`) and the rest. To accomplish this, `const_evaluatable_predicates_of` had to be changed to not use `from_anon_const` anymore. Instead of visiting the HIR and lowering anon consts on the fly, it now visits the `rustc_middle::ty` data structures instead and directly looks for `UnevaluatedConst`s. This approach was proposed in: https://github.com/rust-lang/rust/pull/131081#discussion_r1821189257
2024-12-01Rollup merge of #133589 - voidc:remove-array-len, r=boxyuwuJacob Pratt-4/+2
Remove `hir::ArrayLen` This refactoring removes `hir::ArrayLen`, replacing it with `hir::ConstArg`. To represent inferred array lengths (previously `hir::ArrayLen::Infer`), a new variant `ConstArgKind::Infer` is added. r? `@BoxyUwU`
2024-12-01Rollup merge of #132047 - compiler-errors:rbv-rtn-cleanup, r=cjgillotMatthias Krüger-35/+110
Robustify and genericize return-type-notation resolution in `resolve_bound_vars` #129629 implemented return-type-notation (RTN) in its path form, like `where T::method(..): Bound`. As part of lowering, we must record the late-bound vars for the where clause introduced by the method (namely, its early- and late-bound lifetime arguments, since `where T::method(..)` turns into a higher-ranked where clause over all of the lifetimes according to [RFC 3654](https://rust-lang.github.io/rfcs/3654-return-type-notation.html#converting-to-higher-ranked-trait-bounds)). However, this logic was only looking at the where clauses of the parent item that the `T::method(..)` bound was written on, and not any parent items. This PR generalizes that logic to look at the parent item (i.e. the outer impl or trait) instead and fixes a (debug only) assertion as an effect. This logic is also more general and likely easier to adapt to more interesting (though likely very far off) cases like non-lifetime binder `for<T: Trait> T::method(..): Send` bounds. Tracking: - https://github.com/rust-lang/rust/issues/109417
2024-11-30Remove hir::ArrayLen, introduce ConstArgKind::InferDominik Stolz-4/+2
Remove Node::ArrayLenInfer
2024-11-28Replace `Symbol::intern` calls with preinterned symbolsclubby789-1/+1