about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2024-04-21Auto merge of #124241 - matthiaskrgr:rollup-xhu90xr, r=matthiaskrgrbors-10/+235
Rollup of 5 pull requests Successful merges: - #123840 (Add an intrinsic for `ptr::from_raw_parts(_mut)`) - #124224 (cleanup: unnecessary clone during lower generics args) - #124229 (Add gnullvm targets to manifest) - #124231 (remove from reviewers) - #124235 (Move some tests) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-21Rollup merge of #124224 - bvanjoi:cleanup, r=fmeaseMatthias Krüger-2/+2
cleanup: unnecessary clone during lower generics args
2024-04-21Rollup merge of #123840 - scottmcm:aggregate-kind-rawptr, r=cjgillotMatthias Krüger-8/+233
Add an intrinsic for `ptr::from_raw_parts(_mut)` Fixes #123174 cc `@CAD97` `@saethlin` r? `@cjgillot` As suggested in https://github.com/rust-lang/rust/pull/123190#issuecomment-2028717967, this adds a new `AggregateKind::RawPtr` for creating a pointer from its data pointer and its metadata. That means that `slice::from_raw_parts` and friends no longer need to hard-code pointer layout into `libcore`, and because it no longer does union hacks the MIR is shorter and more amenable to optimizations.
2024-04-21Auto merge of #124203 - lukas-code:delete-deleting-caches, r=compiler-errorsbors-29/+21
fix normalizing in different `ParamEnv`s with the same `InferCtxt` This PR changes the key of the projection cache from just `AliasTy` to `(AliasTy, ParamEnv)` to allow normalizing in different `ParamEnv`s without resetting caches. Previously, normalizing the same alias in different param envs would always reuse the cached result from the first normalization, which is incorrect if the projection clauses in the param env have changed. Fixing this bug allows us to get rid of `InferCtxt::clear_caches`, which was only used by the `AutoTraitFinder`, because it requires normalizing in different param envs. r? `@fmease`
2024-04-21Address more PR feedbackScott McMurray-3/+3
2024-04-21Address PR feedbackScott McMurray-15/+12
2024-04-21Also handle AggregateKind::RawPtr in cg_craneliftScott McMurray-0/+30
2024-04-21InstSimplify `from_raw_parts(p, ())` → `p as _`Scott McMurray-1/+35
2024-04-21Use it in the library, and `InstSimplify` it away in the easy placesScott McMurray-2/+48
2024-04-21Add an intrinsic that lowers to AggregateKind::RawPtrScott McMurray-1/+38
2024-04-21Add `AggregateKind::RawPtr` and enough support to compileScott McMurray-3/+84
2024-04-21Auto merge of #123594 - Urgau:fix-non_local_def-lint-overflow, r=lcnrbors-1/+13
Fix trait solver overflow with `non_local_definitions` lint This PR fixes the trait solver overflow with the `non_local_definitions` lint reported in https://github.com/rust-lang/rust/issues/123573 using the suggestion from `@lcnr:` https://github.com/rust-lang/rust/issues/123573#issuecomment-2041348320 to use the next trait solver. ~~I have not (yet) tried to create a minimized repro~~ ``@compiler-errors`` did the minimization (thanks you) but I have manually tested on the `starlark-rust` project that it fixes the issue. Fixes #123573 r? `@lcnr`
2024-04-21also remap RPITITs nested in other types back to their opaquesLukas Markeffsky-2/+2
2024-04-21cleanup: unnecessary clone during lower generics argsbohan-2/+2
2024-04-21Rollup merge of #124198 - compiler-errors:improve-ty-ct-param-span, r=NadrierilGuillaume Gomez-21/+50
Flip spans for precise capturing syntax not capturing a ty/const param, and for implicit captures of lifetime params Make the primary span point to the opaque, rather than the param which might be very far away (e.g. in an impl header hundreds of lines above).
2024-04-21Auto merge of #117457 - daxpedda:wasm-nontrapping-fptoint, r=wesleywiserbors-4/+5
Stabilize Wasm target features that are in phase 4 and 5 This stabilizes the Wasm target features that are known to be working and in [phase 4 and 5](https://github.com/WebAssembly/proposals/tree/04fa8c810e1dc99ab399e41052a6e427ee988180). Feature stabilized: - [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions) - [Import/Export of Mutable Globals](https://github.com/WebAssembly/mutable-global) - [Sign-extension operators](https://github.com/WebAssembly/sign-extension-ops) - [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations) - [Extended Constant Expressions](https://github.com/WebAssembly/extended-const) Features not stabilized: - [Multi-value](https://github.com/WebAssembly/multi-value): requires rebuilding `std` #73755. - [Reference Types](https://github.com/WebAssembly/reference-types): no point stabilizing without #103516. - [Threads](https://github.com/webassembly/threads): requires rebuilding `std` #77839. - [Relaxed SIMD](https://github.com/WebAssembly/relaxed-simd): separate PR #117468. - [Multi Memory](https://github.com/WebAssembly/multi-memory): not implemented. See https://github.com/rust-lang/rust/pull/117457#issuecomment-1787648070 for more context. Documentation: https://github.com/rust-lang/reference/pull/1420 Tracking issue: https://github.com/rust-lang/rust/issues/44839
2024-04-20Rollup merge of #124191 - dtolnay:fixup, r=compiler-errors许杰友 Jieyou Xu (Joe)-224/+178
Give a name to each distinct manipulation of pretty-printer FixupContext There are only 7 distinct ways that the AST pretty-printer interacts with FixupContext: 3 constructors (including Default), 2 transformations, and 2 queries. This PR turns these into associated functions which can be documented with examples. This PR unblocks https://github.com/rust-lang/rust/pull/119427#discussion_r1439481201. In order to improve the pretty-printer's behavior regarding parenthesization of braced macro calls in match arms, which have different grammar than macro calls in statements, FixupContext needs to be extended with 2 new fields. In the previous approach, that would be onerous. In the new approach, all it entails is 1 new constructor (`FixupContext::new_match_arm()`).
2024-04-20Rollup merge of #124132 - RalfJung:OpBundlesIndirect, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-0/+3
llvm RustWrapper: explain OpBundlesIndirect argument type Follow-up to https://github.com/rust-lang/rust/pull/123941 r? ``@Mark-Simulacrum``
2024-04-20Rollup merge of #123967 - RalfJung:static_mut_refs, r=Nilstrieb许杰友 Jieyou Xu (Joe)-8/+13
static_mut_refs: use raw pointers to remove the remaining FIXME Using `SyncUnsafeCell` would not make a lot of sense IMO.
2024-04-20Rollup merge of #123379 - wutchzone:119266, r=compiler-errors许杰友 Jieyou Xu (Joe)-2/+19
Print note with closure signature on type mismatch Fixes #119266 r? Nilstrieb
2024-04-20merge two impl blocksLukas Markeffsky-2/+0
2024-04-20Explicitly mention `Self`Michael Goulet-7/+29
2024-04-20remove `InferCtxt::clear_caches`Lukas Markeffsky-12/+0
2024-04-20include ParamEnv in projection cache keyLukas Markeffsky-13/+19
2024-04-20Flip spans for precise capturing syntax not capturing a ty/ct paramMichael Goulet-14/+21
2024-04-20Print note with closure signature on type mismatchDaniel Sedlak-2/+19
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-20Auto merge of #124194 - matthiaskrgr:rollup-40s0c4q, r=matthiaskrgrbors-62/+1079
Rollup of 3 pull requests Successful merges: - #123409 (Implement Modified Condition/Decision Coverage) - #124104 (Fix capturing duplicated lifetimes via parent in `precise_captures` (`impl use<'...>`)) - #124137 (Match hyphen in multi-revision comment matchers) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-20Rollup merge of #124104 - compiler-errors:parent-generic-use, r=oli-obkMatthias Krüger-7/+30
Fix capturing duplicated lifetimes via parent in `precise_captures` (`impl use<'...>`) For technical reasons related to the way that `Self` and `T::Assoc` are lowered from HIR -> `rustc_middle::ty`, an opaque may mention in its bounds both the original early-bound lifetime from the parent `impl`/`fn`, *and* the *duplicated* early-bound lifetime on the opaque. This is fine -- and has been fine since `@cjgillot` rewrote the way we handled opaque lifetime captures, and we went further to allow this behavior explicitly in https://github.com/rust-lang/rust/pull/115659. It's worthwhile to read this PR's technical section to recall how this duplication works and when it acts surprisingly. The problem here is that the check that make sure that `impl use<'a, 'b>` lists all of the opaque's captured lifetimes wasn't smart enough to consider both these captured lifetimes and the original lifetimes they're duplicated from to be equal. This PR fixes that. r? oli-obk
2024-04-20Rollup merge of #123409 - ZhuUx:master, r=oli-obkMatthias Krüger-55/+1049
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-20Auto merge of #124156 - DianQK:disable-match_branches, r=RalfJungbors-1/+4
Disable SimplifyToExp in MatchBranchSimplification Due to the miscompilation mentioned in #124150, We need to disable MatchBranchSimplification temporarily. To fully resolve this issue, my plan is: 1. Disable SimplifyToExp in MatchBranchSimplification (this PR). 2. Remove all potentially unclear transforms in #124122. 3. Gradually add back the removed transforms (possibly multiple PRs). r? `@Nilstrieb` or `@oli-obk`
2024-04-19Give a name to each distinct manipulation of pretty-printer FixupContextDavid Tolnay-153/+106
2024-04-19Move pretty-printer FixupContext to a moduleDavid Tolnay-74/+75
Required for being able to make the fields private and force the use of accessor methods, which will be added in the next commit.
2024-04-20PatRangeBoundary::compare_with: als add a fast-path for signed integersRalf Jung-5/+8
2024-04-20Auto merge of #124166 - oli-obk:define_opaque_types11, r=compiler-errorsbors-1/+1
Let inherent associated types constrain opaque types during projection r? `@compiler-errors` The same test ICEs on master: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=f4ff62663a5a3a0e16d00953ee7414d5
2024-04-20Disable SimplifyToExp in MatchBranchSimplificationDianQK-1/+4
2024-04-19Auto merge of #124170 - matthiaskrgr:rollup-ldopl64, r=matthiaskrgrbors-16/+32
Rollup of 5 pull requests Successful merges: - #123571 (Correctly change type when adding adjustments on top of `NeverToAny`) - #123729 (run-make: refactor out command wrappers for `clang` and `llvm-readobj`) - #124106 (Don't repeatedly duplicate TAIT lifetimes for each subsequently nested TAIT) - #124149 (rustdoc-search: fix description on aliases in results) - #124155 (bootstrap: don't use rayon for sysinfo) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-19Fix capturing duplicated lifetimes via parentMichael Goulet-7/+30
2024-04-19Rollup merge of #124106 - compiler-errors:tait-lifetime-dedup, r=oli-obkMatthias Krüger-6/+9
Don't repeatedly duplicate TAIT lifetimes for each subsequently nested TAIT Make it so that nested TAITs inherit the lifetimes from their parent item, not their parent TAIT. This is because we don't need to re-duplicate lifetimes for nested TAITs over and over, since the only lifetimes they can capture are from the parent item anyways. This mirrors how RPITs work. This is **not** a functional change that should be observable, since the whole point of duplicating lifetimes and marking the shadowed ones (and uncaptured ones) as bivariant is designed to *not* be observable. r? oli-obk
2024-04-19Auto merge of #124113 - RalfJung:interpret-scalar-ops, r=oli-obkbors-152/+211
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-3/+240
2024-04-19Let inherent associated types constrain opaque types during projectionOli Scherer-1/+1
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-19ScalarInt: add methods to assert being a (u)int of given sizeRalf Jung-72/+78
2024-04-19Correctly change type when adding adjustments on top of `NeverToAny`Maybe Waffle-10/+23
2024-04-19coverage. Generate Mappings of decisions and conditions for MC/DCzhuyunxing-41/+779
2024-04-19Auto merge of #124147 - workingjubilee:rollup-7pjnzr6, r=workingjubileebors-151/+442
Rollup of 7 pull requests Successful merges: - #123406 (Force exhaustion in iter::ArrayChunks::into_remainder) - #123752 (Properly handle emojis as literal prefix in macros) - #123935 (Don't inline integer literals when they overflow - new attempt) - #123980 ( Add an opt-in to store incoming edges in `VecGraph` + misc) - #124019 (Use raw-dylib for Windows synchronization functions) - #124110 (Fix negating `f16` and `f128` constants) - #124116 (when suggesting RUST_BACKTRACE=1, add a special note for Miri's env var isolation) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-18Rollup merge of #124110 - beetrees:neg-f16-f128, r=compiler-errorsJubilee-2/+14
Fix negating `f16` and `f128` constants Make `f16` and `f128` constants respect `neg` in `parse_float_into_scalar`. Tracking issue: #116909 ```@rustbot``` label +F-f16_and_f128
2024-04-18Rollup merge of #124019 - ChrisDenton:futex-raw-dylib, r=joboetJubilee-0/+37
Use raw-dylib for Windows synchronization functions Fixes #123999 by using the raw-dylib feature to specify the DLL to load the Windows futex functions from (e.g. [`WaitOnAddress`](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitonaddress)). This avoids reliance on the import library causing that issue. With apologies to ``@bjorn3,`` as it's currently necessary to revert this for cranelift.
2024-04-18Rollup merge of #123980 - WaffleLapkin:graph-average-refactor, r=wesleywiserJubilee-70/+265
Add an opt-in to store incoming edges in `VecGraph` + misc r? ```@fmease``` needed for #123939