Skip to content

Rollup of 8 pull requests #141628

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

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 61 additions & 22 deletions compiler/rustc_codegen_llvm/src/va_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,33 @@ fn emit_direct_ptr_va_arg<'ll, 'tcx>(
}
}

enum PassMode {
Direct,
Indirect,
}

enum SlotSize {
Bytes8 = 8,
Bytes4 = 4,
}

enum AllowHigherAlign {
No,
Yes,
}

fn emit_ptr_va_arg<'ll, 'tcx>(
bx: &mut Builder<'_, 'll, 'tcx>,
list: OperandRef<'tcx, &'ll Value>,
target_ty: Ty<'tcx>,
indirect: bool,
slot_size: Align,
allow_higher_align: bool,
pass_mode: PassMode,
slot_size: SlotSize,
allow_higher_align: AllowHigherAlign,
) -> &'ll Value {
let indirect = matches!(pass_mode, PassMode::Indirect);
let allow_higher_align = matches!(allow_higher_align, AllowHigherAlign::Yes);
let slot_size = Align::from_bytes(slot_size as u64).unwrap();

let layout = bx.cx.layout_of(target_ty);
let (llty, size, align) = if indirect {
(
Expand Down Expand Up @@ -179,8 +198,14 @@ fn emit_aapcs_va_arg<'ll, 'tcx>(

// On Stack block
bx.switch_to_block(on_stack);
let stack_value =
emit_ptr_va_arg(bx, list, target_ty, false, Align::from_bytes(8).unwrap(), true);
let stack_value = emit_ptr_va_arg(
bx,
list,
target_ty,
PassMode::Direct,
SlotSize::Bytes8,
AllowHigherAlign::Yes,
);
bx.br(end);

bx.switch_to_block(end);
Expand Down Expand Up @@ -386,29 +411,43 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
// Determine the va_arg implementation to use. The LLVM va_arg instruction
// is lacking in some instances, so we should only use it as a fallback.
let target = &bx.cx.tcx.sess.target;
let arch = &bx.cx.tcx.sess.target.arch;
match &**arch {
// Windows x86
"x86" if target.is_like_windows => {
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(4).unwrap(), false)
}
// Generic x86
"x86" => emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(4).unwrap(), true),
// Windows AArch64
"aarch64" | "arm64ec" if target.is_like_windows => {
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), false)
}
// macOS / iOS AArch64
"aarch64" if target.is_like_darwin => {
emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), true)

match &*target.arch {
"x86" => emit_ptr_va_arg(
bx,
addr,
target_ty,
PassMode::Direct,
SlotSize::Bytes4,
if target.is_like_windows { AllowHigherAlign::No } else { AllowHigherAlign::Yes },
),
"aarch64" | "arm64ec" if target.is_like_windows || target.is_like_darwin => {
emit_ptr_va_arg(
bx,
addr,
target_ty,
PassMode::Direct,
SlotSize::Bytes8,
if target.is_like_windows { AllowHigherAlign::No } else { AllowHigherAlign::Yes },
)
}
"aarch64" => emit_aapcs_va_arg(bx, addr, target_ty),
"s390x" => emit_s390x_va_arg(bx, addr, target_ty),
// Windows x86_64
"x86_64" if target.is_like_windows => {
let target_ty_size = bx.cx.size_of(target_ty).bytes();
let indirect: bool = target_ty_size > 8 || !target_ty_size.is_power_of_two();
emit_ptr_va_arg(bx, addr, target_ty, indirect, Align::from_bytes(8).unwrap(), false)
emit_ptr_va_arg(
bx,
addr,
target_ty,
if target_ty_size > 8 || !target_ty_size.is_power_of_two() {
PassMode::Indirect
} else {
PassMode::Direct
},
SlotSize::Bytes8,
AllowHigherAlign::No,
)
}
"xtensa" => emit_xtensa_va_arg(bx, addr, target_ty),
// For all other architecture/OS combinations fall back to using
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
));
self.note("consider using `--verbose` to print the full type name to the console");
}
Box::into_inner(self.diag.take().unwrap())
*self.diag.take().unwrap()
}

/// This method allows us to access the path of the file where "long types" are written to.
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#![feature(array_windows)]
#![feature(assert_matches)]
#![feature(associated_type_defaults)]
#![feature(box_into_inner)]
#![feature(box_patterns)]
#![feature(default_field_values)]
#![feature(error_reporter)]
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_ty_utils/src/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,10 @@ fn opaque_types_defined_by<'tcx>(
collector.collect_taits_declared_in_body();
}
// Closures and coroutines are type checked with their parent
DefKind::Closure | DefKind::InlineConst => {
// Note that we also support `SyntheticCoroutineBody` since we create
// a MIR body for the def kind, and some MIR passes (like promotion)
// may require doing analysis using its typing env.
DefKind::Closure | DefKind::InlineConst | DefKind::SyntheticCoroutineBody => {
collector.opaques.extend(tcx.opaque_types_defined_by(tcx.local_parent(item)));
}
DefKind::AssocTy | DefKind::TyAlias | DefKind::GlobalAsm => {}
Expand All @@ -343,8 +346,7 @@ fn opaque_types_defined_by<'tcx>(
| DefKind::ForeignMod
| DefKind::Field
| DefKind::LifetimeParam
| DefKind::Impl { .. }
| DefKind::SyntheticCoroutineBody => {
| DefKind::Impl { .. } => {
span_bug!(
tcx.def_span(item),
"`opaque_types_defined_by` not defined for {} `{item:?}`",
Expand Down
4 changes: 2 additions & 2 deletions src/doc/rustc/src/check-cfg/cargo-specifics.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ rustc, not Cargo.
-->

This document is intended to summarize the principal ways Cargo interacts with
the `unexpected_cfgs` lint and `--check-cfg` flag. It is not intended to provide
individual details, for that refer to the [`--check-cfg` documentation](../check-cfg.md) and
the `unexpected_cfgs` lint and `--check-cfg` flag.
For individual details, refer to the [`--check-cfg` documentation](../check-cfg.md) and
to the [Cargo book](../../cargo/index.html).

> The full list of well known cfgs (aka builtins) can be found under [Checking conditional configurations / Well known names and values](../check-cfg.md#well-known-names-and-values).
Expand Down
4 changes: 2 additions & 2 deletions src/tools/rustbook/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -885,9 +885,9 @@ dependencies = [

[[package]]
name = "mdbook"
version = "0.4.50"
version = "0.4.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f72bc08f096e1fb15cfc382babe218317c2897d2040f967c4db40d156ca28e21"
checksum = "a87e65420ab45ca9c1b8cdf698f95b710cc826d373fa550f0f7fad82beac9328"
dependencies = [
"ammonia",
"anyhow",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rustbook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ mdbook-i18n-helpers = "0.3.3"
mdbook-spec = { path = "../../doc/reference/mdbook-spec" }

[dependencies.mdbook]
version = "0.4.50"
version = "0.4.51"
default-features = false
features = ["search"]
13 changes: 13 additions & 0 deletions tests/ui/async-await/async-closures/promote-in-body.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@ build-pass
//@ compile-flags: --crate-type=lib
//@ edition: 2024

union U {
f: i32,
}

fn foo() {
async || {
&U { f: 1 }
};
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ edition:2015
//@ check-pass
// Make sure that we don't eagerly recover `async ::Bound` in edition 2015.

Expand Down
1 change: 1 addition & 0 deletions tests/ui/async-await/async-fn/edition-2015.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ edition:2015
fn foo(x: impl async Fn()) -> impl async Fn() { x }
//~^ ERROR `async` trait bounds are only allowed in Rust 2018 or later
//~| ERROR `async` trait bounds are only allowed in Rust 2018 or later
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/async-await/async-fn/edition-2015.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `async` trait bounds are only allowed in Rust 2018 or later
--> $DIR/edition-2015.rs:1:16
--> $DIR/edition-2015.rs:2:16
|
LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
| ^^^^^
Expand All @@ -8,7 +8,7 @@ LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
= note: for more on editions, read https://doc.rust-lang.org/edition-guide

error: `async` trait bounds are only allowed in Rust 2018 or later
--> $DIR/edition-2015.rs:1:36
--> $DIR/edition-2015.rs:2:36
|
LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
| ^^^^^
Expand All @@ -17,7 +17,7 @@ LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
= note: for more on editions, read https://doc.rust-lang.org/edition-guide

error[E0658]: `async` trait bounds are unstable
--> $DIR/edition-2015.rs:1:16
--> $DIR/edition-2015.rs:2:16
|
LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
| ^^^^^
Expand All @@ -28,7 +28,7 @@ LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
= help: use the desugared name of the async trait, such as `AsyncFn`

error[E0658]: `async` trait bounds are unstable
--> $DIR/edition-2015.rs:1:36
--> $DIR/edition-2015.rs:2:36
|
LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
| ^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ edition:2015
#![allow(non_camel_case_types)]
#![deny(keyword_idents)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
error: `await` is a keyword in the 2018 edition
--> $DIR/2015-edition-error-various-positions.rs:5:13
--> $DIR/2015-edition-error-various-positions.rs:6:13
|
LL | pub mod await {
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
note: the lint level is defined here
--> $DIR/2015-edition-error-various-positions.rs:2:9
--> $DIR/2015-edition-error-various-positions.rs:3:9
|
LL | #![deny(keyword_idents)]
| ^^^^^^^^^^^^^^
= note: `#[deny(keyword_idents_2018)]` implied by `#[deny(keyword_idents)]`

error: `await` is a keyword in the 2018 edition
--> $DIR/2015-edition-error-various-positions.rs:7:20
--> $DIR/2015-edition-error-various-positions.rs:8:20
|
LL | pub struct await;
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -23,7 +23,7 @@ LL | pub struct await;
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: `await` is a keyword in the 2018 edition
--> $DIR/2015-edition-error-various-positions.rs:11:16
--> $DIR/2015-edition-error-various-positions.rs:12:16
|
LL | use outer_mod::await::await;
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -32,7 +32,7 @@ LL | use outer_mod::await::await;
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: `await` is a keyword in the 2018 edition
--> $DIR/2015-edition-error-various-positions.rs:11:23
--> $DIR/2015-edition-error-various-positions.rs:12:23
|
LL | use outer_mod::await::await;
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -41,7 +41,7 @@ LL | use outer_mod::await::await;
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: `await` is a keyword in the 2018 edition
--> $DIR/2015-edition-error-various-positions.rs:16:14
--> $DIR/2015-edition-error-various-positions.rs:17:14
|
LL | struct Foo { await: () }
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -50,7 +50,7 @@ LL | struct Foo { await: () }
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: `await` is a keyword in the 2018 edition
--> $DIR/2015-edition-error-various-positions.rs:20:15
--> $DIR/2015-edition-error-various-positions.rs:21:15
|
LL | impl Foo { fn await() {} }
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -59,7 +59,7 @@ LL | impl Foo { fn await() {} }
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: `await` is a keyword in the 2018 edition
--> $DIR/2015-edition-error-various-positions.rs:24:14
--> $DIR/2015-edition-error-various-positions.rs:25:14
|
LL | macro_rules! await {
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -68,7 +68,7 @@ LL | macro_rules! await {
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: `await` is a keyword in the 2018 edition
--> $DIR/2015-edition-error-various-positions.rs:31:5
--> $DIR/2015-edition-error-various-positions.rs:32:5
|
LL | await!();
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -77,7 +77,7 @@ LL | await!();
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: `await` is a keyword in the 2018 edition
--> $DIR/2015-edition-error-various-positions.rs:34:11
--> $DIR/2015-edition-error-various-positions.rs:35:11
|
LL | match await { await => {} }
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand All @@ -86,7 +86,7 @@ LL | match await { await => {} }
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>

error: `await` is a keyword in the 2018 edition
--> $DIR/2015-edition-error-various-positions.rs:34:19
--> $DIR/2015-edition-error-various-positions.rs:35:19
|
LL | match await { await => {} }
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ edition:2015
//@ run-rustfix

#![allow(non_camel_case_types)]
Expand Down
1 change: 1 addition & 0 deletions tests/ui/async-await/await-keyword/2015-edition-warning.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ edition:2015
//@ run-rustfix

#![allow(non_camel_case_types)]
Expand Down
Loading