Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from rust-lang:master #6

Merged
merged 173 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
102997a
Update Tests
veera-sivarajan Jul 13, 2024
764675e
Add Tests
veera-sivarajan Aug 6, 2024
f003e92
Don't Suggest Labeling `const` and `unsafe` Blocks
veera-sivarajan Aug 6, 2024
27f92b6
fix: get llvm type of global val
LYF1999 Aug 8, 2024
12de141
Suggest `impl Trait` for References to Bare Trait in Function Header
veera-sivarajan Jul 13, 2024
1aebff9
Add Top TOC support to rustdoc
notriddle Feb 6, 2024
a7aea5d
Add configuration options to hide TOC or module navigation
notriddle Feb 7, 2024
5a6054b
rustdoc: add separate section for module items
notriddle Jul 22, 2024
68773c7
rustdoc: add separate section for module items
notriddle Jul 22, 2024
7091fa5
rustdoc: show code spans as `<code>` in TOC
notriddle Jul 22, 2024
95fcddd
Add more test case
notriddle Jul 23, 2024
12a3c42
rustdoc: consistentify `#TOC` and `#ModNav` to lowercase
notriddle Jul 24, 2024
bead042
rustdoc: add test case for modnav position when TOC is off
notriddle Jul 24, 2024
723609f
Update x86_64-linux host compiler to LLVM 19 rc 3
nikic Aug 20, 2024
992b0b3
Document the broken C ABI of `wasm32-unknown-unknown`
alexcrichton Aug 26, 2024
1ef4f5d
clarify that addr_of creates read-only pointers
RalfJung Aug 27, 2024
e77eb04
Arbitrary self types v2: pointers feature gate.
adetaylor Mar 30, 2024
94e9c4c
warn the user if the upstream master branch is old
lolbinarycat Aug 25, 2024
cea707d
emit old upstream warning no matter the build step
lolbinarycat Aug 27, 2024
3743cdb
downgrade git error to a warning, and skip UX check in CI
lolbinarycat Aug 27, 2024
992dd0b
CI: rfl: add a couple comments to split the steps and document them
ojeda Aug 10, 2024
d783b1d
CI: rfl: switch to a stage 2 build
ojeda Aug 27, 2024
824397d
CI: rfl: add a Clippy build
ojeda Aug 10, 2024
d584f70
CI: rfl: add a `rustfmt` run
ojeda Aug 10, 2024
5c558d3
CI: rfl: add macro expanded source build (`-Zunpretty=expanded`)
ojeda Aug 10, 2024
778ff06
CI: rfl: factor out build targets
ojeda Aug 10, 2024
b5bd0fe
addr_of on places derived from raw pointers should preserve permissions
RalfJung Aug 27, 2024
c6111c0
Remove the `'body` lifetime on `FilterInformation`.
nnethercote Aug 29, 2024
0a282ea
Move `WriteInfo` out of `Allocations`.
nnethercote Aug 29, 2024
ad5a6e1
Remove `Allocations`.
nnethercote Aug 29, 2024
1be2204
Simplify `Candidate`.
nnethercote Aug 29, 2024
21edc73
bootstrap: Try to track down why `initial_libdir` sometimes fails
Zalathar Aug 30, 2024
39e3add
Make `./x.py <cmd> compiler/<crate>` aware of the crate's features
Veykril Aug 30, 2024
8e20b66
Some code review suggestions.
adetaylor Aug 30, 2024
0d156f2
Unify scraped examples with other code examples
GuillaumeGomez Aug 30, 2024
5b75f8a
Update rustdoc GUI tests
GuillaumeGomez Aug 30, 2024
121e9f4
Add rust.randomize-layout config to build artifacts with -Zrandomize-…
the8472 Sep 2, 2022
f3bc08a
ignore/fix layout-sensitive tests
the8472 Sep 2, 2022
5bf8eeb
disable size asserts in the compiler when randomizing layouts
the8472 Sep 2, 2022
e3169f7
when -Zrandomize-layout is enabled disable alloc test testing interna…
the8472 Sep 2, 2022
1e377c5
enable layout randomization in x86_64-gnu-llvm-17 CI job
the8472 Sep 2, 2022
df20808
inhibit layout randomization for Box
the8472 Aug 31, 2024
c218c75
exclude tools with deps that have size asserts
the8472 Aug 31, 2024
5afc461
Fix wrong rounded corners when line numbers are displayed on code exa…
GuillaumeGomez Aug 31, 2024
84259ff
Add GUI tests to ensure that rounded corners on code blocks are worki…
GuillaumeGomez Aug 31, 2024
35a7c1b
Fix position of scraped examples title on mobile devices
GuillaumeGomez Sep 1, 2024
dd5f7bc
Add GUI regression test for scraped examples title position on mobile
GuillaumeGomez Sep 1, 2024
4825fb1
Add missing CSS variables in GUI test for `custom-theme.css`
GuillaumeGomez Sep 1, 2024
5a85632
Correctly handle code examples buttons position
GuillaumeGomez Sep 1, 2024
01d8235
Fix scraped examples background gradient
GuillaumeGomez Sep 1, 2024
e3af6dc
Simplify CSS but wrapping scraped example into a div and move the tit…
GuillaumeGomez Sep 2, 2024
c51953f
Use `DeepRejectCtxt` to quickly reject `ParamEnv` candidates
Bryanskiy Aug 4, 2024
6f6a6bc
Non-exhaustive structs may be empty
Nadrieril Aug 10, 2024
55bc638
Fix wrong padding for expanded scraped example
GuillaumeGomez Sep 2, 2024
8d3e5fa
Move the `data` and `vtable` methods from `RawWaker` to `Waker`
kevinmehall Sep 2, 2024
2dc7514
Stabilize waker_getters
kevinmehall Sep 2, 2024
22bd319
Add `Waker::new` and `LocalWaker::new`
kevinmehall Sep 3, 2024
5410900
Adjust `SanityCheck`.
nnethercote Sep 3, 2024
2aae619
Move `MirPass` to `rustc_mir_transform`.
nnethercote Sep 3, 2024
827fa43
Reduce visibility of `MirPass` and related things.
nnethercote Sep 3, 2024
0b2b03c
Clarify a comment.
nnethercote Sep 3, 2024
6188aae
do not attempt to prove unknowable goals
lcnr Sep 2, 2024
6f435cb
Port std library to RTEMS
thesummer Aug 21, 2023
124454c
rtems: Add spec file for arm_rtems6_eabihf
thesummer Jan 23, 2024
6fd358e
Add documentation for target armv7-rtems-eabihf
thesummer Jun 26, 2024
5c0dfc6
update comment regarding TargetOptions.features
RalfJung Sep 1, 2024
aa1f60e
rustc_driver_impl: remove some old dead logic
RalfJung Sep 3, 2024
17f3f92
include 1.80.1 release notes on master
pietroalbini Sep 3, 2024
c811d31
More robust extension checking
ChrisDenton Jul 18, 2024
2d6d6a8
Updates/clarifications
alexcrichton Aug 27, 2024
f75a195
Rollup merge of #127692 - veera-sivarajan:bugfix-125139, r=estebank
matthiaskrgr Sep 3, 2024
51c686f
Rollup merge of #128701 - veera-sivarajan:fix-128604, r=estebank
matthiaskrgr Sep 3, 2024
e7504ac
Rollup merge of #128934 - Nadrieril:fix-empty-non-exhaustive, r=compi…
matthiaskrgr Sep 3, 2024
1453cce
Rollup merge of #129630 - alexcrichton:document-broken-c-abi-on-wasm3…
matthiaskrgr Sep 3, 2024
2f6e855
Rollup merge of #129863 - RalfJung:target-spec-features, r=wesleywiser
matthiaskrgr Sep 3, 2024
485fd38
Rollup merge of #129896 - lcnr:bail-on-unknowable, r=jackh726
matthiaskrgr Sep 3, 2024
4ed0f0d
Rollup merge of #129926 - nnethercote:mv-SanityCheck-and-MirPass, r=c…
matthiaskrgr Sep 3, 2024
442c077
Rollup merge of #129928 - RalfJung:rustc_driver_impl-crt-static, r=co…
matthiaskrgr Sep 3, 2024
2e00511
Rollup merge of #129930 - ferrocene:pa-relnotes-1801, r=pietroalbini
matthiaskrgr Sep 3, 2024
0402394
Add an internal lint that warns when accessing untracked data
Nadrieril Aug 9, 2024
b5d07fd
copy rustc rustlib artifacts from ci-rustc
onur-ozkan Sep 3, 2024
65e78db
Elaborate on deriving vs implementing `Copy`
chancancode Sep 3, 2024
3626b66
Update marker.rs
chancancode Sep 3, 2024
efc20de
Update marker.rs
chancancode Sep 3, 2024
277a08c
Update marker.rs
chancancode Sep 3, 2024
e45b53e
Update marker.rs
chancancode Sep 3, 2024
98f74b4
explain why Rvalue::Len still exists
RalfJung Sep 3, 2024
7157f98
Fix square corners on line numbers when code is collapsed
GuillaumeGomez Sep 3, 2024
a4f2a31
Don't ICE when dumping MIR of a synthetic coroutine body
compiler-errors Aug 28, 2024
5525043
Rename dump of coroutine by-move-body to be more consistent, adjust test
compiler-errors Aug 28, 2024
f3efe3d
Add compat note for trait solver change
Mark-Simulacrum Sep 3, 2024
e2484be
docs: add digit separators in `Duration` examples
LiterallyVoid Sep 3, 2024
842d6fc
Auto merge of #129356 - nikic:llvm19-host, r=Mark-Simulacrum
bors Sep 4, 2024
4df28b8
forward linker option to lint-docs
chenx97 Sep 4, 2024
9cb6d12
use the bootstrapped compiler for `test-float-parse` test
onur-ozkan Sep 3, 2024
93b4b2d
Temporarily remove fmease from the review rotation
fmease Sep 4, 2024
8860008
Re-parent the by-move body
compiler-errors Aug 28, 2024
42d2d78
Make supertrait and implied predicates queries defaulted
compiler-errors Aug 29, 2024
c753d2d
remove deprecated option `rust.split-debuginfo`
onur-ozkan Sep 3, 2024
c06ed92
add change entry for `rust.split-debuginfo` removal
onur-ozkan Sep 4, 2024
5b96ae7
Don't codegen `expect` in opt-level=0
clubby789 Feb 25, 2024
0c45d3b
update docs of missing_abi lint
kadiwa4 Sep 2, 2024
49a93df
fix: correct {Path,OsStr}::to_string_lossy() docs
rjooske Sep 4, 2024
4ac7bcb
Auto merge of #129962 - pietroalbini:pa-cve-2024-43402-nightly, r=Ama…
bors Sep 4, 2024
f7679d0
propagate `tainted_by_errors` in `MirBorrowckCtxt::emit_errors`
folkertdev Sep 4, 2024
49e3b9a
fix ICE when `asm_const` and `const_refs_to_static` are combined
folkertdev Aug 23, 2024
009e738
Auto merge of #129936 - matthiaskrgr:rollup-0s8xycb, r=matthiaskrgr
bors Sep 4, 2024
8a60d0a
Rollup merge of #101339 - the8472:ci-randomize-debug, r=Mark-Simulacrum
matthiaskrgr Sep 5, 2024
e1da72c
Rollup merge of #120736 - notriddle:notriddle/toc, r=t-rustdoc
matthiaskrgr Sep 5, 2024
3775e6b
Rollup merge of #127021 - thesummer:1-add-target-support-for-rtems-ar…
matthiaskrgr Sep 5, 2024
7d01557
Rollup merge of #128928 - ojeda:ci-rfl-more-tools, r=Kobzol
matthiaskrgr Sep 5, 2024
776187d
Rollup merge of #129584 - lolbinarycat:old-upstream-warning, r=albert…
matthiaskrgr Sep 5, 2024
08187c3
Rollup merge of #129664 - adetaylor:arbitrary-self-types-pointers-fea…
matthiaskrgr Sep 5, 2024
4261bff
Rollup merge of #129752 - compiler-errors:predicates-of-defaulted, r=…
matthiaskrgr Sep 5, 2024
94eea0a
Rollup merge of #129918 - kadiwa4:missing_abi_docs, r=Urgau
matthiaskrgr Sep 5, 2024
c7c3ada
Rollup merge of #129919 - kevinmehall:waker-getters, r=dtolnay
matthiaskrgr Sep 5, 2024
3190521
Rollup merge of #129925 - onur-ozkan:deprecated-option, r=Kobzol
matthiaskrgr Sep 5, 2024
eb33b43
Auto merge of #129978 - matthiaskrgr:rollup-a7ryoox, r=matthiaskrgr
bors Sep 5, 2024
1a893ac
stabilize `-Znext-solver=coherence`
lcnr Mar 1, 2024
d93e047
rebase and update fixed `crashes`
lcnr Apr 15, 2024
69fdd14
remove unnecessary revisions
lcnr Aug 16, 2024
a138a92
update test description
lcnr Sep 5, 2024
2031eac
run_make_support: rename `Command::stdin` to `stdin_buf` and add `std…
jieyouxu Sep 4, 2024
afed862
tests: use renamed `stdin_buf`
jieyouxu Sep 5, 2024
8871ce0
run_make_support: make each command invocation only-run-once
jieyouxu Sep 5, 2024
a459403
Sort impl associated items by kinds and then by appearance
GuillaumeGomez Aug 23, 2024
f96aff9
Add regression test for impl associated items sorting
GuillaumeGomez Aug 23, 2024
1884983
Make impl associated constants sorted first
GuillaumeGomez Aug 25, 2024
d059f37
Add missing sidebar associated items
GuillaumeGomez Aug 26, 2024
238944c
Add regression test for sidebar associated items
GuillaumeGomez Aug 26, 2024
8f9c4b3
Update to new rustdoc internal API
GuillaumeGomez Sep 5, 2024
f8f4d50
Don't worry about uncaptured contravariant lifetimes if they outlive …
compiler-errors Aug 12, 2024
7064135
Do less work on the good path
compiler-errors Aug 12, 2024
c1d0410
Review comments
compiler-errors Aug 19, 2024
e8472e8
Check unnormalized signature on pointer cast
compiler-errors Aug 13, 2024
67804c5
Adjust tests
compiler-errors Aug 25, 2024
b89ee99
Rollup merge of #128820 - LYF1999:yf/dev, r=nikic
matthiaskrgr Sep 5, 2024
b0cc78c
Rollup merge of #129028 - compiler-errors:contra, r=lcnr
matthiaskrgr Sep 5, 2024
6a23ee5
Rollup merge of #129471 - GuillaumeGomez:sort-impl-associated-items, …
matthiaskrgr Sep 5, 2024
11085aa
Rollup merge of #129706 - compiler-errors:scratch, r=estebank
matthiaskrgr Sep 5, 2024
15e7a67
Rollup merge of #129720 - nnethercote:simplify-dest_prop-mm, r=cjgillot
matthiaskrgr Sep 5, 2024
9be97ae
Rollup merge of #129796 - GuillaumeGomez:unify-code-examples, r=notri…
matthiaskrgr Sep 5, 2024
0db3932
Rollup merge of #129938 - chancancode:patch-1, r=thomcc
matthiaskrgr Sep 5, 2024
fee6c0a
Rollup merge of #129973 - jieyouxu:rework-rmake-stdio, r=Kobzol
matthiaskrgr Sep 5, 2024
a551ccc
Remove wasm32-wasip2's tier 2 status from release notes
alexcrichton Sep 5, 2024
46f390f
Rollup merge of #128919 - Nadrieril:lint-query-leaks, r=cjgillot
matthiaskrgr Sep 5, 2024
3daa015
Rollup merge of #129472 - folkertdev:const-refs-to-static-asm-const, …
matthiaskrgr Sep 5, 2024
85d15d2
Rollup merge of #129653 - RalfJung:addr-of-read-only, r=scottmcm
matthiaskrgr Sep 5, 2024
4a8135c
Rollup merge of #129775 - Zalathar:initial-libdir, r=albertlarsan68
matthiaskrgr Sep 5, 2024
2efefe6
Rollup merge of #129939 - RalfJung:rvalue-len, r=compiler-errors
matthiaskrgr Sep 5, 2024
95c580d
Rollup merge of #129942 - onur-ozkan:building-rustc-tools, r=Kobzol
matthiaskrgr Sep 5, 2024
57d85fa
Rollup merge of #129943 - onur-ozkan:test-float-parse-compiler, r=Kobzol
matthiaskrgr Sep 5, 2024
a84ef47
Rollup merge of #129944 - Mark-Simulacrum:relnotes-tweak, r=pietroalbini
matthiaskrgr Sep 5, 2024
96719db
Rollup merge of #129947 - LiterallyVoid:duration-docs-digit-separator…
matthiaskrgr Sep 5, 2024
a0ab808
Rollup merge of #129955 - fmease:fmease-break, r=fmease
matthiaskrgr Sep 5, 2024
d34ad5d
Rollup merge of #129957 - chenx97:lint-docs-linker-opt, r=albertlarsan68
matthiaskrgr Sep 5, 2024
9c01301
Auto merge of #129994 - matthiaskrgr:rollup-zkj4ekl, r=matthiaskrgr
bors Sep 5, 2024
f6e8a84
Make `Ty::boxed_ty` return an `Option`
GrigorenkoPV Sep 4, 2024
54fdef7
Auto merge of #121614 - clubby789:no-expect, r=saethlin
bors Sep 6, 2024
4f5c16d
Enzyme backend
ZuseZ4 Sep 4, 2024
d678b81
Auto merge of #129999 - matthiaskrgr:rollup-pzr9c8p, r=matthiaskrgr
bors Sep 6, 2024
3446ca5
coverage: Add test to codify existing behavior
jonathan-conder Sep 6, 2024
25d1830
coverage: Treat await similar to a macro
jonathan-conder Sep 5, 2024
e903b29
Rollup merge of #129021 - compiler-errors:ptr-cast-outlives, r=lcnr
matthiaskrgr Sep 6, 2024
b09f316
Rollup merge of #129781 - Veykril:lw-x-py-compiler-features, r=albert…
matthiaskrgr Sep 6, 2024
45d6957
Rollup merge of #129963 - rjooske:fix/inaccurate_to_string_lossy_doc,…
matthiaskrgr Sep 6, 2024
0180b8f
Rollup merge of #129969 - GrigorenkoPV:boxed-ty, r=compiler-errors
matthiaskrgr Sep 6, 2024
6841e35
Rollup merge of #129995 - alexcrichton:remove-wasm32-wasip2-release-n…
matthiaskrgr Sep 6, 2024
11d5614
Rollup merge of #130013 - jonathan-conder:await_coverage, r=Zalathar
matthiaskrgr Sep 6, 2024
a3af208
Auto merge of #130016 - matthiaskrgr:rollup-fopistw, r=matthiaskrgr
bors Sep 6, 2024
59d4114
Auto merge of #129176 - EnzymeAD:enzyme-backend, r=albertlarsan68
bors Sep 6, 2024
17b322f
Auto merge of #121848 - lcnr:stabilize-next-solver, r=compiler-errors
bors Sep 6, 2024
26b5599
Auto merge of #128776 - Bryanskiy:deep-reject-ctxt, r=lcnr
bors Sep 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@
path = src/tools/rustc-perf
url = https://github.com/rust-lang/rustc-perf.git
shallow = true
[submodule "src/tools/enzyme"]
path = src/tools/enzyme
url = https://github.com/EnzymeAD/Enzyme.git
shallow = true
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3569,6 +3569,7 @@ dependencies = [
"rustc_hir_pretty",
"rustc_hir_typeck",
"rustc_incremental",
"rustc_index",
"rustc_infer",
"rustc_interface",
"rustc_lint",
Expand Down
12 changes: 11 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Compiler
- [Add Tier 3 `std` Xtensa targets:](https://github.com/rust-lang/rust/pull/126380/) `xtensa-esp32-espidf`, `xtensa-esp32s2-espidf`, `xtensa-esp32s3-espidf`
- [Add Tier 3 i686 Redox OS target:](https://github.com/rust-lang/rust/pull/126192/) `i686-unknown-redox`
- [Promote `arm64ec-pc-windows-msvc` to Tier 2.](https://github.com/rust-lang/rust/pull/126039/)
- [Promote `wasm32-wasip2` to Tier 2.](https://github.com/rust-lang/rust/pull/126967/)
- [Promote `loongarch64-unknown-linux-musl` to Tier 2 with host tools.](https://github.com/rust-lang/rust/pull/126298/)
- [Enable full tools and profiler for LoongArch Linux targets.](https://github.com/rust-lang/rust/pull/127078/)
- [Unconditionally warn on usage of `wasm32-wasi`.](https://github.com/rust-lang/rust/pull/126662/) (see compatibility note below)
Expand Down Expand Up @@ -100,6 +99,9 @@ Compatibility Notes
The reason is that these types have different roles: `std::panic::PanicHookInfo` is the argument to the [panic hook](https://doc.rust-lang.org/stable/std/panic/fn.set_hook.html) in std context (where panics can have an arbitrary payload), while `core::panic::PanicInfo` is the argument to the [`#[panic_handler]`](https://doc.rust-lang.org/nomicon/panic-handler.html) in no_std context (where panics always carry a formatted *message*). Separating these types allows us to add more useful methods to these types, such as `std::panic::PanicHookInfo::payload_as_str()` and `core::panic::PanicInfo::message()`.

* The new sort implementations may panic if a type's implementation of [`Ord`](https://doc.rust-lang.org/std/cmp/trait.Ord.html) (or the given comparison function) does not implement a [total order](https://en.wikipedia.org/wiki/Total_order) as the trait requires. `Ord`'s supertraits (`PartialOrd`, `Eq`, and `PartialEq`) must also be consistent. The previous implementations would not "notice" any problem, but the new implementations have a good chance of detecting inconsistencies, throwing a panic rather than returning knowingly unsorted data.
* [In very rare cases, a change in the internal evaluation order of the trait
solver may result in new fatal overflow errors.](https://github.com/rust-lang/rust/pull/126128)


<a id="1.81.0-Internal-Changes"></a>

Expand All @@ -112,6 +114,14 @@ tools.

- [Add a Rust-for Linux `auto` CI job to check kernel builds.](https://github.com/rust-lang/rust/pull/125209/)

Version 1.80.1 (2024-08-08)
===========================

<a id="1.80.1"></a>

- [Fix miscompilation in the jump threading MIR optimization when comparing floats](https://github.com/rust-lang/rust/pull/128271)
- [Revert changes to the `dead_code` lint from 1.80.0](https://github.com/rust-lang/rust/pull/128618)

Version 1.80.0 (2024-07-25)
==========================

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ features = ['unprefixed_malloc_on_supported_platforms']
jemalloc = ['dep:jemalloc-sys']
llvm = ['rustc_driver_impl/llvm']
max_level_info = ['rustc_driver_impl/max_level_info']
rustc_randomized_layouts = ['rustc_driver_impl/rustc_randomized_layouts']
rustc_use_parallel_compiler = ['rustc_driver_impl/rustc_use_parallel_compiler']
# tidy-alphabetical-end
11 changes: 7 additions & 4 deletions compiler/rustc_abi/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,8 @@ fn univariant<
let mut align = if pack.is_some() { dl.i8_align } else { dl.aggregate_align };
let mut max_repr_align = repr.align;
let mut inverse_memory_index: IndexVec<u32, FieldIdx> = fields.indices().collect();
let optimize = !repr.inhibit_struct_field_reordering();
if optimize && fields.len() > 1 {
let optimize_field_order = !repr.inhibit_struct_field_reordering();
if optimize_field_order && fields.len() > 1 {
let end = if let StructKind::MaybeUnsized = kind { fields.len() - 1 } else { fields.len() };
let optimizing = &mut inverse_memory_index.raw[..end];
let fields_excluding_tail = &fields.raw[..end];
Expand Down Expand Up @@ -1176,7 +1176,7 @@ fn univariant<
// If field 5 has offset 0, offsets[0] is 5, and memory_index[5] should be 0.
// Field 5 would be the first element, so memory_index is i:
// Note: if we didn't optimize, it's already right.
let memory_index = if optimize {
let memory_index = if optimize_field_order {
inverse_memory_index.invert_bijective_mapping()
} else {
debug_assert!(inverse_memory_index.iter().copied().eq(fields.indices()));
Expand All @@ -1189,6 +1189,9 @@ fn univariant<
}
let mut layout_of_single_non_zst_field = None;
let mut abi = Abi::Aggregate { sized };

let optimize_abi = !repr.inhibit_newtype_abi_optimization();

// Try to make this a Scalar/ScalarPair.
if sized && size.bytes() > 0 {
// We skip *all* ZST here and later check if we are good in terms of alignment.
Expand All @@ -1205,7 +1208,7 @@ fn univariant<
match field.abi {
// For plain scalars, or vectors of them, we can't unpack
// newtypes for `#[repr(C)]`, as that affects C ABIs.
Abi::Scalar(_) | Abi::Vector { .. } if optimize => {
Abi::Scalar(_) | Abi::Vector { .. } if optimize_abi => {
abi = field.abi;
}
// But scalar pairs are Rust-specific and get
Expand Down
15 changes: 11 additions & 4 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ bitflags! {
const IS_SIMD = 1 << 1;
const IS_TRANSPARENT = 1 << 2;
// Internal only for now. If true, don't reorder fields.
// On its own it does not prevent ABI optimizations.
const IS_LINEAR = 1 << 3;
// If true, the type's layout can be randomized using
// the seed stored in `ReprOptions.field_shuffle_seed`
// If true, the type's crate has opted into layout randomization.
// Other flags can still inhibit reordering and thus randomization.
// The seed stored in `ReprOptions.field_shuffle_seed`.
const RANDOMIZE_LAYOUT = 1 << 4;
// Any of these flags being set prevent field reordering optimisation.
const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits()
const FIELD_ORDER_UNOPTIMIZABLE = ReprFlags::IS_C.bits()
| ReprFlags::IS_SIMD.bits()
| ReprFlags::IS_LINEAR.bits();
const ABI_UNOPTIMIZABLE = ReprFlags::IS_C.bits() | ReprFlags::IS_SIMD.bits();
}
}

Expand Down Expand Up @@ -139,10 +142,14 @@ impl ReprOptions {
self.c() || self.int.is_some()
}

pub fn inhibit_newtype_abi_optimization(&self) -> bool {
self.flags.intersects(ReprFlags::ABI_UNOPTIMIZABLE)
}

/// Returns `true` if this `#[repr()]` guarantees a fixed field order,
/// e.g. `repr(C)` or `repr(<int>)`.
pub fn inhibit_struct_field_reordering(&self) -> bool {
self.flags.intersects(ReprFlags::IS_UNOPTIMISABLE) || self.int.is_some()
self.flags.intersects(ReprFlags::FIELD_ORDER_UNOPTIMIZABLE) || self.int.is_some()
}

/// Returns `true` if this type is valid for reordering and `-Z randomize-layout`
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,9 +662,10 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
// `&dyn Trait`
ty::Ref(_, ty, _) if ty.is_trait() => true,
// `Box<dyn Trait>`
_ if ty.is_box() && ty.boxed_ty().is_trait() => {
_ if ty.boxed_ty().is_some_and(Ty::is_trait) => {
true
}

// `dyn Trait`
_ if ty.is_trait() => true,
// Anything else.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
variant_index: Option<VariantIdx>,
including_tuple_field: IncludingTupleField,
) -> Option<String> {
if ty.is_box() {
if let Some(boxed_ty) = ty.boxed_ty() {
// If the type is a box, the field is described from the boxed type
self.describe_field_from_ty(ty.boxed_ty(), field, variant_index, including_tuple_field)
self.describe_field_from_ty(boxed_ty, field, variant_index, including_tuple_field)
} else {
match *ty.kind() {
ty::Adt(def, _) => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2522,7 +2522,7 @@ mod diags {
}

pub(crate) fn emit_errors(&mut self) -> Option<ErrorGuaranteed> {
let mut res = None;
let mut res = self.infcx.tainted_by_errors();

// Buffer any move errors that we collected and de-duplicated.
for (_, (_, diag)) in std::mem::take(&mut self.diags.buffered_move_errors) {
Expand Down
71 changes: 64 additions & 7 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1979,19 +1979,76 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {

match cast_kind {
CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer) => {
let fn_sig = op.ty(body, tcx).fn_sig(tcx);
let src_sig = op.ty(body, tcx).fn_sig(tcx);

// HACK: This shouldn't be necessary... We can remove this when we actually
// get binders with where clauses, then elaborate implied bounds into that
// binder, and implement a higher-ranked subtyping algorithm that actually
// respects these implied bounds.
//
// This protects against the case where we are casting from a higher-ranked
// fn item to a non-higher-ranked fn pointer, where the cast throws away
// implied bounds that would've needed to be checked at the call site. This
// only works when we're casting to a non-higher-ranked fn ptr, since
// placeholders in the target signature could have untracked implied
// bounds, resulting in incorrect errors.
//
// We check that this signature is WF before subtyping the signature with
// the target fn sig.
if src_sig.has_bound_regions()
&& let ty::FnPtr(target_fn_tys, target_hdr) = *ty.kind()
&& let target_sig = target_fn_tys.with(target_hdr)
&& let Some(target_sig) = target_sig.no_bound_vars()
{
let src_sig = self.infcx.instantiate_binder_with_fresh_vars(
span,
BoundRegionConversionTime::HigherRankedType,
src_sig,
);
let src_ty = Ty::new_fn_ptr(self.tcx(), ty::Binder::dummy(src_sig));
self.prove_predicate(
ty::ClauseKind::WellFormed(src_ty.into()),
location.to_locations(),
ConstraintCategory::Cast { unsize_to: None },
);

let src_ty = self.normalize(src_ty, location);
if let Err(terr) = self.sub_types(
src_ty,
*ty,
location.to_locations(),
ConstraintCategory::Cast { unsize_to: None },
) {
span_mirbug!(
self,
rvalue,
"equating {:?} with {:?} yields {:?}",
target_sig,
src_sig,
terr
);
};
}

let src_ty = Ty::new_fn_ptr(tcx, src_sig);
// HACK: We want to assert that the signature of the source fn is
// well-formed, because we don't enforce that via the WF of FnDef
// types normally. This should be removed when we improve the tracking
// of implied bounds of fn signatures.
self.prove_predicate(
ty::ClauseKind::WellFormed(src_ty.into()),
location.to_locations(),
ConstraintCategory::Cast { unsize_to: None },
);

// The type that we see in the fcx is like
// `foo::<'a, 'b>`, where `foo` is the path to a
// function definition. When we extract the
// signature, it comes from the `fn_sig` query,
// and hence may contain unnormalized results.
let fn_sig = self.normalize(fn_sig, location);

let ty_fn_ptr_from = Ty::new_fn_ptr(tcx, fn_sig);

let src_ty = self.normalize(src_ty, location);
if let Err(terr) = self.sub_types(
ty_fn_ptr_from,
src_ty,
*ty,
location.to_locations(),
ConstraintCategory::Cast { unsize_to: None },
Expand All @@ -2000,7 +2057,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
self,
rvalue,
"equating {:?} with {:?} yields {:?}",
ty_fn_ptr_from,
src_ty,
ty,
terr
);
Expand Down
14 changes: 12 additions & 2 deletions compiler/rustc_borrowck/src/universal_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ use rustc_macros::extension;
use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{
self, GenericArgs, GenericArgsRef, InlineConstArgs, InlineConstArgsParts, RegionVid, Ty, TyCtxt,
self, GenericArgs, GenericArgsRef, InlineConstArgs, InlineConstArgsParts, RegionVid, Ty,
TyCtxt, TypeVisitableExt,
};
use rustc_middle::{bug, span_bug};
use rustc_span::symbol::{kw, sym};
Expand Down Expand Up @@ -688,7 +689,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
defining_ty: DefiningTy<'tcx>,
) -> ty::Binder<'tcx, &'tcx ty::List<Ty<'tcx>>> {
let tcx = self.infcx.tcx;
match defining_ty {

let inputs_and_output = match defining_ty {
DefiningTy::Closure(def_id, args) => {
assert_eq!(self.mir_def.to_def_id(), def_id);
let closure_sig = args.as_closure().sig();
Expand Down Expand Up @@ -798,6 +800,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
// "output" (the type of the constant).
assert_eq!(self.mir_def.to_def_id(), def_id);
let ty = tcx.type_of(self.mir_def).instantiate_identity();

let ty = indices.fold_to_region_vids(tcx, ty);
ty::Binder::dummy(tcx.mk_type_list(&[ty]))
}
Expand All @@ -807,7 +810,14 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
let ty = args.as_inline_const().ty();
ty::Binder::dummy(tcx.mk_type_list(&[ty]))
}
};

// FIXME(#129952): We probably want a more principled approach here.
if let Err(terr) = inputs_and_output.skip_binder().error_reported() {
self.infcx.set_tainted_by_errors(terr);
}

inputs_and_output
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl<'ll> CodegenCx<'ll, '_> {
let val_llty = self.val_ty(v);

let g = self.get_static_inner(def_id, val_llty);
let llty = self.val_ty(g);
let llty = llvm::LLVMGlobalGetValueType(g);

let g = if val_llty == llty {
g
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ pub(crate) fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) ->
if def.is_box()
&& args.get(1).map_or(true, |arg| cx.layout_of(arg.expect_ty()).is_1zst()) =>
{
build_pointer_or_reference_di_node(cx, t, t.boxed_ty(), unique_type_id)
build_pointer_or_reference_di_node(cx, t, t.expect_boxed_ty(), unique_type_id)
}
ty::FnDef(..) | ty::FnPtr(..) => build_subroutine_type_di_node(cx, unique_type_id),
ty::Closure(..) => build_closure_env_di_node(cx, unique_type_id),
Expand Down
17 changes: 10 additions & 7 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
Some(instance),
)
}
sym::likely => {
self.call_intrinsic("llvm.expect.i1", &[args[0].immediate(), self.const_bool(true)])
}
sym::likely => self.expect(args[0].immediate(), true),
sym::is_val_statically_known => {
let intrinsic_type = args[0].layout.immediate_llvm_type(self.cx);
let kind = self.type_kind(intrinsic_type);
Expand All @@ -210,8 +208,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
self.const_bool(false)
}
}
sym::unlikely => self
.call_intrinsic("llvm.expect.i1", &[args[0].immediate(), self.const_bool(false)]),
sym::unlikely => self.expect(args[0].immediate(), false),
sym::select_unpredictable => {
let cond = args[0].immediate();
assert_eq!(args[1].layout, args[2].layout);
Expand Down Expand Up @@ -604,11 +601,17 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
}

fn assume(&mut self, val: Self::Value) {
self.call_intrinsic("llvm.assume", &[val]);
if self.cx.sess().opts.optimize != rustc_session::config::OptLevel::No {
self.call_intrinsic("llvm.assume", &[val]);
}
}

fn expect(&mut self, cond: Self::Value, expected: bool) -> Self::Value {
self.call_intrinsic("llvm.expect.i1", &[cond, self.const_bool(expected)])
if self.cx.sess().opts.optimize != rustc_session::config::OptLevel::No {
self.call_intrinsic("llvm.expect.i1", &[cond, self.const_bool(expected)])
} else {
cond
}
}

fn type_test(&mut self, pointer: Self::Value, typeid: Self::Value) -> Self::Value {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,7 @@ unsafe extern "C" {
pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
pub fn LLVMGlobalGetValueType(Global: &Value) -> &Type;

// Operations on global variables
pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/mir/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
scalar: abi::Scalar,
backend_ty: Bx::Type,
) {
if matches!(self.cx.sess().opts.optimize, OptLevel::No | OptLevel::Less)
if matches!(self.cx.sess().opts.optimize, OptLevel::No)
// For now, the critical niches are all over `Int`eger values.
// Should floating-point values or pointers ever get more complex
// niches, then this code will probably want to handle them too.
Expand Down
Loading