about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2024-05-23Allow const eval failures if the cause is a type layout issueOli Scherer-0/+3
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_middle`.Nicholas Nethercote-6/+41
2024-05-23Auto merge of #125359 - RalfJung:interpret-overflowing-ops, r=oli-obkbors-12/+24
interpret: make overflowing binops just normal binops Follow-up to https://github.com/rust-lang/rust/pull/125173 (Cc `@scottmcm)`
2024-05-23Remove `DelayDm`León Orell Valerian Liehr-1/+1
With the removal of `LintDiagnostic::msg` / the `msg` param from lint diag APIs, primary messages for lint diags are always constructed lazily inside decorator fns rendering this wrapper type unused / useless.
2024-05-23Remove `LintDiagnostic::msg`León Orell Valerian Liehr-33/+20
* instead simply set the primary message inside the lint decorator functions * it used to be this way before [#]101986 which introduced `msg` to prevent good path delayed bugs (which no longer exist) from firing under certain circumstances when lints were suppressed / silenced * this is no longer necessary for various reasons I presume * it shaves off complexity and makes further changes easier to implement
2024-05-22Auto merge of #125423 - fmease:rollup-ne4l9y4, r=fmeasebors-1/+1
Rollup of 7 pull requests Successful merges: - #125043 (reference type safety invariant docs: clarification) - #125306 (Force the inner coroutine of an async closure to `move` if the outer closure is `move` and `FnOnce`) - #125355 (Use Backtrace::force_capture instead of Backtrace::capture in rustc_log) - #125382 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 7)) - #125391 (Minor serialize/span tweaks) - #125395 (Remove unnecessary `.md` from the documentation sidebar) - #125399 (Stop using `to_hir_binop` in codegen) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-22Rollup merge of #125399 - scottmcm:less-hir-in-cg_ssa, r=compiler-errorsLeón Orell Valerian Liehr-1/+1
Stop using `to_hir_binop` in codegen This came up in https://github.com/rust-lang/rust/pull/125359#discussion_r1609401311 , and looking into it we can just use the `mir::BinOp`s directly instead of `hir::BinOpKind`s. (AKA rather than going `mir::BinOp` → `hir::BinOpKind` → `IntPredicate`, just go `mir::BinOp` → `IntPredicate`.)
2024-05-22Auto merge of #125415 - fmease:rollup-n2bg7q5, r=fmeasebors-0/+39
Rollup of 5 pull requests Successful merges: - #124896 (miri: rename intrinsic_fallback_checks_ub to intrinsic_fallback_is_spec) - #125015 (Pattern types: Prohibit generic args on const params) - #125049 (Disallow cast with trailing braced macro in let-else) - #125259 (An async closure may implement `FnMut`/`Fn` if it has no self-borrows) - #125296 (Fix `unexpected_cfgs` lint on std) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-22Rollup merge of #125259 - compiler-errors:fn-mut-as-a-treat, r=oli-obkLeón Orell Valerian Liehr-0/+39
An async closure may implement `FnMut`/`Fn` if it has no self-borrows There's no reason that async closures may not implement `FnMut` or `Fn` if they don't actually borrow anything with the closure's env lifetime. Specifically, #123660 made it so that we don't always need to borrow captures from the closure's env. See the doc comment on `should_reborrow_from_env_of_parent_coroutine_closure`: https://github.com/rust-lang/rust/blob/c00957a3e269219413041a4e3565f33b1f9d0779/compiler/rustc_hir_typeck/src/upvar.rs#L1777-L1823 If there are no such borrows, then we are free to implement `FnMut` and `Fn` as permitted by our closure's inferred `ClosureKind`. As far as I can tell, this change makes `async || {}` work in precisely the set of places they used to work before #120361. Fixes #125247. r? oli-obk
2024-05-22Auto merge of #124686 - saethlin:rust-file-footer, r=fmeasebors-20/+22
Add a footer in FileEncoder and check for it in MemDecoder We have a few reports of ICEs due to decoding failures, where the fault does not lie with the compiler. The goal of this PR is to add some very lightweight and on-by-default validation to the compiler's outputs. If validation fails, we emit a fatal error for rmeta files in general that mentions the path that didn't load, and for incremental compilation artifacts we emit a verbose warning that tries to explain the situation and treat the artifacts as outdated. The validation currently implemented here is very crude, and yet I think we have 11 ICE reports currently open (you can find them by searching issues for `1002111927320821928687967599834759150`) which this simple validation would have detected. The structure of the code changes here should permit the addition of further validation code, such as a checksum, if it is merited. I would like to have code to detect corruption such as reported in https://github.com/rust-lang/rust/issues/124719, but I'm not yet sure how to do that efficiently, and this PR is already a good size. The ICE reports I have in mind that this PR would have smoothed over are: https://github.com/rust-lang/rust/issues/124469 https://github.com/rust-lang/rust/issues/123352 https://github.com/rust-lang/rust/issues/123376 [^1] https://github.com/rust-lang/rust/issues/99763 https://github.com/rust-lang/rust/issues/93900. --- [^1]: This one might be a compiler bug, but even if it is I think the workflow described is pushing the envelope of what we can support. This issue is one of the reasons this warning still asks people to file an issue.
2024-05-22rustc: Use `tcx.used_crates(())` moreVadim Petrochenkov-11/+20
And explain when it should be used.
2024-05-22clarify commentRalf Jung-0/+3
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
2024-05-22Stop using `to_hir_binop` in codegenScott McMurray-1/+1
2024-05-22Auto merge of #125335 - compiler-errors:binder, r=lcnrbors-621/+76
Uplift `Binder`, `OutlivesPredicate` into `rustc_type_ir` Almost done with all the types 🙏 r? lcnr
2024-05-22Auto merge of #125326 - ↵bors-0/+5
weiznich:move/do_not_recommend_to_diganostic_namespace, r=compiler-errors Move `#[do_not_recommend]` to the `#[diagnostic]` namespace This commit moves the `#[do_not_recommend]` attribute to the `#[diagnostic]` namespace. It still requires `#![feature(do_not_recommend)]` to work. r? `@compiler-errors`
2024-05-21PR feedbackBen Kimock-2/+5
2024-05-21Add a footer in FileEncoder and check for it in MemDecoderBen Kimock-20/+19
2024-05-21Uplift OutlivesPredicate, remove a bunch of unnecessary associated types ↵Michael Goulet-39/+16
from Interner
2024-05-21Uplift binderMichael Goulet-582/+60
2024-05-21Rename buffer_lint_with_diagnostic to buffer_lintXiretza-1/+1
2024-05-21Make early lints translatableXiretza-14/+7
2024-05-21Port DeprecatedMacro to diag structsXiretza-85/+103
2024-05-21Generate lint diagnostic message from BuiltinLintDiagXiretza-2/+2
Translation of the lint message happens when the actual diagnostic is created, not when the lint is buffered. Generating the message from BuiltinLintDiag ensures that all required data to construct the message is preserved in the LintBuffer, eventually allowing the messages to be moved to fluent. Remove the `msg` field from BufferedEarlyLint, it is either generated from the data in the BuiltinLintDiag or stored inside BuiltinLintDiag::Normal.
2024-05-21interpret: make overflowing binops just normal binopsRalf Jung-12/+21
2024-05-21Auto merge of #125358 - matthiaskrgr:rollup-mx841tg, r=matthiaskrgrbors-22/+22
Rollup of 7 pull requests Successful merges: - #124570 (Miscellaneous cleanups) - #124772 (Refactor documentation for Apple targets) - #125011 (Add opt-for-size core lib feature flag) - #125218 (Migrate `run-make/no-intermediate-extras` to new `rmake.rs`) - #125225 (Use functions from `crt_externs.h` on iOS/tvOS/watchOS/visionOS) - #125266 (compiler: add simd_ctpop intrinsic) - #125348 (Small fixes to `std::path::absolute` docs) Failed merges: - #125296 (Fix `unexpected_cfgs` lint on std) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-21Move `#[do_not_recommend]` to the `#[diagnostic]` namespaceGeorg Semmler-0/+5
This commit moves the `#[do_not_recommend]` attribute to the `#[diagnostic]` namespace. It still requires `#![feature(do_not_recommend)]` to work.
2024-05-21Rollup merge of #124570 - nnethercote:misc-cleanups, r=michaelwoeristerMatthias Krüger-22/+22
Miscellaneous cleanups A mix of small cleanups made while looking at various things. r? `@wesleywiser`
2024-05-21Auto merge of #124097 - compiler-errors:box-into-iter, r=WaffleLapkinbors-1/+6
Add `IntoIterator` for `Box<[T]>` + edition 2024-specific lints * Adds a similar method probe opt-out mechanism to the `[T;N]: IntoIterator` implementation for edition 2021. * Adjusts the relevant lints (shadowed `.into_iter()` calls, new source of method ambiguity). * Adds some tests. * Took the liberty to rework the logic in the `ARRAY_INTO_ITER` lint, since it was kind of confusing. Based mostly off of #116607. ACP: rust-lang/libs-team#263 References #59878 Tracking for Rust 2024: https://github.com/rust-lang/rust/issues/123759 Crater run was done here: https://github.com/rust-lang/rust/pull/116607#issuecomment-1770293013 Consensus afaict was that there is too much breakage, so let's do this in an edition-dependent way much like `[T; N]: IntoIterator`.
2024-05-21Auto merge of #123812 - compiler-errors:additional-fixes, r=fmeasebors-7/+11
Follow-up fixes to `report_return_mismatched_types` Some renames, simplifications, fixes, etc. Follow-ups to #123804. I don't think it totally disentangles this code, but it does remove some of the worst offenders on the "I am so confused" scale (e.g. `get_node_fn_decl`).
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/+65
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/+47
and make NestedGoals generic