about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2024-05-21Sort `rustc_middle` attributes.Nicholas Nethercote-19/+21
As is already done in several other crates, such as `rustc_errors`.
2024-05-21Remove unused features from `rustc_middle`.Nicholas Nethercote-3/+1
2024-05-21Auto merge of #125284 - compiler-errors:uplift-misc, r=lcnrbors-48/+42
Uplift `RegionVid`, `TermKind` to `rustc_type_ir`, and `EagerResolver` to `rustc_next_trait_solver` - Uplift `RegionVid`. This was complicated due to the fact that we implement `polonius_engine::Atom` for `RegionVid` -- but I just separated that into `PoloniusRegionVid`, and added `From`/`Into` impls so it can be defined in `rustc_borrowck` separately. Coherence 😵 - Change `InferCtxtLike` to expose `opportunistically_resolve_{ty,ct,lt,int,float}_var` so that we can uplift `EagerResolver` for use in the canonicalization methods. - Uplift `TermKind` much like `GenericArgKind` All of this is miscellaneous dependencies for making more `EvalCtxt` methods generic.
2024-05-20Inline get_node_fn_decl into get_fn_decl, simplify/explain logic in ↵Michael Goulet-1/+5
report_return_mismatched_types
2024-05-20Rename confusing function nameMichael Goulet-6/+6
2024-05-20Remove get_parent_fn_decl; it's redundantMichael Goulet-1/+1
2024-05-20Implement BOXED_SLICE_INTO_ITERMichael Goulet-1/+6
2024-05-20move global cache lookup into fnlcnr-16/+18
2024-05-20Uplift TermKindMichael Goulet-18/+25
2024-05-20Rework var resolution in InferCtxtLike, uplift EagerResolverMichael Goulet-0/+16
2024-05-20Uplift RegionVidMichael Goulet-30/+1
2024-05-20Rollup merge of #125173 - scottmcm:never-checked, r=davidtwcoMatthias Krüger-20/+40
Remove `Rvalue::CheckedBinaryOp` Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/intrinsics.20vs.20binop.2Funop/near/438729996> cc `@RalfJung` While it's a draft, r? ghost
2024-05-20Rollup merge of #125106 - Zalathar:expressions, r=davidtwcoMatthias Krüger-2/+2
coverage: Memoize and simplify counter expressions When creating coverage counter expressions as part of coverage instrumentation, we often end up creating obviously-redundant expressions like `c1 + (c0 - c1)`, which is equivalent to just `c0`. To avoid doing so, this PR checks when we would create an expression matching one of 5 patterns, and uses the simplified form instead: - `(a - b) + b` → `a`. - `(a + b) - b` → `a`. - `(a + b) - a` → `b`. - `a + (b - a)` → `b`. - `a - (a - b)` → `b`. Of all the different ways to combine 3 operands and 2 operators, these are the patterns that allow simplification. (Some of those patterns currently don't occur in practice, but are included anyway for completeness, to avoid having to add them later as branch coverage and MC/DC coverage support expands.) --- This PR also adds memoization for newly-created (or newly-simplified) counter expressions, to avoid creating duplicates. This currently makes no difference to the final mappings, but is expected to be useful for MC/DC coverage of match expressions, as proposed by https://github.com/rust-lang/rust/pull/124278#issuecomment-2106754753.
2024-05-20Rollup merge of #124917 - cardigan1008:issue-124819, r=pnkfelixMatthias Krüger-0/+1
Check whether the next_node is else-less if in get_return_block Fix #124819
2024-05-19Make search graph generic over internerMichael Goulet-1/+9
2024-05-19Auto merge of #125294 - matthiaskrgr:rollup-w42c829, r=matthiaskrgrbors-8/+4
Rollup of 4 pull requests Successful merges: - #124948 (chore: Remove repeated words (extension of #124924)) - #124992 (Add example to IsTerminal::is_terminal) - #125279 (make `Debug` impl for `Term` simpler) - #125286 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-19make `Debug` impl for `Term` simplerWaffle Lapkin-8/+4
2024-05-19Add and use generics.is_empty() and generics.is_own_empty, rather than using ↵Santiago Pastorino-1/+9
generics' attributes
2024-05-19Auto merge of #125230 - compiler-errors:uplift-query-stuff, r=lcnrbors-712/+66
Uplift more query stuff - Uplift various query input/response internals - Uplift the `ProofTree` structures and make the `ProofTreeBuilder` stuff (mostly) generic over `Interner` - Stop using `TyCtxt::def_kind` in favor of `AliasTerm::kind` r? lcnr
2024-05-18Uplift inspect into rustc_type_irMichael Goulet-520/+22
2024-05-18Uplift GenericArgKind, CanonicalVarValues, QueryInputMichael Goulet-196/+48
and make NestedGoals generic
2024-05-18Auto merge of #125077 - spastorino:add-new-fnsafety-enum2, r=jackh726bors-46/+34
Rename Unsafe to Safety Alternative to #124455, which is to just have one Safety enum to use everywhere, this opens the posibility of adding `ast::Safety::Safe` that's useful for unsafe extern blocks. This leaves us today with: ```rust enum ast::Safety { Unsafe(Span), Default, // Safe (going to be added for unsafe extern blocks) } enum hir::Safety { Unsafe, Safe, } ``` We would convert from `ast::Safety::Default` into the right Safety level according the context.
2024-05-18(Mostly) revert "Account for type param from other item in `note_and_explain`"Michael Goulet-28/+0
This mostly reverts commit 7449478c2f6fd2d72c12a51d8562f1e6108facab. It also removes an `opt_param_at` that really is unnecessary given our ICE policy for malformed intrinsics.
2024-05-18An async closure may implement FnMut/Fn if it has no self-borrowsMichael Goulet-0/+39
2024-05-17Remove `Rvalue::CheckedBinaryOp`Scott McMurray-20/+40
2024-05-17Rename Unsafe to SafetySantiago Pastorino-46/+34
2024-05-17to_opt_poly_X_pred -> as_X_clauseMichael Goulet-2/+2
2024-05-16Uplift Goal to rustc_type_irMichael Goulet-83/+38
2024-05-16Make impls UpcastFrom, implement Upcast for UpcastFromMichael Goulet-89/+91
2024-05-16Make P parameter explicitMichael Goulet-16/+16
2024-05-16Rename ToPredicate for UpcastMichael Goulet-85/+85
2024-05-16Uplift FnSigMichael Goulet-109/+53
2024-05-15Rollup merge of #125137 - RalfJung:mir-sh, r=scottmcmLeón Orell Valerian Liehr-2/+6
MIR operators: clarify Shl/Shr handling of negative offsets "made unsigned" was not fully clear (made unsigned how? by using `abs`? no), so let's say "re-interpreted as an unsigned value of the same size" instead. r? `@scottmcm`
2024-05-15MIR operators: clarify Shl/Shr handling of negative offsetsRalf Jung-2/+6
2024-05-15Rollup merge of #125108 - Zalathar:info-bitmap-bytes, r=nnethercoteMatthias Krüger-10/+0
coverage: `CoverageIdsInfo::mcdc_bitmap_bytes` is never needed This code for recalculating `mcdc_bitmap_bytes` in a query doesn't provide any benefit, because its result won't have changed from the value in `FunctionCoverageInfo` that was computed during the MIR instrumentation pass. Extracted from #124571, to avoid having this held up by unrelated issues with condition count checks. `@rustbot` label +A-code-coverage
2024-05-15Rollup merge of #124990 - fmease:expand-weak-aliases-within-cts, ↵Matthias Krüger-1/+1
r=compiler-errors Also expand weak alias tys inside consts inside `expand_weak_alias_tys` Ever since #121344 has been merged, I couldn't let go of the fear that I might've slipped a tiny bug into rustc (:P). Checking the type flags of the `Const` is strictly more correct than only checking the ones of the `Const`'s `Ty`. I don't think it's possible to trigger an ICE rn (i.e., one of the two `bug!("unexpected weak alias type")` I added in branches where `expand_weak_alias_tys` should've expanded *all* weak alias tys) because presently const exprs aren't allowed to capture late-bound vars. To be future-proof however, we should iron this out. A possible reproducer would be the following if I'm not mistaken (currently fails to compile due to the aforementioned restriction): ```rs #![feature(lazy_type_alias, adt_const_params, generic_const_exprs)] type F = for<'a> fn(A<{ S::<Weak<'a>>(loop {}) }>) -> &'a (); type A<const N: S<Weak<'static>>> = (); #[derive(PartialEq, Eq, std::marker::ConstParamTy)] struct S<T>(T); type Weak<'a> = &'a (); ``` Whether a late-bound region should actually be considered constrained by a const expr is a separate question — one which we don't need to answer until / unless we actually allow them in such contexts (probable answer: only inside the return exprs of a block but not inside the stmts). r? oli-obk (he's not available rn but that's fine) or types or compiler
2024-05-14Rollup merge of #125088 - compiler-errors:uplift-alias-ty, r=lcnrMichael Goulet-480/+131
Uplift `AliasTy` and `AliasTerm` Follow-up from #125076. r? lcnr
2024-05-14coverage: Remove confusing comments from `CoverageKind`Zalathar-6/+0
These comments appear to be inspired by the similar comments on `CounterIncrement` and `ExpressionUsed`. But those comments refer to specific simplification steps performed during coverage codegen, and there is no corresponding step for the MC/DC coverage statements. If these statements do not survive optimization, they will simply not participate in code generation, just like any other statement.
2024-05-14coverage: `CoverageIdsInfo::mcdc_bitmap_bytes` is never neededZalathar-4/+0
This code for recalculating `mcdc_bitmap_bytes` doesn't provide any benefit, because its result won't have changed from the value in `FunctionCoverageInfo` that was computed during the MIR instrumentation pass.
2024-05-13Use a proper probe for shadowing implMichael Goulet-0/+5
2024-05-14coverage: Memoize newly-created counter expressionsZalathar-2/+2
This currently has no effect, but is expected to be useful when expanding support for branch coverage and MC/DC coverage.
2024-05-13Remove to_termMichael Goulet-8/+0
2024-05-13Uplift AliasTyMichael Goulet-480/+139
2024-05-13Auto merge of #125076 - compiler-errors:alias-term, r=lcnrbors-69/+285
Split out `ty::AliasTerm` from `ty::AliasTy` Splitting out `AliasTerm` (for use in project and normalizes goals) and `AliasTy` (for use in `ty::Alias`) r? lcnr
2024-05-13Apply nitsMichael Goulet-31/+35
2024-05-13split out AliasTy -> AliasTermMichael Goulet-61/+273
2024-05-13Add `size_of`, `size_of_val`, `align_of`, and `align_of_val` to the preludeJosh Triplett-1/+1
Many, many projects use `size_of` to get the size of a type. However, it's also often equally easy to hardcode a size (e.g. `8` instead of `size_of::<u64>()`). Minimizing friction in the use of `size_of` helps ensure that people use it and make code more self-documenting. The name `size_of` is unambiguous: the name alone, without any prefix or path, is self-explanatory and unmistakeable for any other functionality. Adding it to the prelude cannot produce any name conflicts, as any local definition will silently shadow the one from the prelude. Thus, we don't need to wait for a new edition prelude to add it. Add `size_of_val`, `align_of`, and `align_of_val` as well, with similar justification: widely useful, self-explanatory, unmistakeable for anything else, won't produce conflicts.
2024-05-13interpret: move error macros into error.rsRalf Jung-132/+126
2024-05-13Auto merge of #124914 - nnethercote:rm-extern-crate-rustc_middle, r=saethlinbors-11/+27
Remove `#[macro_use] extern crate rustc middle` from numerous crates Because explicit importing of macros via `use` items is nicer (more standard and readable) than implicit importing via `#[macro_use]`. This PR mops up some cases I didn't get to in #124511. r? `@saethlin`
2024-05-13Remove `extern crate rustc_middle` from `rustc_const_eval`.Nicholas Nethercote-11/+27
This requires exporting the interpreter macros so they can be used with `use crate::interpret::*`.