about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src
AgeCommit message (Collapse)AuthorLines
2024-03-11Run a single huge `par_body_owners` instead of many small ones after each other.Oli Scherer-13/+0
This improves parallel rustc parallelism by avoiding the bottleneck after each individual `par_body_owners` (because it needs to wait for queries to finish, so if there is one long running one, a lot of cores will be idle while waiting for the single query).
2024-03-11Merge various rustc_attr based testsOli Scherer-8/+2
2024-03-11Never bail out early while running all the type check queriesOli Scherer-25/+15
2024-03-11Rollup merge of #121840 - oli-obk:freeze, r=dtolnayJacob Pratt-0/+14
Expose the Freeze trait again (unstably) and forbid implementing it manually non-emoji version of https://github.com/rust-lang/rust/pull/121501 cc #60715 This trait is useful for generic constants (associated consts of generic traits). See the test (`tests/ui/associated-consts/freeze.rs`) added in this PR for a usage example. The builtin `Freeze` trait is the only way to do it, users cannot work around this issue. It's also a useful trait for building some very specific abstrations, as shown by the usage by the `zerocopy` crate: https://github.com/google/zerocopy/issues/941 cc ```@RalfJung``` T-lang signed off on reexposing this unstably: https://github.com/rust-lang/rust/pull/121501#issuecomment-1969827742
2024-03-11Rename `IntoDiagnostic` as `Diagnostic`.Nicholas Nethercote-4/+4
To match `derive(Diagnostic)`. Also rename `into_diagnostic` as `into_diag`.
2024-03-10Auto merge of #121662 - saethlin:precondition-unification, r=RalfJungbors-2/+3
Distinguish between library and lang UB in assert_unsafe_precondition As described in https://github.com/rust-lang/rust/pull/121583#issuecomment-1963168186, `assert_unsafe_precondition` now explicitly distinguishes between language UB (conditions we explicitly optimize on) and library UB (things we document you shouldn't do, and maybe some library internals assume you don't do). `debug_assert_nounwind` was originally added to avoid the "only at runtime" aspect of `assert_unsafe_precondition`. Since then the difference between the macros has gotten muddied. This totally revamps the situation. Now _all_ preconditions shall be checked with `assert_unsafe_precondition`. If you have a precondition that's only checkable at runtime, do a `const_eval_select` hack, as done in this PR. r? RalfJung
2024-03-09miri: do not apply aliasing restrictions to Box with custom allocatorRalf Jung-0/+4
2024-03-08Distinguish between library and lang UB in assert_unsafe_preconditionBen Kimock-2/+3
2024-03-08Rollup merge of #122172 - compiler-errors:rpitit-collect-ice, r=fmeaseMatthias Krüger-8/+7
Don't ICE if we collect no RPITITs unless there are no unification errors Move an assertion in `collect_return_position_impl_trait_in_trait_tys` to after the `ObligationCtxt::eq` calls, so that we only assert and ICE if we have unification errors. Fixes #121468
2024-03-08Rollup merge of #122100 - compiler-errors:better-capture, r=oli-obkMatthias Krüger-28/+52
Better comment for implicit captures in RPITIT Improve the error message for implicit captures. Also always set E0657. r? oli-obk
2024-03-08Improve error message for opaque capturesMichael Goulet-28/+52
2024-03-08Auto merge of #122190 - matthiaskrgr:rollup-9ol4y30, r=matthiaskrgrbors-32/+27
Rollup of 8 pull requests Successful merges: - #121025 (add known-bug tests for derive failure to detect packed repr) - #121194 (Refactor pre-getopts command line argument handling) - #121563 (Use `ControlFlow` in visitors.) - #122173 (Don't ICE in CTFE if raw/fn-ptr types differ) - #122175 (Bless tidy issues order) - #122179 (rustc: Fix typo) - #122181 (Fix crash in internal late lint checking) - #122183 (interpret: update comment about read_discriminant on uninhabited variants) Failed merges: - #122076 (Tweak the way we protect in-place function arguments in interpreters) - #122132 (Diagnostic renaming 3) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-08Don't ICE if we collect no RPITITs unless there are no unification errorsMichael Goulet-8/+7
2024-03-08Auto merge of #121500 - oli-obk:track_errors12, r=petrochenkovbors-20/+23
Merge `collect_mod_item_types` query into `check_well_formed` follow-up to https://github.com/rust-lang/rust/pull/121154 this removes more potential parallel-compiler bottlenecks and moves diagnostics for the same items next to each other, instead of grouping diagnostics by analysis kind
2024-03-08Rollup merge of #121563 - Jarcho:use_cf, r=petrochenkovMatthias Krüger-32/+27
Use `ControlFlow` in visitors. Follow up to #121256 This does have a few small behaviour changes in some diagnostic output where the visitor will now find the first match rather than the last match. The change in `find_anon_types.rs` has the only affected test. I don't see this being an issue as the last occurrence isn't any better of a choice than the first.
2024-03-08Rollup merge of #122103 - compiler-errors:taits-capture-everything, r=oli-obkMatthias Krüger-73/+20
Make TAITs and ATPITs capture late-bound lifetimes in scope This generalizes the behavior that RPITs have, where they duplicate their in-scope lifetimes so that they will always *reify* late-bound lifetimes that they capture. This allows TAITs and ATPITs to properly error when they capture in-scope late-bound lifetimes. r? `@oli-obk` cc `@aliemjay` Fixes #122093 and therefore https://github.com/rust-lang/rust/pull/120700#issuecomment-1981213868
2024-03-08Rollup merge of #119365 - nbdd0121:asm-goto, r=AmanieuMatthias Krüger-0/+2
Add asm goto support to `asm!` Tracking issue: #119364 This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto). Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary. r? ``@Amanieu`` cc ``@ojeda``
2024-03-08Rename some functions to represent their generalized behaviorMichael Goulet-2/+2
2024-03-08Make TAITs capture all higher-ranked lifetimes in scopeMichael Goulet-72/+19
2024-03-07Merge collect_mod_item_types query into check_well_formedOli Scherer-31/+23
2024-03-07Rollup merge of #122123 - compiler-errors:object-trait-alias-bounds, r=oli-obkGuillaume Gomez-44/+36
Don't require specifying unrelated assoc types when trait alias is in `dyn` type Object types must specify the associated types for all of the principal trait ref's supertraits. However, we weren't doing elaboration properly, so we incorrectly errored with erroneous suggestions to specify associated types that were unrelated to that principal trait ref. To fix this, use proper supertrait elaboration when expanding trait aliases in `conv_object_ty_poly_trait_ref`. **NOTE**: Please use the ignore-whitespace option when reviewing. This only touches a handful of lines. r? oli-obk or please feel free to reassign. Fixes #122118
2024-03-07Rollup merge of #122043 - Y-Nak:move-early-binder, r=lcnrGuillaume Gomez-36/+31
Apply `EarlyBinder` only to `TraitRef` in `ImplTraitHeader` Resolves #121852 This PR 1. Moves `EarlyBinder` to `TraitRef` inside `ImplTraitHeader`, 2. Changes visibility of `coherence::builtin::check_trait` to `pub(super)` from `pub` as it seems not being re-exported from the `coherence` module.
2024-03-07Rollup merge of #121863 - lukas-code:silence-mismatched-super-projections, ↵Guillaume Gomez-18/+28
r=lcnr silence mismatched types errors for implied projections Currently, if a trait bound is not satisfied, then we suppress any errors for the trait's supertraits not being satisfied, but still report errors for super projections not being satisfied. For example: ```rust trait Super { type Assoc; } trait Sub: Super<Assoc = ()> {} ``` Before this PR, if `T: Sub` is not satisfied, then errors for `T: Super` are suppressed, but errors for `<T as Super>::Assoc == ()` are still shown. This PR makes it so that errors about super projections not being satisfied are also suppressed. The errors are only suppressed if the span of the trait obligation matches the span of the super predicate obligation to avoid silencing error that are not related. This PR removes some differences between the spans of supertraits and super projections to make the suppression work correctly. This PR fixes the majority of the diagnostics fallout when making `Thin` a supertrait of `Sized` (in a future PR). cc https://github.com/rust-lang/rust/pull/120354#issuecomment-1930585382 cc `@lcnr`
2024-03-07Use the same collection order as check_mod_type_wfOli Scherer-3/+3
2024-03-07Apply `EarlyBinder` only to `TraitRef` in `ImplTraitHeader`Yoshitomo Nakanishi-36/+31
2024-03-07Collect mod item types in parallel, just like wfcheckOli Scherer-1/+12
2024-03-07Merge `check_mod_impl_wf` and `check_mod_type_wf`Oli Scherer-27/+13
2024-03-07Don't require specifying unrelated assoc types when trait alias is in dyn typeMichael Goulet-44/+36
2024-03-06Rollup merge of #122027 - compiler-errors:rpitit-cycle, r=spastorinoMatthias Krüger-15/+61
Uplift some feeding out of `associated_type_for_impl_trait_in_impl` and into queries This PR moves the `type_of` and `generics_of` query feeding out of `associated_type_for_impl_trait_in_impl`, since eagerly feeding results in query cycles due to a subtle interaction with `resolve_bound_vars`. Fixes #122019 r? spastorino
2024-03-06Auto merge of #121679 - lcnr:opaque-wf-check-2, r=oli-obkbors-32/+24
stricter hidden type wf-check [based on #115008] Original work by `@aliemjay` in #115008. A huge thanks to them for originally figuring out this approach :heart: Fixes https://github.com/rust-lang/rust/issues/114728 Fixes https://github.com/rust-lang/rust/issues/114572 Instead of adding the `WellFormed` obligations when relating opaque types, we now always emit such an obligation when defining the hidden type. This causes nested opaque types which aren't wf to error, see the comment below for the described impact. I believe this change to be desirable as it significantly reduces complexity by removing special-cases. It also caused an issue with RPITIT: in defaulted trait methods, we add a `Projection(synthetic_assoc, rpit_of_trait_method)` clause to the `param_env`. This clause is not added to the `ParamEnv` of the nested coroutines. This caused a normalization failure in `fn check_coroutine_obligations` with the new solver. I fixed that by using the env of the typeck root instead. r? `@oli-obk`
2024-03-06Auto merge of #122045 - matthiaskrgr:rollup-5l3vpn7, r=matthiaskrgrbors-2/+2
Rollup of 9 pull requests Successful merges: - #121065 (Add basic i18n guidance for `Display`) - #121744 (Stop using Bubble in coherence and instead emulate it with an intercrate check) - #121829 (Dummy tweaks (attempt 2)) - #121857 (Implement async closure signature deduction) - #121894 (const_eval_select: make it safe but be careful with what we expose on stable for now) - #122014 (Change some attributes to only_local.) - #122016 (will_wake tests fail on Miri and that is expected) - #122018 (only set noalias on Box with the global allocator) - #122028 (Remove some dead code) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-05Use `ControlFlow` in HIR visitorsJason Newcomb-32/+27
2024-03-05Split refining_impl_trait lint into _reachable, _internal variantsTyler Mandry-16/+18
2024-03-06Auto merge of #122041 - matthiaskrgr:rollup-imsmdke, r=matthiaskrgrbors-21/+14
Rollup of 8 pull requests Successful merges: - #121202 (Limit the number of names and values in check-cfg diagnostics) - #121301 (errors: share `SilentEmitter` between rustc and rustfmt) - #121658 (Hint user to update nightly on ICEs produced from outdated nightly) - #121846 (only compare ambiguity item that have hard error) - #121961 (add test for #78894 #71450) - #121975 (hir_analysis: enums return `None` in `find_field`) - #121978 (Fix duplicated path in the "not found dylib" error) - #121991 (Merge impl_trait_in_assoc_types_defined_by query back into `opaque_types_defined_by`) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-05Rollup merge of #122028 - oli-obk:drop_in_place_leftovers, r=compiler-errorsMatthias Krüger-1/+0
Remove some dead code drop_in_place has been a lang item, not an intrinsic, for forever
2024-03-05Rollup merge of #121894 - RalfJung:const_eval_select, r=oli-obkMatthias Krüger-1/+2
const_eval_select: make it safe but be careful with what we expose on stable for now As this is all still nightly-only I think `````@rust-lang/wg-const-eval````` can do that without involving t-lang. r? `````@oli-obk````` Cc `````@Nilstrieb````` -- the updated version of your RFC would basically say that we can remove these comments about not making behavior differences visible in stable `const fn`
2024-03-05Rollup merge of #121991 - oli-obk:merge_opaque_types_defined_by_queries, ↵Matthias Krüger-20/+8
r=compiler-errors Merge impl_trait_in_assoc_types_defined_by query back into `opaque_types_defined_by` Instead, when we're collecting opaques for associated items, we choose the right collection mode depending on whether we're collecting for an associated item of a trait impl or not. r? ```@compiler-errors``` follow up to https://github.com/rust-lang/rust/pull/121838
2024-03-05Rollup merge of #121975 - davidtwco:issue-121757, r=petrochenkovMatthias Krüger-1/+6
hir_analysis: enums return `None` in `find_field` Fixes #121757. Unnamed union fields with enums are checked for, but if `find_field` causes an ICE then the compiler won't get to that point.
2024-03-05Convert `TypeVisitor` and `DefIdVisitor` to use `VisitorResult`Jason Newcomb-43/+25
2024-03-05Move visitor utils to `rustc_ast_ir`Jason Newcomb-2/+2
2024-03-05Merge `impl_trait_in_assoc_types_defined_by` query back into ↵Oli Scherer-20/+8
`opaque_types_defined_by` Instead, when we're collecting opaques for associated items, we choose the right collection mode depending on whether we're collecting for an associated item of a trait impl or not.
2024-03-05Remove some dead codeOli Scherer-1/+0
drop_in_place has been a lang item, not an intrinsic, for forever
2024-03-05Uplift some feeding out of associated_type_for_impl_trait_in_impl and into ↵Michael Goulet-15/+61
queries
2024-03-05Auto merge of #121780 - nnethercote:diag-renaming2, r=davidtwcobors-10/+10
Diagnostic renaming 2 A sequel to #121489. r? `@davidtwco`
2024-03-05Rename `StructuredDiagnostic` as `StructuredDiag`.Nicholas Nethercote-8/+8
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-2/+2
2024-03-05Auto merge of #120675 - oli-obk:intrinsics3.0, r=pnkfelixbors-2/+2
Add a scheme for moving away from `extern "rust-intrinsic"` entirely All `rust-intrinsic`s can become free functions now, either with a fallback body, or with a dummy body and an attribute, requiring backends to actually implement the intrinsic. This PR demonstrates the dummy-body scheme with the `vtable_size` intrinsic. cc https://github.com/rust-lang/rust/issues/63585 follow-up to #120500 MCP at https://github.com/rust-lang/compiler-team/issues/720
2024-03-04Rollup merge of #121969 - nnethercote:ParseSess-cleanups, r=wesleywiserMatthias Krüger-1/+1
`ParseSess` cleanups The main change here is to rename all `ParseSess` values as `psess`. Plus a few other small cleanups. r? `@wesleywiser`
2024-03-05Rename all `ParseSess` variables/fields/lifetimes as `psess`.Nicholas Nethercote-1/+1
Existing names for values of this type are `sess`, `parse_sess`, `parse_session`, and `ps`. `sess` is particularly annoying because that's also used for `Session` values, which are often co-located, and it can be difficult to know which type a value named `sess` refers to. (That annoyance is the main motivation for this change.) `psess` is nice and short, which is good for a name used this much. The commit also renames some `parse_sess_created` values as `psess_created`.
2024-03-04rename `ast_*` to `hir_*` in wfcheckLukas Markeffsky-17/+17