Skip to content

Commit 6250d5a

Browse files
committed
Auto merge of rust-lang#93427 - matthiaskrgr:rollup-esd3ixl, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#92611 (Add links to the reference and rust by example for asm! docs and lints) - rust-lang#93158 (wasi: implement `sock_accept` and enable networking) - rust-lang#93239 (Add os::unix::net::SocketAddr::from_path) - rust-lang#93261 (Some unwinding related cg_ssa cleanups) - rust-lang#93295 (Avoid double panics when using `TempDir` in tests) - rust-lang#93353 (Unimpl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}<$t> for Saturating<$t>) - rust-lang#93356 (Edit docs introduction for `std::cmp::PartialOrd`) - rust-lang#93375 (fix typo `documenation`) - rust-lang#93399 (rustbuild: Fix compiletest warning when building outside of root.) - rust-lang#93404 (Fix a typo from rust-lang#92899) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents e0a55f4 + 27f6821 commit 6250d5a

File tree

28 files changed

+321
-254
lines changed

28 files changed

+321
-254
lines changed

Cargo.lock

+9-3
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
14731473
dependencies = [
14741474
"cfg-if 0.1.10",
14751475
"libc",
1476-
"wasi",
1476+
"wasi 0.9.0+wasi-snapshot-preview1",
14771477
]
14781478

14791479
[[package]]
@@ -1484,7 +1484,7 @@ checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4"
14841484
dependencies = [
14851485
"cfg-if 0.1.10",
14861486
"libc",
1487-
"wasi",
1487+
"wasi 0.9.0+wasi-snapshot-preview1",
14881488
]
14891489

14901490
[[package]]
@@ -4854,7 +4854,7 @@ dependencies = [
48544854
"rustc-demangle",
48554855
"std_detect",
48564856
"unwind",
4857-
"wasi",
4857+
"wasi 0.11.0+wasi-snapshot-preview1",
48584858
]
48594859

48604860
[[package]]
@@ -5612,6 +5612,12 @@ name = "wasi"
56125612
version = "0.9.0+wasi-snapshot-preview1"
56135613
source = "registry+https://github.com/rust-lang/crates.io-index"
56145614
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
5615+
5616+
[[package]]
5617+
name = "wasi"
5618+
version = "0.11.0+wasi-snapshot-preview1"
5619+
source = "registry+https://github.com/rust-lang/crates.io-index"
5620+
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
56155621
dependencies = [
56165622
"compiler_builtins",
56175623
"rustc-std-workspace-alloc",

compiler/rustc_codegen_gcc/src/builder.rs

+13-16
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
12561256
aggregate_value
12571257
}
12581258

1259-
fn landing_pad(&mut self, _ty: Type<'gcc>, _pers_fn: RValue<'gcc>, _num_clauses: usize) -> RValue<'gcc> {
1259+
fn set_personality_fn(&mut self, _personality: RValue<'gcc>) {
1260+
// TODO(antoyo)
1261+
}
1262+
1263+
fn cleanup_landing_pad(&mut self, _ty: Type<'gcc>, _pers_fn: RValue<'gcc>) -> RValue<'gcc> {
12601264
let field1 = self.context.new_field(None, self.u8_type, "landing_pad_field_1");
12611265
let field2 = self.context.new_field(None, self.i32_type, "landing_pad_field_1");
12621266
let struct_type = self.context.new_struct_type(None, "landing_pad", &[field1, field2]);
@@ -1267,38 +1271,31 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
12671271
// rustc_codegen_ssa now calls the unwinding builder methods even on panic=abort.
12681272
}
12691273

1270-
fn set_cleanup(&mut self, _landing_pad: RValue<'gcc>) {
1271-
// TODO(antoyo)
1272-
}
1273-
1274-
fn resume(&mut self, _exn: RValue<'gcc>) -> RValue<'gcc> {
1274+
fn resume(&mut self, _exn: RValue<'gcc>) {
12751275
unimplemented!();
12761276
}
12771277

12781278
fn cleanup_pad(&mut self, _parent: Option<RValue<'gcc>>, _args: &[RValue<'gcc>]) -> Funclet {
12791279
unimplemented!();
12801280
}
12811281

1282-
fn cleanup_ret(&mut self, _funclet: &Funclet, _unwind: Option<Block<'gcc>>) -> RValue<'gcc> {
1282+
fn cleanup_ret(&mut self, _funclet: &Funclet, _unwind: Option<Block<'gcc>>) {
12831283
unimplemented!();
12841284
}
12851285

12861286
fn catch_pad(&mut self, _parent: RValue<'gcc>, _args: &[RValue<'gcc>]) -> Funclet {
12871287
unimplemented!();
12881288
}
12891289

1290-
fn catch_switch(&mut self, _parent: Option<RValue<'gcc>>, _unwind: Option<Block<'gcc>>, _num_handlers: usize) -> RValue<'gcc> {
1290+
fn catch_switch(
1291+
&mut self,
1292+
_parent: Option<RValue<'gcc>>,
1293+
_unwind: Option<Block<'gcc>>,
1294+
_handlers: &[Block<'gcc>],
1295+
) -> RValue<'gcc> {
12911296
unimplemented!();
12921297
}
12931298

1294-
fn add_handler(&mut self, _catch_switch: RValue<'gcc>, _handler: Block<'gcc>) {
1295-
unimplemented!();
1296-
}
1297-
1298-
fn set_personality_fn(&mut self, _personality: RValue<'gcc>) {
1299-
// TODO(antoyo)
1300-
}
1301-
13021299
// Atomic Operations
13031300
fn atomic_cmpxchg(&mut self, dst: RValue<'gcc>, cmp: RValue<'gcc>, src: RValue<'gcc>, order: AtomicOrdering, failure_order: AtomicOrdering, weak: bool) -> RValue<'gcc> {
13041301
let expected = self.current_func().new_local(None, cmp.get_type(), "expected");

compiler/rustc_codegen_llvm/src/builder.rs

+37-36
Original file line numberDiff line numberDiff line change
@@ -956,29 +956,24 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
956956
unsafe { llvm::LLVMBuildInsertValue(self.llbuilder, agg_val, elt, idx as c_uint, UNNAMED) }
957957
}
958958

959-
fn landing_pad(
960-
&mut self,
961-
ty: &'ll Type,
962-
pers_fn: &'ll Value,
963-
num_clauses: usize,
964-
) -> &'ll Value {
965-
// Use LLVMSetPersonalityFn to set the personality. It supports arbitrary Consts while,
966-
// LLVMBuildLandingPad requires the argument to be a Function (as of LLVM 12). The
967-
// personality lives on the parent function anyway.
968-
self.set_personality_fn(pers_fn);
959+
fn set_personality_fn(&mut self, personality: &'ll Value) {
969960
unsafe {
970-
llvm::LLVMBuildLandingPad(self.llbuilder, ty, None, num_clauses as c_uint, UNNAMED)
961+
llvm::LLVMSetPersonalityFn(self.llfn(), personality);
971962
}
972963
}
973964

974-
fn set_cleanup(&mut self, landing_pad: &'ll Value) {
965+
fn cleanup_landing_pad(&mut self, ty: &'ll Type, pers_fn: &'ll Value) -> &'ll Value {
966+
let landing_pad = self.landing_pad(ty, pers_fn, 1 /* FIXME should this be 0? */);
975967
unsafe {
976968
llvm::LLVMSetCleanup(landing_pad, llvm::True);
977969
}
970+
landing_pad
978971
}
979972

980-
fn resume(&mut self, exn: &'ll Value) -> &'ll Value {
981-
unsafe { llvm::LLVMBuildResume(self.llbuilder, exn) }
973+
fn resume(&mut self, exn: &'ll Value) {
974+
unsafe {
975+
llvm::LLVMBuildResume(self.llbuilder, exn);
976+
}
982977
}
983978

984979
fn cleanup_pad(&mut self, parent: Option<&'ll Value>, args: &[&'ll Value]) -> Funclet<'ll> {
@@ -995,14 +990,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
995990
Funclet::new(ret.expect("LLVM does not have support for cleanuppad"))
996991
}
997992

998-
fn cleanup_ret(
999-
&mut self,
1000-
funclet: &Funclet<'ll>,
1001-
unwind: Option<&'ll BasicBlock>,
1002-
) -> &'ll Value {
1003-
let ret =
1004-
unsafe { llvm::LLVMRustBuildCleanupRet(self.llbuilder, funclet.cleanuppad(), unwind) };
1005-
ret.expect("LLVM does not have support for cleanupret")
993+
fn cleanup_ret(&mut self, funclet: &Funclet<'ll>, unwind: Option<&'ll BasicBlock>) {
994+
unsafe {
995+
llvm::LLVMRustBuildCleanupRet(self.llbuilder, funclet.cleanuppad(), unwind)
996+
.expect("LLVM does not have support for cleanupret");
997+
}
1006998
}
1007999

10081000
fn catch_pad(&mut self, parent: &'ll Value, args: &[&'ll Value]) -> Funclet<'ll> {
@@ -1023,31 +1015,25 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
10231015
&mut self,
10241016
parent: Option<&'ll Value>,
10251017
unwind: Option<&'ll BasicBlock>,
1026-
num_handlers: usize,
1018+
handlers: &[&'ll BasicBlock],
10271019
) -> &'ll Value {
10281020
let name = cstr!("catchswitch");
10291021
let ret = unsafe {
10301022
llvm::LLVMRustBuildCatchSwitch(
10311023
self.llbuilder,
10321024
parent,
10331025
unwind,
1034-
num_handlers as c_uint,
1026+
handlers.len() as c_uint,
10351027
name.as_ptr(),
10361028
)
10371029
};
1038-
ret.expect("LLVM does not have support for catchswitch")
1039-
}
1040-
1041-
fn add_handler(&mut self, catch_switch: &'ll Value, handler: &'ll BasicBlock) {
1042-
unsafe {
1043-
llvm::LLVMRustAddHandler(catch_switch, handler);
1044-
}
1045-
}
1046-
1047-
fn set_personality_fn(&mut self, personality: &'ll Value) {
1048-
unsafe {
1049-
llvm::LLVMSetPersonalityFn(self.llfn(), personality);
1030+
let ret = ret.expect("LLVM does not have support for catchswitch");
1031+
for handler in handlers {
1032+
unsafe {
1033+
llvm::LLVMRustAddHandler(ret, handler);
1034+
}
10501035
}
1036+
ret
10511037
}
10521038

10531039
// Atomic Operations
@@ -1478,4 +1464,19 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
14781464
None
14791465
}
14801466
}
1467+
1468+
pub(crate) fn landing_pad(
1469+
&mut self,
1470+
ty: &'ll Type,
1471+
pers_fn: &'ll Value,
1472+
num_clauses: usize,
1473+
) -> &'ll Value {
1474+
// Use LLVMSetPersonalityFn to set the personality. It supports arbitrary Consts while,
1475+
// LLVMBuildLandingPad requires the argument to be a Function (as of LLVM 12). The
1476+
// personality lives on the parent function anyway.
1477+
self.set_personality_fn(pers_fn);
1478+
unsafe {
1479+
llvm::LLVMBuildLandingPad(self.llbuilder, ty, None, num_clauses as c_uint, UNNAMED)
1480+
}
1481+
}
14811482
}

compiler/rustc_codegen_llvm/src/intrinsic.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,8 @@ fn codegen_msvc_try<'ll>(
525525

526526
normal.ret(bx.const_i32(0));
527527

528-
let cs = catchswitch.catch_switch(None, None, 2);
529-
catchswitch.add_handler(cs, catchpad_rust.llbb());
530-
catchswitch.add_handler(cs, catchpad_foreign.llbb());
528+
let cs =
529+
catchswitch.catch_switch(None, None, &[catchpad_rust.llbb(), catchpad_foreign.llbb()]);
531530

532531
// We can't use the TypeDescriptor defined in libpanic_unwind because it
533532
// might be in another DLL and the SEH encoding only supports specifying

compiler/rustc_codegen_ssa/src/mir/block.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1346,8 +1346,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
13461346
let mut cp_bx = self.new_block(&format!("cp_funclet{:?}", bb));
13471347
ret_llbb = cs_bx.llbb();
13481348

1349-
let cs = cs_bx.catch_switch(None, None, 1);
1350-
cs_bx.add_handler(cs, cp_bx.llbb());
1349+
let cs = cs_bx.catch_switch(None, None, &[cp_bx.llbb()]);
13511350

13521351
// The "null" here is actually a RTTI type descriptor for the
13531352
// C++ personality function, but `catch (...)` has no type so
@@ -1374,8 +1373,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
13741373

13751374
let llpersonality = self.cx.eh_personality();
13761375
let llretty = self.landing_pad_type();
1377-
let lp = bx.landing_pad(llretty, llpersonality, 1);
1378-
bx.set_cleanup(lp);
1376+
let lp = bx.cleanup_landing_pad(llretty, llpersonality);
13791377

13801378
let slot = self.get_personality_slot(&mut bx);
13811379
slot.storage_live(&mut bx);

compiler/rustc_codegen_ssa/src/traits/builder.rs

+9-16
Original file line numberDiff line numberDiff line change
@@ -421,29 +421,22 @@ pub trait BuilderMethods<'a, 'tcx>:
421421
fn extract_value(&mut self, agg_val: Self::Value, idx: u64) -> Self::Value;
422422
fn insert_value(&mut self, agg_val: Self::Value, elt: Self::Value, idx: u64) -> Self::Value;
423423

424-
fn landing_pad(
425-
&mut self,
426-
ty: Self::Type,
427-
pers_fn: Self::Value,
428-
num_clauses: usize,
429-
) -> Self::Value;
430-
fn set_cleanup(&mut self, landing_pad: Self::Value);
431-
fn resume(&mut self, exn: Self::Value) -> Self::Value;
424+
fn set_personality_fn(&mut self, personality: Self::Value);
425+
426+
// These are used by everyone except msvc
427+
fn cleanup_landing_pad(&mut self, ty: Self::Type, pers_fn: Self::Value) -> Self::Value;
428+
fn resume(&mut self, exn: Self::Value);
429+
430+
// These are used only by msvc
432431
fn cleanup_pad(&mut self, parent: Option<Self::Value>, args: &[Self::Value]) -> Self::Funclet;
433-
fn cleanup_ret(
434-
&mut self,
435-
funclet: &Self::Funclet,
436-
unwind: Option<Self::BasicBlock>,
437-
) -> Self::Value;
432+
fn cleanup_ret(&mut self, funclet: &Self::Funclet, unwind: Option<Self::BasicBlock>);
438433
fn catch_pad(&mut self, parent: Self::Value, args: &[Self::Value]) -> Self::Funclet;
439434
fn catch_switch(
440435
&mut self,
441436
parent: Option<Self::Value>,
442437
unwind: Option<Self::BasicBlock>,
443-
num_handlers: usize,
438+
handlers: &[Self::BasicBlock],
444439
) -> Self::Value;
445-
fn add_handler(&mut self, catch_switch: Self::Value, handler: Self::BasicBlock);
446-
fn set_personality_fn(&mut self, personality: Self::Value);
447440

448441
fn atomic_cmpxchg(
449442
&mut self,

compiler/rustc_lint/src/builtin.rs

+3
Original file line numberDiff line numberDiff line change
@@ -3158,7 +3158,10 @@ declare_lint! {
31583158
/// of this, GNU assembler [local labels] *must* be used instead of labels
31593159
/// with a name. Using named labels might cause assembler or linker errors.
31603160
///
3161+
/// See the explanation in [Rust By Example] for more details.
3162+
///
31613163
/// [local labels]: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Local-Labels
3164+
/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels
31623165
pub NAMED_ASM_LABELS,
31633166
Deny,
31643167
"named labels in inline assembly",

compiler/rustc_lint/src/context.rs

+1
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ pub trait LintContext: Sized {
762762
}
763763
BuiltinLintDiagnostics::NamedAsmLabel(help) => {
764764
db.help(&help);
765+
db.note("see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information");
765766
}
766767
}
767768
// Rewrap `db`, and pass control to the user.

compiler/rustc_lint_defs/src/builtin.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2456,6 +2456,10 @@ declare_lint! {
24562456
/// register size, to alert you of possibly using the incorrect width. To
24572457
/// fix this, add the suggested modifier to the template, or cast the
24582458
/// value to the correct size.
2459+
///
2460+
/// See [register template modifiers] in the reference for more details.
2461+
///
2462+
/// [register template modifiers]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html#template-modifiers
24592463
pub ASM_SUB_REGISTER,
24602464
Warn,
24612465
"using only a subset of a register for inline asm inputs",

library/core/src/cmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ impl PartialOrd for Ordering {
880880
}
881881
}
882882

883-
/// Trait for values that can be compared for a sort-order.
883+
/// Trait for types that form a [partial order](https://en.wikipedia.org/wiki/Partial_order).
884884
///
885885
/// The `lt`, `le`, `gt`, and `ge` methods of this trait can be called using
886886
/// the `<`, `<=`, `>`, and `>=` operators, respectively.

library/core/src/iter/traits/iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ pub trait Iterator {
515515
/// assert_eq!((2, 'o'), zipper[2]);
516516
/// ```
517517
///
518-
/// If both iterators have roughly equivalent syntax, it may me more readable to use [`zip`]:
518+
/// If both iterators have roughly equivalent syntax, it may be more readable to use [`zip`]:
519519
///
520520
/// ```
521521
/// use std::iter::zip;

library/core/src/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,25 @@ pub mod arch {
374374
pub use crate::core_arch::arch::*;
375375

376376
/// Inline assembly.
377+
///
378+
/// Refer to [rust by example] for a usage guide and the [reference] for
379+
/// detailed information about the syntax and available options.
380+
///
381+
/// [rust by example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
382+
/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html
377383
#[stable(feature = "asm", since = "1.59.0")]
378384
#[rustc_builtin_macro]
379385
pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
380386
/* compiler built-in */
381387
}
382388
383389
/// Module-level inline assembly.
390+
///
391+
/// Refer to [rust by example] for a usage guide and the [reference] for
392+
/// detailed information about the syntax and available options.
393+
///
394+
/// [rust by example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
395+
/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html
384396
#[stable(feature = "global_asm", since = "1.59.0")]
385397
#[rustc_builtin_macro]
386398
pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))?) {

0 commit comments

Comments
 (0)