about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-04-08Rollup merge of #123635 - maurer:kcfi-no-assoc, r=compiler-errorsMatthias Krüger-3/+10
CFI: Fix ICE in KCFI non-associated function pointers We oddly weren't testing the more usual case of casting non-methods to function pointers. The KCFI shim insertion logic would ICE on these due to asking for an irrefutable associated item if we cast a function to a function pointer without needing a traditional shim. r? `@compiler-errors`
2024-04-08Rollup merge of #123632 - ohno418:fix-UnmatchedDelim-visibility, ↵Matthias Krüger-5/+2
r=compiler-errors parser: reduce visibility of unnecessary public `UnmatchedDelim` `lexer::UnmatchedDelim` struct in `rustc_parse` is unnecessary public outside of the crate. This commit reduces the visibility to `pub(crate)`. Beside, this removes unnecessary field `expected_delim` that causes warnings after changing the visibility.
2024-04-08Rollup merge of #123591 - Zalathar:useless-cast, r=cuviperMatthias Krüger-2/+2
Remove unnecessary cast from `LLVMRustGetInstrProfIncrementIntrinsic` (Noticed while reviewing #123409.) This particular cast appears to have been copied over from clang, but there are plenty of other call sites in clang that don't bother with a cast here, and it works fine without one. For context, `llvm::Intrinsic::ID` is a typedef for `unsigned`, and `llvm::Intrinsic::instrprof_increment` is a member of `enum IndependentIntrinsics : unsigned`. --- The formatting change in `unwrap(M)` is the result of manually running `clang-format` on this file, and then reverting all changes other than the ones affecting these lines.
2024-04-08Rollup merge of #123578 - lqd:regression-123275, r=compiler-errorsMatthias Krüger-3/+291
Restore `pred_known_to_hold_modulo_regions` As requested by `@lcnr` in https://github.com/rust-lang/rust/issues/123275#issuecomment-2031885563 this PR restores `pred_known_to_hold_modulo_regions` to fix that "unexpected unsized tail" beta regression. This also adds the reduced repro from https://github.com/rust-lang/rust/issues/123275#issuecomment-2041222851 as a sub-optimal test is better than no test at all, and it'll also cover #108721. It still ICEs on master, even though https://github.com/phlip9/rustc-warp-ice doesn't on nightly anymore, since https://github.com/rust-lang/rust/pull/122493. Fixes #123275. r? `@compiler-errors` but feel free to close if you'd rather have a better test instead cc `@wesleywiser` who had signed up to do the revert Will need a backport if we go with this PR: `@rustbot` label +beta-nominated
2024-04-08Rollup merge of #123564 - scottmcm:step-by-div-zero, r=joboetMatthias Krüger-31/+75
Don't emit divide-by-zero panic paths in `StepBy::len` I happened to notice today that there's actually two such calls emitted in the assembly: <https://rust.godbolt.org/z/1Wbbd3Ts6> Since they're impossible, hopefully telling LLVM that will also help optimizations elsewhere.
2024-04-08Rollup merge of #123547 - klensy:bs-pubs, r=onur-ozkanMatthias Krüger-30/+0
bootstrap: remove unused pub fns Looks dead, remove.
2024-04-08Rollup merge of #123518 - compiler-errors:by-move-fixes, r=oli-obkMatthias Krüger-35/+461
Fix `ByMove` coroutine-closure shim (for 2021 precise closure capturing behavior) This PR reworks the way that we perform the `ByMove` coroutine-closure shim to account for the fact that the upvars of the outer coroutine-closure and the inner coroutine might not line up due to edition-2021 closure capture rules changes. Specifically, the number of upvars may differ *and/or* the inner coroutine may have additional projections applied to an upvar. This PR reworks the information we pass into the `ByMoveBody` MIR visitor to account for both of these facts. I tried to leave comments explaining exactly what everything is doing, but let me know if you have questions. r? oli-obk
2024-04-08Rollup merge of #123367 - jswrenn:layoutify, r=compiler-errorsMatthias Krüger-783/+899
Safe Transmute: Compute transmutability from `rustc_target::abi::Layout` In its first step of computing transmutability, `rustc_transmutability` constructs a byte-level representation of type layout (`Tree`). Previously, this representation was computed for ADTs by inspecting the ADT definition and performing our own layout computations. This process was error-prone, verbose, and limited our ability to analyze many types (particularly default-repr types). In this PR, we instead construct `Tree`s from `rustc_target::abi::Layout`s. This helps ensure that layout optimizations are reflected our analyses, and increases the kinds of types we can now analyze, including: - default repr ADTs - transparent unions - `UnsafeCell`-containing types Overall, this PR expands the expressvity of `rustc_transmutability` to be much closer to the transmutability analysis performed by miri. Future PRs will work to close the remaining gaps (e.g., support for `Box`, raw pointers, `NonZero*`, coroutines, etc.). r? `@compiler-errors`
2024-04-08Rollup merge of #122781 - nikic:ppc-abi-fix, r=cuviperMatthias Krüger-41/+156
Fix argument ABI for overaligned structs on ppc64le When passing a 16 (or higher) aligned struct by value on ppc64le, it needs to be passed as an array of `i128` rather than an array of `i64`. This will force the use of an even starting doubleword. For the case of a 16 byte struct with alignment 16 it is important that `[1 x i128]` is used instead of `i128` -- apparently, the latter will get treated similarly to `[2 x i64]`, not exhibiting the correct ABI. Add a `force_array` flag to `Uniform` to support this. The relevant clang code can be found here: https://github.com/llvm/llvm-project/blob/fe2119a7b08b6e468b2a67768904ea85b1bf0a45/clang/lib/CodeGen/Targets/PPC.cpp#L878-L884 https://github.com/llvm/llvm-project/blob/fe2119a7b08b6e468b2a67768904ea85b1bf0a45/clang/lib/CodeGen/Targets/PPC.cpp#L780-L784 I think the corresponding psABI wording is this: > Fixed size aggregates and unions passed by value are mapped to as > many doublewords of the parameter save area as the value uses in > memory. Aggregrates and unions are aligned according to their > alignment requirements. This may result in doublewords being > skipped for alignment. In particular the last sentence. Though I didn't find any wording for Clang's behavior of clamping the alignment to 16. Fixes https://github.com/rust-lang/rust/issues/122767. r? `@cuviper`
2024-04-08CFI: Fix ICE in KCFI non-associated function pointersMatthew Maurer-3/+10
We oddly weren't testing the more usual case of casting non-methods to function pointers. The KCFI shim insertion logic would ICE on these due to asking for an irrefutable associated item if we cast a function to a function pointer without needing a traditional shim.
2024-04-08Auto merge of #120131 - oli-obk:pattern_types_syntax, r=compiler-errorsbors-66/+1499
Implement minimal, internal-only pattern types in the type system rebase of https://github.com/rust-lang/rust/pull/107606 You can create pattern types with `std::pat::pattern_type!(ty is pat)`. The feature is incomplete and will panic on you if you use any pattern other than integral range patterns. The only way to create or deconstruct a pattern type is via `transmute`. This PR's implementation differs from the MCP's text. Specifically > This means you could implement different traits for different pattern types with the same base type. Thus, we just forbid implementing any traits for pattern types. is violated in this PR. The reason is that we do need impls after all in order to make them usable as fields. constants of type `std::time::Nanoseconds` struct are used in patterns, so the type must be structural-eq, which it only can be if you derive several traits on it. It doesn't need to be structural-eq recursively, so we can just manually implement the relevant traits on the pattern type and use the pattern type as a private field. Waiting on: * [x] move all unrelated commits into their own PRs. * [x] fix niche computation (see 2db07f94f44f078daffe5823680d07d4fded883f) * [x] add lots more tests * [x] T-types MCP https://github.com/rust-lang/types-team/issues/126 to finish * [x] some commit cleanup * [x] full self-review * [x] remove 61bd325da19a918cc3e02bbbdce97281a389c648, it's not necessary anymore I think. * [ ] ~~make sure we never accidentally leak pattern types to user code (add stability checks or feature gate checks and appopriate tests)~~ we don't even do this for the new float primitives * [x] get approval that [the scope expansion to trait impls](https://rust-lang.zulipchat.com/#narrow/stream/326866-t-types.2Fnominated/topic/Pattern.20types.20types-team.23126/near/427670099) is ok r? `@BoxyUwU`
2024-04-08Compute transmutability from `rustc_target::abi::Layout`Jack Wrenn-783/+899
In its first step of computing transmutability, `rustc_transmutability` constructs a byte-level representation of type layout (`Tree`). Previously, this representation was computed for ADTs by inspecting the ADT definition and performing our own layout computations. This process was error-prone, verbose, and limited our ability to analyze many types (particularly default-repr types). In this PR, we instead construct `Tree`s from `rustc_target::abi::Layout`s. This helps ensure that layout optimizations are reflected our analyses, and increases the kinds of types we can now analyze, including: - default repr ADTs - transparent unions - `UnsafeCell`-containing types Overall, this PR expands the expressvity of `rustc_transmutability` to be much closer to the transmutability analysis performed by miri. Future PRs will work to close the remaining gaps (e.g., support for `Box`, raw pointers, `NonZero*`, coroutines, etc.).
2024-04-08parser: reduce visibility of unnecessary public `UnmatchedDelim`Yutaro Ohno-5/+2
`lexer::UnmatchedDelim` struct in `rustc_parse` is unnecessary public outside of the crate. This commit reduces the visibility to `pub(crate)`. Beside, this removes unnecessary field `expected_delim` that causes warnings after changing the visibility.
2024-04-08Auto merge of #123628 - matthiaskrgr:rollup-6otgb94, r=matthiaskrgrbors-203/+403
Rollup of 6 pull requests Successful merges: - #115984 (extending filesystem support for Hermit) - #120144 (privacy: Stabilize lint `unnameable_types`) - #122807 (Add consistency with phrases "meantime" and "mean time") - #123089 (Add invariant to VecDeque::pop_* that len < cap if pop successful) - #123595 (Documentation fix) - #123625 (Stop exporting `TypeckRootCtxt` and `FnCtxt`.) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-08Rollup merge of #123625 - oli-obk:private_fnctxt, r=fee1-deadMatthias Krüger-63/+57
Stop exporting `TypeckRootCtxt` and `FnCtxt`. While they have many convenient APIs, it is better to expose dedicated functions for them noticed in #122213
2024-04-08Rollup merge of #123595 - balaganesh102004:master, r=joboetMatthias Krüger-1/+1
Documentation fix Changed "It must not be an identical residual when interconversion is involved" to "The residual is not mandated to be identical when interconversion is involved." as the previous parenthetical appears to state that the residual is not permitted to be identical when interconversion is involved. However the intention of the original wording was to convey that the residual is not required to be identical when interconversion is involved, which makes more sense contextually.
2024-04-08Rollup merge of #123089 - Philippe-Cholet:vecdeque_pop_assume_cap, r=NilstriebMatthias Krüger-2/+75
Add invariant to VecDeque::pop_* that len < cap if pop successful Similar to #114370 for VecDeque instead of Vec. I initially come from https://github.com/rust-itertools/itertools/pull/899 where we noticed that `pop_front;push_back;` was slower than expected so `@scottmcm` suggested I file an issue which lead to https://internals.rust-lang.org/t/vecdeque-pop-front-push-back/20483 where **kornel** mentionned #114334 (fixed by #114370). This is my first time with codegen tests, I based the test on what was done for Vec.
2024-04-08Rollup merge of #122807 - danielhuang:fix-1, r=davidtwcoMatthias Krüger-5/+5
Add consistency with phrases "meantime" and "mean time" "mean time" is used in a few places while "meantime" is used everywhere else; this would make usage consistent throughout the codebase.
2024-04-08Rollup merge of #120144 - petrochenkov:unty, r=davidtwcoMatthias Krüger-29/+14
privacy: Stabilize lint `unnameable_types` This is the last piece of ["RFC #2145: Type privacy and private-in-public lints"](https://github.com/rust-lang/rust/issues/48054). Having unstable lints is not very useful because you cannot even dogfood them in the compiler/stdlib in this case (https://github.com/rust-lang/rust/pull/113284). The worst thing that may happen when a lint is removed are some `removed_lints` warnings, but I haven't heard anyone suggesting removing this specific lint. This lint is allow-by-default and is supposed to be enabled explicitly. Some false positives are expected, because sometimes unnameable types are a legitimate pattern. This lint also have some unnecessary false positives, that can be fixed - see https://github.com/rust-lang/rust/issues/120146 and https://github.com/rust-lang/rust/issues/120149. Closes https://github.com/rust-lang/rust/issues/48054.
2024-04-08Rollup merge of #115984 - hermit-os:fuse, r=m-ou-seMatthias Krüger-103/+251
extending filesystem support for Hermit Extending `std` to create, change and read a directory for Hermit. Hermit is a tier 3 platform and this PR changes only files, wich are related to the tier 3 platform.
2024-04-08Auto merge of #123608 - Mark-Simulacrum:no-demangle-dbg, r=Kobzolbors-0/+1
Remove debuginfo from rustc-demangle too This is done for the same reason as the other dependencies in this list.
2024-04-08Normalize layout test to protect against android alignment differencesOli Scherer-15/+18
2024-04-08Actually create ranged int types in the type system.Oli Scherer-77/+1208
2024-04-08Test macrosOli Scherer-0/+35
2024-04-08Start handling pattern types at the HIR -> Ty conversion boundaryOli Scherer-7/+36
2024-04-08Thread pattern types through the HIROli Scherer-5/+48
2024-04-08Stop exporting `TypeckRootCtxt` and `FnCtxt`.Oli Scherer-63/+57
While they have many convenient APIs, it is better to expose dedicated functions for them
2024-04-08Add pattern types to parserOli Scherer-0/+167
2024-04-08Add pattern types to astOli Scherer-1/+26
2024-04-08Add invariant to VecDeque::pop_* that len < cap if pop successfulPhilippe-Cholet-2/+75
Similar to #114370 for VecDeque instead of Vec. It now uses `core::hint::assert_unchecked`.
2024-04-08Auto merge of #123577 - Urgau:prep-work-for-compiletest-check-cfg, r=oli-obkbors-165/+121
Do some preparation work for compiletest check-cfg This PR does several preparation work for having always-on check-cfg in compiletest. In particular, this PR does two main things: - It unifies all the *always-false* cfgs under the `FALSE` cfg (as it seems to be the convention under `tests/ui`) - It also removes some useless conditions This is done ahead of the introduction of the always-on check-cfg in compiletest to reduce the amount of changes in that follow-up work. I also think that this is useful even without that follow-up work.
2024-04-08Auto merge of #123616 - bzEq:fix-be-test, r=jhprattbors-0/+1
[Test] issue-122805.rs should limit to little endian target In issue-122805.rs, codegen on big endian target is different from little endian target. ```llvm %0 = load <8 x i16>, ptr %value, align 2 store <8 x i16> %0, ptr %_0, align 1 ret void ``` This is expected since the conversion is unnecessary on BE target for this case.
2024-04-08Limited to little endian targetKai Luo-0/+1
2024-04-08force_array -> is_consecutiveNikita Popov-57/+53
The actual ABI implication here is that in some cases the values are required to be "consecutive", i.e. must either all be passed in registers or all on stack (without padding). Adjust the code to either use Uniform::new() or Uniform::consecutive() depending on which behavior is needed. Then, when lowering this in LLVM, skip the [1 x i128] to i128 simplification if is_consecutive is set. i128 is the only case I'm aware of where this is problematic right now. If we find other cases, we can extend this (either based on target information or possibly just by not simplifying for is_consecutive entirely).
2024-04-08Fix argument ABI for overaligned structs on ppc64leNikita Popov-33/+152
When passing a 16 (or higher) aligned struct by value on ppc64le, it needs to be passed as an array of `i128` rather than an array of `i64`. This will force the use of an even starting register. For the case of a 16 byte struct with alignment 16 it is important that `[1 x i128]` is used instead of `i128` -- apparently, the latter will get treated similarly to `[2 x i64]`, not exhibiting the correct ABI. Add a `force_array` flag to `Uniform` to support this. The relevant clang code can be found here: https://github.com/llvm/llvm-project/blob/fe2119a7b08b6e468b2a67768904ea85b1bf0a45/clang/lib/CodeGen/Targets/PPC.cpp#L878-L884 https://github.com/llvm/llvm-project/blob/fe2119a7b08b6e468b2a67768904ea85b1bf0a45/clang/lib/CodeGen/Targets/PPC.cpp#L780-L784 I think the corresponding psABI wording is this: > Fixed size aggregates and unions passed by value are mapped to as > many doublewords of the parameter save area as the value uses in > memory. Aggregrates and unions are aligned according to their > alignment requirements. This may result in doublewords being > skipped for alignment. In particular the last sentence. Fixes https://github.com/rust-lang/rust/issues/122767.
2024-04-08Auto merge of #123569 - c410-f3r:testsssssss, r=jieyouxubors-26/+26
Move some tests r? `@petrochenkov`
2024-04-08Auto merge of #123506 - RalfJung:miri-test-libstd, r=Mark-Simulacrumbors-12/+68
check-aux: test core, alloc, std in Miri Let's see if this works, and how long it takes.
2024-04-07Remove debuginfo from rustc-demangle tooMark Rousskov-0/+1
This is done for the same reason as the other dependencies in this list.
2024-04-07Auto merge of #123597 - Gbd199:patch-1, r=jhprattbors-1/+1
Fix typo in library/core/src/iter/traits/iterator.rs
2024-04-07Move testsCaio-26/+26
2024-04-07Auto merge of #123601 - jieyouxu:compiletest-run-rustfix-revisions, ↵bors-9/+57
r=WaffleLapkin compiletest: properly handle revisioned run-rustfix tests Before this PR, if you have a revisioned `//@ run-rustfix` test like `//`@[foo]` run-rustfix`, you would run into an error saying crate name cannot contain `.` characters because the fixed test file trying to be compiled is named `<test-name>.<revision>.fixed`, from which `rustc` infers the crate name to be `<test-name>.<revision>` which is not a valid crate name. This PR fixes the problem by constructing a synthetic crate name from `<test-name>.<revision>`, by 1. replacing all `-` with `_`, and 2. replacing all `.` with `__` and pass that constructed crate name with `--crate-name` to rustc to compile the fixed file. Fixes https://github.com/rust-lang/rust/issues/123596.
2024-04-07tests/ui: remove workaround for broken revisioned run-rustfix test许杰友 Jieyou Xu (Joe)-8/+4
2024-04-07compiletest: properly handle revisioned run-rustfix tests许杰友 Jieyou Xu (Joe)-1/+53
2024-04-07Fix typo in library/core/src/iter/traits/iterator.rsGabriel Dolberg-1/+1
2024-04-07Made changes in documentationBALAGANESH-1/+1
2024-04-07Auto merge of #123592 - matthiaskrgr:rollup-3k1pq8s, r=matthiaskrgrbors-3/+14
Rollup of 2 pull requests Successful merges: - #123584 (Emit an error when `rustc_doc_primitive` has an unknown value) - #123589 (sys_common::thread_local_key: make a note that this is not used on Windows) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-07Rollup merge of #123589 - RalfJung:nowin, r=ChrisDentonMatthias Krüger-1/+4
sys_common::thread_local_key: make a note that this is not used on Windows This just confused me for a while. I don't have the time to clean it up but I can at least leave a note for the next wary traveler.
2024-04-07Rollup merge of #123584 - tgross35:rustc_doc_primitive-usage-error, r=fmeaseMatthias Krüger-2/+10
Emit an error when `rustc_doc_primitive` has an unknown value Currently rustdoc silently does nothing. Change this to raise an error instead.
2024-04-07Auto merge of #123561 - saethlin:str-unchecked-sub-index, r=scottmcmbors-6/+37
Use unchecked_sub in str indexing https://github.com/rust-lang/rust/pull/108763 applied this logic to indexing for slices, but of course `str` has its own separate impl. Found this by skimming over the codegen for https://github.com/oxidecomputer/hubris/; their dist builds enable overflow checks so the lack of `unchecked_sub` was producing an impossible-to-hit overflow check and also inhibiting some inlining. r? scottmcm
2024-04-07Remove unnecessary cast from `LLVMRustGetInstrProfIncrementIntrinsic`Zalathar-2/+2
This particular cast appears to have been copied over from clang, but there are plenty of other call sites in clang that don't bother with a cast here, and it works fine without one. For context, `llvm::Intrinsic::ID` is a typedef for `unsigned`, and `llvm::Intrinsic::instrprof_increment` is a member of `enum IndependentIntrinsics : unsigned`.