about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2024-03-27Stop doing expensive work in opt_suggest_box_span eagerlyMichael Goulet-2/+4
2024-03-27Remove `Partial/Ord` from `EarlyParamRegion`Oli Scherer-1/+1
2024-03-27Remove `Partial/Ord` from `AdtDef`Oli Scherer-16/+1
2024-03-27Remove `Partial/Ord` from `BoundRegion`Oli Scherer-12/+10
2024-03-27Remove `Ord` from `BoundTy`Oli Scherer-3/+3
2024-03-27Remove `Ord` from `Binder`Oli Scherer-1/+1
2024-03-27Remove `Ord` from `Ty`, `Const`, and `Region`Oli Scherer-30/+21
2024-03-27Implement `mut ref`/`mut ref mut`Jules Bertholet-72/+38
2024-03-27Eliminate `UbCheck` for non-standard librariesDianQK-2/+2
2024-03-27Use a `dyn Debug` trait object instead of a closure.Oli Scherer-11/+22
Simplifies the API a bit.
2024-03-27Add a `CurrentGcx` type to let the deadlock handler access `TyCtxt`John Kåre Alsaker-3/+54
2024-03-27Rollup merge of #123021 - compiler-errors:coroutine-layout-lol, r=oli-obkGuillaume Gomez-6/+41
Make `TyCtxt::coroutine_layout` take coroutine's kind parameter For coroutines that come from coroutine-closures (i.e. async closures), we may have two kinds of bodies stored in the coroutine; one that takes the closure's captures by reference, and one that takes the captures by move. These currently have identical layouts, but if we do any optimization for these layouts that are related to the upvars, then they will diverge -- e.g. https://github.com/rust-lang/rust/pull/120168#discussion_r1536943728. This PR relaxes the assertion I added in #121122, and instead make the `TyCtxt::coroutine_layout` method take the `coroutine_kind_ty` argument from the coroutine, which will allow us to differentiate these by-move and by-ref bodies.
2024-03-27Make `def_path_hash_to_def_id` a hookOli Scherer-5/+9
2024-03-27Move `CrateStore::expn_hash_to_expn_id` to a hookOli Scherer-7/+8
2024-03-27Start replacing `CStore` trait methods with hooks.Oli Scherer-6/+9
This also avoids the cyclic definition issues with CrateStore being defined after TyCtxt, but needing to be used in TyCtxt.
2024-03-26Rollup merge of #122835 - compiler-errors:deref-pure, r=NadrierilMatthias Krüger-0/+25
Require `DerefMut` and `DerefPure` on `deref!()` patterns when appropriate Waiting on the deref pattern syntax pr to merge r? nadrieril
2024-03-26Remove `CacheSelector` trait now that we can use GATsOli Scherer-59/+56
2024-03-26ignore uncaptured lifetimes when checking opaquesAli MJ Al-Nasrawy-0/+32
2024-03-26Auto merge of #123065 - workingjubilee:rollup-bve45ex, r=workingjubileebors-9/+17
Rollup of 10 pull requests Successful merges: - #122707 (Fix a typo in the alloc::string::String docs) - #122769 (extend comments for reachability set computation) - #122892 (fix(bootstrap/dist): use versioned dirs when vendoring) - #122896 (Update stdarch submodule) - #122923 (In `pretty_print_type()`, print `async fn` futures' paths instead of spans.) - #122950 (Add regression tests for #101903) - #123039 (Update books) - #123042 (Import the 2021 prelude in the core crate) - #123044 (`Instance` is `Copy`) - #123051 (did I mention that tests are super cool? ) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-26Auto merge of #111769 - saethlin:ctfe-backtrace-ctrlc, r=RalfJungbors-0/+2
Print a backtrace in const eval if interrupted Demo: ```rust #![feature(const_eval_limit)] #![const_eval_limit = "0"] const OW: u64 = { let mut res: u64 = 0; let mut i = 0; while i < u64::MAX { res = res.wrapping_add(i); i += 1; } res }; fn main() { println!("{}", OW); } ``` ``` ╭ ➜ ben@archlinux:~/rust ╰ ➤ rustc +stage1 spin.rs ^Cerror[E0080]: evaluation of constant value failed --> spin.rs:8:33 | 8 | res = res.wrapping_add(i); | ^ Compilation was interrupted note: erroneous constant used --> spin.rs:15:20 | 15 | println!("{}", OW); | ^^ note: erroneous constant used --> spin.rs:15:20 | 15 | println!("{}", OW); | ^^ | = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. ```
2024-03-25Extract helper, fix comment on DerefPureMichael Goulet-0/+25
2024-03-25Rollup merge of #123044 - compiler-errors:instance, r=oli-obkJubilee-4/+4
`Instance` is `Copy` No reason to take it by value; it was confusing ``@rcvalle`` to see it being mutated when it's also being passed by ref in some places.
2024-03-25Instance is CopyMichael Goulet-4/+4
2024-03-25In `pretty_print_type()`, print `async fn` futures' paths instead of spans.Kevin Reid-5/+13
This makes `-Zprint-type-sizes`'s output easier to read, because the name of an `async fn` is more immediately recognizable than its span. I also deleted the comment "FIXME(eddyb) should use `def_span`." because it appears to have already been fixed by commit 67727aa7c31a24ea73a91a9134c3653fae8209ab.
2024-03-25Auto merge of #122721 - oli-obk:merge_queries, r=davidtwcobors-11/+11
Replace `mir_built` query with a hook and use mir_const everywhere instead A small perf improvement due to less dep graph handling. Mostly just a cleanup to get rid of one of our many mir queries
2024-03-24Relax validation nowMichael Goulet-2/+0
2024-03-24Require coroutine kind type to be passed to TyCtxt::coroutine_layoutMichael Goulet-6/+43
2024-03-24Address PR feedbackScott McMurray-0/+8
2024-03-24Rollup merge of #122937 - Zalathar:unbox, r=oli-obkMatthias Krüger-12/+7
Unbox and unwrap the contents of `StatementKind::Coverage` The payload of coverage statements was historically a structure with several fields, so it was boxed to avoid bloating `StatementKind`. Now that the payload is a single relatively-small enum, we can replace `Box<Coverage>` with just `CoverageKind`. This patch also adds a size assertion for `StatementKind`, to avoid accidentally bloating it in the future. ``@rustbot`` label +A-code-coverage
2024-03-23Add+Use `mir::BinOp::Cmp`Scott McMurray-1/+16
2024-03-23Auto merge of #122629 - RalfJung:assert-unsafe-precondition, r=saethlinbors-13/+6
refactor check_{lang,library}_ub: use a single intrinsic This enacts the plan I laid out [here](https://github.com/rust-lang/rust/pull/122282#issuecomment-1996917998): use a single intrinsic, called `ub_checks` (in aniticpation of https://github.com/rust-lang/compiler-team/issues/725), that just exposes the value of `debug_assertions` (consistently implemented in both codegen and the interpreter). Put the language vs library UB logic into the library. This makes it easier to do something like https://github.com/rust-lang/rust/pull/122282 in the future: that just slightly alters the semantics of `ub_checks` (making it more approximating when crates built with different flags are mixed), but it no longer affects whether these checks can happen in Miri or compile-time. The first commit just moves things around; I don't think these macros and functions belong into `intrinsics.rs` as they are not intrinsics. r? `@saethlin`
2024-03-23refactor check_{lang,library}_ub: use a single intrinsic, put policy into ↵Ralf Jung-13/+6
library
2024-03-23Rollup merge of #122780 - GuillaumeGomez:rename-hir-local, r=oli-obkMatthias Krüger-3/+3
Rename `hir::Local` into `hir::LetStmt` Follow-up of #122776. As discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Improve.20naming.20of.20.60ExprKind.3A.3ALet.60.3F). I made this change into a separate PR because I'm less sure about this change as is. For example, we have `visit_local` and `LocalSource` items. Is it fine to keep these two as is (I supposed it is but I prefer to ask) or not? Having `Node::Local(LetStmt)` makes things more explicit but is it going too far? r? ```@oli-obk```
2024-03-23rename MIR int2ptr casts to match library nameRalf Jung-3/+3
2024-03-23rename ptr::from_exposed_addr -> ptr::with_exposed_provenanceRalf Jung-1/+1
2024-03-23Unbox and unwrap the contents of `StatementKind::Coverage`Zalathar-12/+7
The payload of coverage statements was historically a structure with several fields, so it was boxed to avoid bloating `StatementKind`. Now that the payload is a single relatively-small enum, we can replace `Box<Coverage>` with just `CoverageKind`. This patch also adds a size assertion for `StatementKind`, to avoid accidentally bloating it in the future.
2024-03-22Auto merge of #122900 - matthiaskrgr:rollup-nls90mb, r=matthiaskrgrbors-35/+77
Rollup of 8 pull requests Successful merges: - #114009 (compiler: allow transmute of ZST arrays with generics) - #122195 (Note that the caller chooses a type for type param) - #122651 (Suggest `_` for missing generic arguments in turbofish) - #122784 (Add `tag_for_variant` query) - #122839 (Split out `PredicatePolarity` from `ImplPolarity`) - #122873 (Merge my contributor emails into one using mailmap) - #122885 (Adjust better spastorino membership to triagebot's adhoc_groups) - #122888 (add a couple more tests) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-22Auto merge of #122852 - compiler-errors:raw-ptr, r=lcnrbors-76/+79
Remove `TypeAndMut` from `ty::RawPtr` variant, make it take `Ty` and `Mutability` Pretty much mechanically converting `ty::RawPtr(ty::TypeAndMut { ty, mutbl })` to `ty::RawPtr(ty, mutbl)` and its fallout. r? lcnr cc rust-lang/types-team#124
2024-03-22Rename `hir::Node::Local` into `hir::Node::LetStmt`Guillaume Gomez-3/+3
2024-03-22Rollup merge of #122839 - compiler-errors:predicate-polarity, r=lcnrMatthias Krüger-34/+54
Split out `PredicatePolarity` from `ImplPolarity` Because having to deal with a third `Reservation` level in all the trait solver code is kind of weird. r? `@lcnr` or `@oli-obk`
2024-03-22Rollup merge of #122784 - jswrenn:tag_for_variant, r=compiler-errorsMatthias Krüger-0/+17
Add `tag_for_variant` query This query allows for sharing code between `rustc_const_eval` and `rustc_transmutability`. It's a precursor to a PR I'm working on to entirely replace the bespoke layout computations in `rustc_transmutability`. r? `@compiler-errors`
2024-03-22Rollup merge of #114009 - dvdhrm:pr/transmzst, r=pnkfelixMatthias Krüger-1/+6
compiler: allow transmute of ZST arrays with generics Extend the `SizeSkeleton` evaluator to shortcut zero-sized arrays, thus considering `[T; 0]` to have a compile-time fixed-size of 0. The existing evaluator already deals with generic arrays under the feature-guard `transmute_const_generics`. However, it merely allows comparing fixed-size types with fixed-size types, and generic types with generic types. For generic types, it merely compares whether their arguments match (ordering them first). Even if their exact sizes are not known at compile time, it can ensure that they will eventually be the same. This patch extends this by shortcutting the size-evaluation of zero sized arrays and thus allowing size comparisons of `()` with `[T; 0]`, where one contains generics and the other does not. This code is guarded by `transmute_const_generics` (#109929), even though it is unclear whether it should be. However, this assumes that a separate stabilization PR is required to move this out of the feature guard. Initially reported in #98104.
2024-03-22Add `tag_for_variant` queryJack Wrenn-0/+17
This query allows for sharing code between `rustc_const_eval` and `rustc_transmutability`. Also moves `DummyMachine` to `rustc_const_eval`.
2024-03-22Auto merge of #122580 - saethlin:compiler-builtins-can-panic, r=pnkfelixbors-0/+6
"Handle" calls to upstream monomorphizations in compiler_builtins This is pretty cooked, but I think it works. compiler-builtins has a long-standing problem that at link time, its rlib cannot contain any calls to `core`. And yet, in codegen we _love_ inserting calls to symbols in `core`, generally from various panic entrypoints. I intend this PR to attack that problem as completely as possible. When we generate a function call, we now check if we are generating a function call from `compiler_builtins` and whether the callee is a function which was not lowered in the current crate, meaning we will have to link to it. If those conditions are met, actually generating the call is asking for a linker error. So we don't. If the callee diverges, we lower to an abort with the same behavior as `core::intrinsics::abort`. If the callee does not diverge, we produce an error. This means that compiler-builtins can contain panics, but they'll SIGILL instead of panicking. I made non-diverging calls a compile error because I'm guessing that they'd mostly get into compiler-builtins by someone making a mistake while working on the crate, and compile errors are better than linker errors. We could turn such calls into aborts as well if that's preferred.
2024-03-22Further simplificationsMichael Goulet-36/+5
2024-03-22Split out ImplPolarity and PredicatePolarityMichael Goulet-22/+73
2024-03-22Make RawPtr take Ty and Mutbl separatelyMichael Goulet-22/+20
2024-03-22Programmatically convert some of the pat ctorsMichael Goulet-20/+17
2024-03-22Ty::new_ref and Ty::new_ptr stop using TypeAndMutMichael Goulet-12/+17
2024-03-22Remove TypeAndMut from relateMichael Goulet-29/+32