about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2024-04-19Prepare for `CrateNum` query feeding on creationOli Scherer-2/+5
2024-04-19Isolate `CrateNum` creation to `TyCtxt` methodsOli Scherer-0/+10
2024-04-19Move `stable_crate_ids` from `CrateStore` to `Untracked`Oli Scherer-1/+6
This way it's like `Definitions`, which creates `DefId`s by interning `DefPathData`s, but for interning stable crate hashes
2024-04-19ScalarInt: add methods to assert being a (u)int of given sizeRalf Jung-34/+45
2024-04-19coverage. Generate Mappings of decisions and conditions for MC/DCzhuyunxing-5/+124
2024-04-19Auto merge of #117919 - daxpedda:wasm-c-abi, r=wesleywiserbors-1/+15
Introduce perma-unstable `wasm-c-abi` flag Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it. This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`. Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide. This is a companion PR to #117918, but they could be merged independently. MCP: https://github.com/rust-lang/compiler-team/issues/703 Tracking issue: https://github.com/rust-lang/rust/issues/122532
2024-04-18interpret/binary_int_op: avoid dropping to raw ints until we determined the signRalf Jung-18/+35
2024-04-18Fix disabling the export of noop async_drop_in_place_rawDaria Sukhonina-3/+7
2024-04-18Auto merge of #124008 - nnethercote:simpler-static_assert_size, r=Nilstriebbors-18/+18
Simplify `static_assert_size`s. We want to run them on all 64-bit platforms. r? `@ghost`
2024-04-18Simplify `static_assert_size`s.Nicholas Nethercote-18/+18
We want to run them on all 64-bit platforms.
2024-04-17has_typeck_results doesnt need to be a queryMichael Goulet-4/+11
2024-04-17Use non-exhaustive matches for TyKindDaria Sukhonina-93/+77
Also no longer export noop async_drop_in_place_raw
2024-04-17Rename `BindingAnnotation` to `BindingMode`Jules Bertholet-23/+14
2024-04-17consistency rename: language item -> lang itemRalf Jung-1/+1
2024-04-17Rollup merge of #122813 - nnethercote:nicer-quals, r=compiler-errorsMatthias Krüger-63/+58
Qualifier tweaking Adding and removing qualifiers in some cases that make things nicer. Details in individual commits. r? `@compiler-errors`
2024-04-16Rollup merge of #124016 - DaniPopes:dedup-default-providers, r=lcnrGuillaume Gomez-23/+28
Outline default query and hook provider function implementations The default query and hook provider functions call `bug!` with a decently long message. Due to argument inlining in `format_args!` ([`flatten_format_args`](https://github.com/rust-lang/rust/issues/78356)), this ends up duplicating the message for each query, adding ~90KB to `librustc_driver.so` of unreachable panic messages. To avoid this, we can outline the common `bug!` logic.
2024-04-16Add simple async drop glue generationzetanumbers-9/+290
Explainer: https://zetanumbers.github.io/book/async-drop-design.html https://github.com/rust-lang/rust/pull/121801
2024-04-16Outline default query and hook provider function implementationsDaniPopes-23/+28
2024-04-16Auto merge of #124015 - GuillaumeGomez:rollup-s46ksxa, r=GuillaumeGomezbors-16/+7
Rollup of 14 pull requests Successful merges: - #120781 (Correct usage note on OpenOptions::append()) - #121694 (sess: stabilize `-Zrelro-level` as `-Crelro-level`) - #122521 (doc(bootstrap): add top-level doc-comment to utils/tarball.rs) - #123491 (Fix ICE in `eval_body_using_ecx`) - #123574 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 6)) - #123687 (Update ar_archive_writer to 0.2.0) - #123721 (Various visionOS fixes) - #123797 (Better graphviz output for SCCs and NLL constraints) - #123990 (Make `suggest_deref_closure_return` more idiomatic/easier to understand) - #123995 (Make `thir_tree` and `thir_flat` into hooks) - #123998 (Opaque types have no namespace) - #124001 (Fix docs for unstable_features lint.) - #124006 (Move size assertions for `mir::syntax` types into the same file) - #124011 (rustdoc: update the module-level docs of `rustdoc::clean`) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-16Rollup merge of #124006 - Zalathar:static-assert, r=nnethercoteGuillaume Gomez-2/+1
Move size assertions for `mir::syntax` types into the same file A redundant size assertion for `StatementKind` was added in #122937, because the existing assertion was in a different file. This PR cleans that up, and also moves the `TerminatorKind` assertion into the same file where it belongs, to avoid the same thing happening again. r? `@nnethercote`
2024-04-16Rollup merge of #123995 - compiler-errors:thir-hooks, r=oli-obkGuillaume Gomez-14/+6
Make `thir_tree` and `thir_flat` into hooks No need for them to be queries, since they are only called with `-Zunpretty`
2024-04-16Auto merge of #123468 - compiler-errors:precise-capturing, r=oli-obkbors-0/+2
Implement syntax for `impl Trait` to specify its captures explicitly (`feature(precise_capturing)`) Implements `impl use<'a, 'b, T, U> Sized` syntax that allows users to explicitly list the captured parameters for an opaque, rather than inferring it from the opaque's bounds (or capturing *all* lifetimes under 2024-edition capture rules). This allows us to exclude some implicit captures, so this syntax may be used as a migration strategy for changes due to #117587. We represent this list of captured params as `PreciseCapturingArg` in AST and HIR, resolving them between `rustc_resolve` and `resolve_bound_vars`. Later on, we validate that the opaques only capture the parameters in this list. We artificially limit the feature to *require* mentioning all type and const parameters, since we don't currently have support for non-lifetime bivariant generics. This can be relaxed in the future. We also may need to limit this to require naming *all* lifetime parameters for RPITIT, since GATs have no variance. I have to investigate this. This can also be relaxed in the future. r? `@oli-obk` Tracking issue: - https://github.com/rust-lang/rust/issues/123432
2024-04-16Avoid lots of `hir::HirId{,Map,Set}` qualifiers.Nicholas Nethercote-63/+58
Because they're a bit redundant.
2024-04-16Move size assertions for `mir::syntax` types into the same fileZalathar-2/+1
A redundant size assertion for `StatementKind` was added in #122937, because the existing assertion was in a different file. This patch cleans that up, and also moves the `TerminatorKind` assertion into the same file where it belongs, to avoid the same thing happening again.
2024-04-15Make thir_tree and thir_flat into hooksMichael Goulet-14/+6
2024-04-15Do check_coroutine_obligations once per typeck rootMichael Goulet-6/+3
2024-04-15Rename coroutine_stalled_predicatesMichael Goulet-2/+2
2024-04-16Rollup merge of #123989 - compiler-errors:type-dependent-def-id, r=oli-obkLeón Orell Valerian Liehr-3/+0
Just use `type_dependent_def_id` to figure out what the method is for an expr The calls to `lookup_method_for_diagnostic` are overkill. r? oli-obk
2024-04-16Rollup merge of #123926 - compiler-errors:no-ann, r=estebankLeón Orell Valerian Liehr-0/+7
Fix pretty HIR for anon consts in diagnostics This removes the `NoAnn` printer which skips over nested bodies altogether, which is confusing, and requires users of `{ty|qpath|pat}_to_string` to pass in `&tcx` which now impleemnts `hir_pretty::PpAnn`. There's one case where this "regresses" by actually printing out the body of the anon const -- we could suppress that, but I don't expect people to actually get anon consts like that unless they're fuzzing, tbh. r? estebank
2024-04-16Rollup merge of #123603 - compiler-errors:no-intrinsic, r=estebankLeón Orell Valerian Liehr-3/+8
Don't even parse an intrinsic unless the feature gate is enabled Don't return true in `tcx.is_intrinsic` if the function is defined locally and `#![feature(intrinsics)]` is not enabled. This is a slightly more general fix than #123526, since #123587 shows that we have simplifying assumptions about intrinsics elsewhere in the compiler. This will make the code ICE again if the user **enables** `#[feature(intrinsics)]`, but I kind of feel like if we want to fix that, we should make the `INTERNAL_FEATURES` lint `Deny` again. Perhaps we could do that on non-nightly compilers. Or we should just stop compilation altogether if they have `#![feature]` enabled on a non-nightly compiler. As for the UX of *real* cases of hitting these ICEs, I believe pretty strongly that if a compiler/stdlib dev is modifying internal intrinsics (intentionally, like when making a change to rustc) we have no guarantee to make the ICE better looking for them. Honestly, *not* spitting out a stack trace is probably a disservice to the people who hit those ICEs in that case. r? `@Nilstrieb` `@estebank`
2024-04-16Rollup merge of #123016 - compiler-errors:no-type-var-origin, r=lcnrLeón Orell Valerian Liehr-10/+4
Remove `TypeVariableOriginKind` and `ConstVariableOriginKind` It's annoying to have to import `TypeVariableOriginKind` just to fill it with `MiscVariable` for almost every use. Every other usage other than `TypeParameterDefinition` wasn't even used -- I can see how it may have been useful once for debugging, but I do quite a lot of typeck debugging and I've never really needed it. So let's just remove it, and keep around the only useful thing which is the `DefId` of the param for `var_for_def`. This is based on #123006, which removed the special use of `TypeVariableOriginKind::OpaqueInference`, which I'm pretty sure I was the one that added. r? lcnr or re-roll to types
2024-04-15Fix pretty hir for anon consts in diagnosticsMichael Goulet-0/+7
2024-04-15Just use type_dependent_def_id to figure out what the method is for an exprMichael Goulet-3/+0
2024-04-15nitsMichael Goulet-1/+3
2024-04-15Remove ConstVariableOriginKindMichael Goulet-10/+2
2024-04-15Add hir::Node::PreciseCapturingNonLifetimeArgMichael Goulet-0/+2
2024-04-15Rollup merge of #123900 - compiler-errors:nobound, r=lcnrMichael Goulet-3/+2
Stop using `PolyTraitRef` for closure/coroutine predicates already instantiated w placeholders r? lcnr
2024-04-15Rollup merge of #123934 - WaffleLapkin:graph-mini-refactor, r=fmease许杰友 Jieyou Xu (Joe)-20/+8
`rustc_data_structures::graph` mini refactor Who doesn't love to breathe dust from the ancient times?
2024-04-15Stop using PolyTraitRef for closure/coroutine predicates already ↵Michael Goulet-3/+2
instantiated w placeholders
2024-04-15Use RPITIT for `Successors` and `Predecessors` traitsMaybe Waffle-7/+3
Now with RPITIT instead of GAT!
2024-04-14Rename `WithNumEdges` => `NumEdges` and `WithStartNode` => `StartNode`Maybe Waffle-3/+3
2024-04-14Merge `{With,Graph}{Successors,Predecessors}` into `{Successors,Predecessors}`Maybe Waffle-15/+9
Now with GAT!
2024-04-14Merge `WithNumNodes` into DirectedGraphMaybe Waffle-4/+2
2024-04-13Rollup merge of #123890 - klensy:cl, r=fee1-deadMatthias Krüger-45/+0
removed (mostly) unused code First commit removes unused code, second one - some old debug output, probably unused?
2024-04-13remove some ancient debug output, looks unused?klensy-15/+0
2024-04-12Rollup merge of #123834 - compiler-errors:async-closure-with-tainted-body, ↵Matthias Krüger-1/+1
r=oli-obk Don't do coroutine-closure-specific upvar analysis if tainted by errors See the comment Fixes #123821 Fixes #123818
2024-04-12Don't do coroutine-closure-specific upvar analysis if tainted by errorsMichael Goulet-1/+1
2024-04-12remove dead codeklensy-30/+0
2024-04-12Rollup merge of #123789 - klensy:rq, r=cjgillotMatthias Krüger-12/+0
move QueryKeyStringCache from rustc_middle to rustc_query_impl, where it actually used Also allows to drop measureme dep on rustc_middle.
2024-04-11Rollup merge of #123660 - compiler-errors:coroutine-closure-env, r=oli-obkMatthias Krüger-3/+71
Make the computation of `coroutine_captures_by_ref_ty` more sophisticated Currently, we treat all the by-(mut/)ref borrows of a coroutine-closure as having a "closure env" borrowed lifetime. When we have the given code: ```rust let x: &'a i32 = ...; let c = async || { let _x = *x; }; ``` Then when we call: ```rust c() // which, because `AsyncFn` takes a `&self`, we insert an autoref: (&c /* &'env {coroutine-closure} */)() ``` We will return a future whose captures contain `&'env i32` instead of `&'a i32`, which is way more restrictive than necessary. We should be able to drop `c` while the future is alive since it's not actually borrowing any data *originating from within* the closure's captures, but since the capture has that `'env` lifetime, this is not possible. This wouldn't be true, for example, if the closure captured `i32` instead of `&'a i32`, because the `'env` lifetime is actually *necessary* since the data (`i32`) is owned by the closure. This PR identifies two criteria where we *need* to take the borrow with the closure env lifetime: 1. If the closure borrows data from inside the closure's captures. This is not true if the parent capture is by-ref, OR if the parent capture is by-move and the child capture begins with a deref projection. This is the example described above. 2. If we're dealing with mutable references, since we cannot reborrow `&'env mut &'a mut i32` into `&'a mut i32`, *only* `&'env mut i32`. See the documentation on `should_reborrow_from_env_of_parent_coroutine_closure` for more info. **important:** As disclaimer states on that function, luckily, if this heuristic is not correct, then the program is not unsound, since we still borrowck and validate the choices made from this function -- the only side-effect is that the user may receive unnecessary borrowck errors. Fixes #123241