about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2024-04-23Auto merge of #124277 - matthiaskrgr:rollup-zdb93i4, r=matthiaskrgrbors-21/+82
Rollup of 7 pull requests Successful merges: - #123680 (Deny gen keyword in `edition_2024_compat` lints) - #124057 (Fix ICE when ADT tail has type error) - #124168 (Use `DefiningOpaqueTypes::Yes` in rustdoc, where the `InferCtxt` is guaranteed to have no opaque types it can define) - #124197 (Move duplicated code in functions in `tests/rustdoc-gui/notable-trait.goml`) - #124200 (Improve handling of expr->field errors) - #124220 (Miri: detect wrong vtables in wide pointers) - #124266 (remove an unused type from the reentrant lock tests) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-23Rollup merge of #124220 - RalfJung:interpret-wrong-vtable, r=oli-obkMatthias Krüger-21/+78
Miri: detect wrong vtables in wide pointers Fixes https://github.com/rust-lang/miri/issues/3497. Needed to catch the UB that https://github.com/rust-lang/rust/pull/123572 will start exploiting. r? `@oli-obk`
2024-04-23Rollup merge of #124057 - gurry:124031-ice-layout-errored, r=compiler-errorsMatthias Krüger-0/+4
Fix ICE when ADT tail has type error Fixes #124031
2024-04-23Auto merge of #123992 - compiler-errors:no-has-typeck-results, r=jackh726bors-4/+11
`has_typeck_results` doesnt need to be a query self-explanatory
2024-04-23Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obkbors-10/+279
Add simple async drop glue generation This is a prototype of the async drop glue generation for some simple types. Async drop glue is intended to behave very similar to the regular drop glue except for being asynchronous. Currently it does not execute synchronous drops but only calls user implementations of `AsyncDrop::async_drop` associative function and awaits the returned future. It is not complete as it only recurses into arrays, slices, tuples, and structs and does not have same sensible restrictions as the old `Drop` trait implementation like having the same bounds as the type definition, while code assumes their existence (requires a future work). This current design uses a workaround as it does not create any custom async destructor state machine types for ADTs, but instead uses types defined in the std library called future combinators (deferred_async_drop, chain, ready_unit). Also I recommend reading my [explainer](https://zetanumbers.github.io/book/async-drop-design.html). This is a part of the [MCP: Low level components for async drop](https://github.com/rust-lang/compiler-team/issues/727) work. Feature completeness: - [x] `AsyncDrop` trait - [ ] `async_drop_in_place_raw`/async drop glue generation support for - [x] Trivially destructible types (integers, bools, floats, string slices, pointers, references, etc.) - [x] Arrays and slices (array pointer is unsized into slice pointer) - [x] ADTs (enums, structs, unions) - [x] tuple-like types (tuples, closures) - [ ] Dynamic types (`dyn Trait`, see explainer's [proposed design](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#async-drop-glue-for-dyn-trait)) - [ ] coroutines (https://github.com/rust-lang/rust/pull/123948) - [x] Async drop glue includes sync drop glue code - [x] Cleanup branch generation for `async_drop_in_place_raw` - [ ] Union rejects non-trivially async destructible fields - [ ] `AsyncDrop` implementation requires same bounds as type definition - [ ] Skip trivially destructible fields (optimization) - [ ] New [`TyKind::AdtAsyncDestructor`](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#adt-async-destructor-types) and get rid of combinators - [ ] [Synchronously undroppable types](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#exclusively-async-drop) - [ ] Automatic async drop at the end of the scope in async context
2024-04-22Rollup merge of #124230 - reitermarkus:generic-nonzero-stable, r=dtolnayGuillaume Gomez-1/+0
Stabilize generic `NonZero`. Tracking issue: https://github.com/rust-lang/rust/issues/120257 r? `@dtolnay`
2024-04-22Rollup merge of #124217 - Zalathar:pre-branch, r=oli-obkGuillaume Gomez-2/+4
coverage: Prepare for improved branch coverage When trying to rebase my new branch coverage work (including #124154) on top of the introduction of MC/DC coverage (#123409), I found it a lot harder than anticipated. With the benefit of hindsight, the branch coverage code and MC/DC code have become more interdependent than I'm happy with. This PR therefore disentangles them a bit, so that it will be easier for both areas of code to evolve independently without interference. --- This PR also includes a few extra branch coverage tests that I had sitting around from my current branch coverage work. They mostly just demonstrate that certain language constructs listed in #124118 currently don't have branch coverage support. ``@rustbot`` label +A-code-coverage
2024-04-22Rollup merge of #124183 - compiler-errors:unnecessary-by-ref, r=oli-obkGuillaume Gomez-11/+11
Stop taking `ParamTy`/`ParamConst`/`EarlyParamRegion`/`AliasTy` by ref It's unnecessary and is annoying when we have it by value.
2024-04-22Stabilize generic `NonZero`.Markus Reiter-1/+0
2024-04-23Wrap dyn type with parentheses in suggestionlong-long-float-17/+22
2024-04-22Stabilize the size of incr comp object file namesBen Kimock-6/+5
2024-04-22Fix typo in the has_surface_drop's doc commentDaria Sukhonina-1/+1
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2024-04-22coverage: Detach MC/DC branch spans from regular branch spansZalathar-2/+4
MC/DC's reliance on the existing branch coverage types is making it much harder to improve branch coverage.
2024-04-22Fix ICE when ADT tail has type errorGurinder Singh-0/+4
2024-04-21Add `AggregateKind::RawPtr` and enough support to compileScott McMurray-0/+28
2024-04-21Miri: detect wrong vtables in wide pointersRalf Jung-21/+78
2024-04-20Fix documentation of `BorrowKind::Fake`Nadrieril-3/+3
2024-04-20Add a non-shallow fake borrowNadrieril-16/+70
2024-04-20Rework fake borrow calculationNadrieril-0/+5
2024-04-20Address closure-related reviewNadrieril-1/+1
2024-04-20Track mutability of deref patternsNadrieril-3/+4
2024-04-20Auto merge of #124190 - RalfJung:pat-compare-with-fast-path, r=Nadrierilbors-5/+8
PatRangeBoundary::compare_with: als add a fast-path for signed integers Not sure if we have a benchmark that hits this... but it seems odd to only do this for unsigned integers.
2024-04-20Rollup merge of #123409 - ZhuUx:master, r=oli-obkMatthias Krüger-5/+128
Implement Modified Condition/Decision Coverage This is an implementation based on llvm backend support (>= 18) by `@evodius96` and branch coverage support by `@Zalathar.` ### Major changes: * Add -Zcoverage-options=mcdc as switch. Now coverage options accept either `no-branch`, `branch`, or `mcdc`. `mcdc` also enables `branch` because it is essential to work. * Add coverage mapping for MCDCBranch and MCDCDecision. Note that MCDCParameter evolves from llvm 18 to llvm 19. The mapping in rust side mainly references to 19 and is casted to 18 types in llvm wrapper. * Add wrapper for mcdc instrinc functions from llvm. And inject associated statements to mir. * Add BcbMappingKind::Decision, I'm not sure is it proper but can't find a better way temporarily. * Let coverage-dump support parsing MCDCBranch and MCDCDecision from llvm ir. * Add simple tests to check whether mcdc works. * Same as clang, currently rustc does not generate instrument for decision with more than 6 condtions or only 1 condition due to considerations of resource. ### Implementation Details 1. To get information about conditions and decisions, `MCDCState` in `BranchInfoBuilder` is used during hir lowering to mir. For expressions with logical op we call `Builder::visit_coverage_branch_operation` to record its sub conditions, generate condition ids for them and save their spans (to construct the span of whole decision). This process mainly references to the implementation in clang and is described in comments over `MCDCState::record_conditions`. Also true marks and false marks introduced by branch coverage are used to detect where the decision evaluation ends: the next id of the condition == 0. 2. Once the `MCDCState::decision_stack` popped all recorded conditions, we can ensure that the decision is checked over and push it into `decision_spans`. We do not manually insert decision span to avoid complexity from then_else_break in nested if scopes. 3. When constructing CoverageSpans, add condition info to BcbMappingKind::Branch and decision info to BcbMappingKind::Decision. If the branch mapping has non-zero condition id it will be transformed to MCDCBranch mapping and insert `CondBitmapUpdate` statements to its evaluated blocks. While decision bcb mapping will insert `TestVectorBitmapUpdate` in all its end blocks. ### Usage ```bash echo "[build]\nprofiler=true" >> config.toml ./x build --stage 1 ./x test tests/coverage/mcdc_if.rs ``` to build the compiler and run tests. ```shell export PATH=path/to/llvm-build:$PATH rustup toolchain link mcdc build/host/stage1 cargo +mcdc rustc --bin foo -- -Cinstrument-coverage -Zcoverage-options=mcdc cd target/debug LLVM_PROFILE_FILE="foo.profraw" ./foo llvm-profdata merge -sparse foo.profraw -o foo.profdata llvm-cov show ./foo -instr-profile=foo.profdata --show-mcdc ``` to check "foo" code. ### Problems to solve For now decision mapping will insert statements to its all end blocks, which may be optimized by inserting a final block of the decision. To do this we must also trace the evaluated value at each end of the decision and join them separately. This implementation is not heavily tested so there should be some unrevealed issues. We are going to check our rust products in the next. Please let me know if you had any suggestions or comments.
2024-04-20PatRangeBoundary::compare_with: als add a fast-path for signed integersRalf Jung-5/+8
2024-04-19Stop taking ParamTy/ParamConst/EarlyParamRegion/AliasTy by refMichael Goulet-11/+11
2024-04-19Auto merge of #124113 - RalfJung:interpret-scalar-ops, r=oli-obkbors-63/+102
interpret: use ScalarInt for bin-ops; avoid PartialOrd for ScalarInt Best reviewed commit-by-commit r? `@oli-obk`
2024-04-20coverage. Lowering MC/DC statements to llvm-irzhuyunxing-0/+4
2024-04-19avoid PartialOrd on ScalarIntRalf Jung-13/+24
we don't know their sign so we cannot, in general, order them properly
2024-04-19Remove `feed_local_crate` in favor of creating the `CrateNum` via `TyCtxt`Oli Scherer-7/+0
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`