Skip to content

Commit 6741521

Browse files
committed
Auto merge of rust-lang#136572 - jieyouxu:rollup-mtyaisw, r=jieyouxu
Rollup of 12 pull requests Successful merges: - rust-lang#132547 (cg_gcc: Directly use rustc_abi instead of reexports) - rust-lang#135572 (tests: Port `split-debuginfo` to rmake.rs) - rust-lang#135964 (Make cenum_impl_drop_cast a hard error) - rust-lang#136154 (Use +secure-plt for powerpc-unknown-linux-gnu{,spe}) - rust-lang#136304 (Reject negative literals for unsigned or char types in pattern ranges and literals) - rust-lang#136418 (uefi: process: Add support for command environment variables) - rust-lang#136449 (std: move network code into `sys`) - rust-lang#136517 (implement inherent str constructors) - rust-lang#136536 (Rename and Move some UI tests to more suitable subdirs) - rust-lang#136537 (Update `compiler-builtins` to 0.1.145) - rust-lang#136555 (Rename `slice::take...` methods to `split_off...`) - rust-lang#136567 (Arbitrary self types v2: recursion test) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a9730c3 + eeef079 commit 6741521

File tree

114 files changed

+2359
-1785
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+2359
-1785
lines changed

compiler/rustc_codegen_cranelift/patches/0029-stdlib-Disable-f16-and-f128-in-compiler-builtins.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ index 7165c3e48af..968552ad435 100644
1616

1717
[dependencies]
1818
core = { path = "../core" }
19-
-compiler_builtins = { version = "=0.1.143", features = ['rustc-dep-of-std'] }
20-
+compiler_builtins = { version = "=0.1.143", features = ['rustc-dep-of-std', 'no-f16-f128'] }
19+
-compiler_builtins = { version = "=0.1.145", features = ['rustc-dep-of-std'] }
20+
+compiler_builtins = { version = "=0.1.145", features = ['rustc-dep-of-std', 'no-f16-f128'] }
2121

2222
[dev-dependencies]
2323
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }

compiler/rustc_codegen_gcc/src/abi.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_middle::ty::Ty;
88
use rustc_middle::ty::layout::LayoutOf;
99
#[cfg(feature = "master")]
1010
use rustc_session::config;
11-
use rustc_target::abi::call::{ArgAttributes, CastTarget, FnAbi, PassMode, Reg, RegKind};
11+
use rustc_target::callconv::{ArgAttributes, CastTarget, FnAbi, PassMode, Reg, RegKind};
1212

1313
use crate::builder::Builder;
1414
use crate::context::CodegenCx;
@@ -132,10 +132,10 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
132132
if cx.sess().opts.optimize == config::OptLevel::No {
133133
return ty;
134134
}
135-
if attrs.regular.contains(rustc_target::abi::call::ArgAttribute::NoAlias) {
135+
if attrs.regular.contains(rustc_target::callconv::ArgAttribute::NoAlias) {
136136
ty = ty.make_restrict()
137137
}
138-
if attrs.regular.contains(rustc_target::abi::call::ArgAttribute::NonNull) {
138+
if attrs.regular.contains(rustc_target::callconv::ArgAttribute::NonNull) {
139139
non_null_args.push(arg_index as i32 + 1);
140140
}
141141
ty

compiler/rustc_codegen_gcc/src/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use rustc_middle::ty::layout::{
2929
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
3030
use rustc_span::Span;
3131
use rustc_span::def_id::DefId;
32-
use rustc_target::abi::call::FnAbi;
32+
use rustc_target::callconv::FnAbi;
3333
use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, Target, WasmCAbi, X86Abi};
3434

3535
use crate::common::{SignType, TypeReflection, type_is_pointer};

compiler/rustc_codegen_gcc/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#[cfg(feature = "master")]
22
use gccjit::{FnAttribute, VarAttribute, Visibility};
33
use gccjit::{Function, GlobalKind, LValue, RValue, ToRValue, Type};
4+
use rustc_abi::{self as abi, Align, HasDataLayout, Primitive, Size, WrappingRange};
45
use rustc_codegen_ssa::traits::{
56
BaseTypeCodegenMethods, ConstCodegenMethods, StaticCodegenMethods,
67
};
@@ -14,7 +15,6 @@ use rustc_middle::ty::layout::LayoutOf;
1415
use rustc_middle::ty::{self, Instance};
1516
use rustc_middle::{bug, span_bug};
1617
use rustc_span::def_id::DefId;
17-
use rustc_target::abi::{self, Align, HasDataLayout, Primitive, Size, WrappingRange};
1818

1919
use crate::base;
2020
use crate::context::CodegenCx;

compiler/rustc_codegen_gcc/src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::cell::{Cell, RefCell};
33
use gccjit::{
44
Block, CType, Context, Function, FunctionPtrType, FunctionType, LValue, Location, RValue, Type,
55
};
6+
use rustc_abi::{HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx};
67
use rustc_codegen_ssa::base::wants_msvc_seh;
78
use rustc_codegen_ssa::errors as ssa_errors;
89
use rustc_codegen_ssa::traits::{BackendTypes, BaseTypeCodegenMethods, MiscCodegenMethods};
@@ -18,7 +19,6 @@ use rustc_middle::ty::{self, ExistentialTraitRef, Instance, Ty, TyCtxt};
1819
use rustc_session::Session;
1920
use rustc_span::source_map::respan;
2021
use rustc_span::{DUMMY_SP, Span};
21-
use rustc_target::abi::{HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx};
2222
use rustc_target::spec::{
2323
HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, Target, TlsModel, WasmCAbi, X86Abi,
2424
};

compiler/rustc_codegen_gcc/src/debuginfo.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::ops::Range;
22

33
use gccjit::{Location, RValue};
4+
use rustc_abi::Size;
45
use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind};
56
use rustc_codegen_ssa::traits::{DebugInfoBuilderMethods, DebugInfoCodegenMethods};
67
use rustc_data_structures::sync::Lrc;
@@ -10,8 +11,7 @@ use rustc_middle::mir::{self, Body, SourceScope};
1011
use rustc_middle::ty::{ExistentialTraitRef, Instance, Ty};
1112
use rustc_session::config::DebugInfo;
1213
use rustc_span::{BytePos, Pos, SourceFile, SourceFileAndLine, Span, Symbol};
13-
use rustc_target::abi::Size;
14-
use rustc_target::abi::call::FnAbi;
14+
use rustc_target::callconv::FnAbi;
1515

1616
use crate::builder::Builder;
1717
use crate::context::CodegenCx;

compiler/rustc_codegen_gcc/src/declare.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use gccjit::{Function, FunctionType, GlobalKind, LValue, RValue, Type};
44
use rustc_codegen_ssa::traits::BaseTypeCodegenMethods;
55
use rustc_middle::ty::Ty;
66
use rustc_span::Symbol;
7-
use rustc_target::abi::call::FnAbi;
7+
use rustc_target::callconv::FnAbi;
88

99
use crate::abi::{FnAbiGcc, FnAbiGccExt};
1010
use crate::context::CodegenCx;

compiler/rustc_codegen_gcc/src/int.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
//! 128-bit integers on 32-bit platforms and thus require to be handled manually.
44
55
use gccjit::{BinaryOp, ComparisonOp, FunctionType, Location, RValue, ToRValue, Type, UnaryOp};
6+
use rustc_abi::{Endian, ExternAbi};
67
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
78
use rustc_codegen_ssa::traits::{BackendTypes, BaseTypeCodegenMethods, BuilderMethods, OverflowOp};
89
use rustc_middle::ty::{self, Ty};
9-
use rustc_target::abi::Endian;
10-
use rustc_target::abi::call::{ArgAbi, ArgAttributes, Conv, FnAbi, PassMode};
11-
use rustc_target::spec;
10+
use rustc_target::callconv::{ArgAbi, ArgAttributes, Conv, FnAbi, PassMode};
1211

1312
use crate::builder::{Builder, ToGccComp};
1413
use crate::common::{SignType, TypeReflection};
@@ -401,7 +400,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
401400
conv: Conv::C,
402401
can_unwind: false,
403402
};
404-
fn_abi.adjust_for_foreign_abi(self.cx, spec::abi::Abi::C { unwind: false }).unwrap();
403+
fn_abi.adjust_for_foreign_abi(self.cx, ExternAbi::C { unwind: false }).unwrap();
405404

406405
let ret_indirect = matches!(fn_abi.ret.mode, PassMode::Indirect { .. });
407406

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ use std::iter;
77
#[cfg(feature = "master")]
88
use gccjit::FunctionType;
99
use gccjit::{ComparisonOp, Function, RValue, ToRValue, Type, UnaryOp};
10+
#[cfg(feature = "master")]
11+
use rustc_abi::ExternAbi;
12+
use rustc_abi::HasDataLayout;
1013
use rustc_codegen_ssa::MemFlags;
1114
use rustc_codegen_ssa::base::wants_msvc_seh;
1215
use rustc_codegen_ssa::common::IntPredicate;
@@ -25,11 +28,8 @@ use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt};
2528
use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf};
2629
use rustc_middle::ty::{self, Instance, Ty};
2730
use rustc_span::{Span, Symbol, sym};
28-
use rustc_target::abi::HasDataLayout;
29-
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
31+
use rustc_target::callconv::{ArgAbi, FnAbi, PassMode};
3032
use rustc_target::spec::PanicStrategy;
31-
#[cfg(feature = "master")]
32-
use rustc_target::spec::abi::Abi;
3333

3434
#[cfg(feature = "master")]
3535
use crate::abi::FnAbiGccExt;
@@ -1238,7 +1238,7 @@ fn get_rust_try_fn<'a, 'gcc, 'tcx>(
12381238
tcx.types.unit,
12391239
false,
12401240
rustc_hir::Safety::Unsafe,
1241-
Abi::Rust,
1241+
ExternAbi::Rust,
12421242
)),
12431243
);
12441244
// `unsafe fn(*mut i8, *mut i8) -> ()`
@@ -1249,7 +1249,7 @@ fn get_rust_try_fn<'a, 'gcc, 'tcx>(
12491249
tcx.types.unit,
12501250
false,
12511251
rustc_hir::Safety::Unsafe,
1252-
Abi::Rust,
1252+
ExternAbi::Rust,
12531253
)),
12541254
);
12551255
// `unsafe fn(unsafe fn(*mut i8) -> (), *mut i8, unsafe fn(*mut i8, *mut i8) -> ()) -> i32`
@@ -1258,7 +1258,7 @@ fn get_rust_try_fn<'a, 'gcc, 'tcx>(
12581258
tcx.types.i32,
12591259
false,
12601260
rustc_hir::Safety::Unsafe,
1261-
Abi::Rust,
1261+
ExternAbi::Rust,
12621262
));
12631263
let rust_try = gen_fn(cx, "__rust_try", rust_fn_sig, codegen);
12641264
cx.rust_try_fn.set(Some(rust_try));

compiler/rustc_codegen_gcc/src/intrinsic/simd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::iter::FromIterator;
33
use gccjit::{BinaryOp, RValue, ToRValue, Type};
44
#[cfg(feature = "master")]
55
use gccjit::{ComparisonOp, UnaryOp};
6+
use rustc_abi::{Align, Size};
67
use rustc_codegen_ssa::base::compare_simd_types;
78
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
89
#[cfg(feature = "master")]
@@ -17,7 +18,6 @@ use rustc_middle::mir::BinOp;
1718
use rustc_middle::ty::layout::HasTyCtxt;
1819
use rustc_middle::ty::{self, Ty};
1920
use rustc_span::{Span, Symbol, sym};
20-
use rustc_target::abi::{Align, Size};
2121

2222
use crate::builder::Builder;
2323
#[cfg(not(feature = "master"))]

compiler/rustc_codegen_gcc/src/type_.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ use std::convert::TryInto;
44
#[cfg(feature = "master")]
55
use gccjit::CType;
66
use gccjit::{RValue, Struct, Type};
7+
use rustc_abi::{AddressSpace, Align, Integer, Size};
78
use rustc_codegen_ssa::common::TypeKind;
89
use rustc_codegen_ssa::traits::{
910
BaseTypeCodegenMethods, DerivedTypeCodegenMethods, TypeMembershipCodegenMethods,
1011
};
1112
use rustc_middle::ty::layout::TyAndLayout;
1213
use rustc_middle::{bug, ty};
13-
use rustc_target::abi::{AddressSpace, Align, Integer, Size};
1414

1515
use crate::common::TypeReflection;
1616
use crate::context::CodegenCx;

compiler/rustc_codegen_gcc/src/type_of.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ use std::fmt::Write;
33
use gccjit::{Struct, Type};
44
use rustc_abi as abi;
55
use rustc_abi::Primitive::*;
6-
use rustc_abi::{BackendRepr, FieldsShape, Integer, PointeeInfo, Size, Variants};
6+
use rustc_abi::{
7+
BackendRepr, FieldsShape, Integer, PointeeInfo, Reg, Size, TyAbiInterface, Variants,
8+
};
79
use rustc_codegen_ssa::traits::{
810
BaseTypeCodegenMethods, DerivedTypeCodegenMethods, LayoutTypeCodegenMethods,
911
};
1012
use rustc_middle::bug;
1113
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
1214
use rustc_middle::ty::print::with_no_trimmed_paths;
1315
use rustc_middle::ty::{self, CoroutineArgsExt, Ty, TypeVisitableExt};
14-
use rustc_target::abi::TyAbiInterface;
15-
use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
16+
use rustc_target::callconv::{CastTarget, FnAbi};
1617

1718
use crate::abi::{FnAbiGcc, FnAbiGccExt, GccType};
1819
use crate::context::CodegenCx;

compiler/rustc_hir_typeck/src/cast.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
831831

832832
// prim -> prim
833833
(Int(CEnum), Int(_)) => {
834-
self.cenum_impl_drop_lint(fcx);
834+
self.err_if_cenum_impl_drop(fcx);
835835
Ok(CastKind::EnumCast)
836836
}
837837
(Int(Char) | Int(Bool), Int(_)) => Ok(CastKind::PrimIntCast),
@@ -1091,19 +1091,14 @@ impl<'a, 'tcx> CastCheck<'tcx> {
10911091
}
10921092
}
10931093

1094-
fn cenum_impl_drop_lint(&self, fcx: &FnCtxt<'a, 'tcx>) {
1094+
fn err_if_cenum_impl_drop(&self, fcx: &FnCtxt<'a, 'tcx>) {
10951095
if let ty::Adt(d, _) = self.expr_ty.kind()
10961096
&& d.has_dtor(fcx.tcx)
10971097
{
10981098
let expr_ty = fcx.resolve_vars_if_possible(self.expr_ty);
10991099
let cast_ty = fcx.resolve_vars_if_possible(self.cast_ty);
11001100

1101-
fcx.tcx.emit_node_span_lint(
1102-
lint::builtin::CENUM_IMPL_DROP_CAST,
1103-
self.expr.hir_id,
1104-
self.span,
1105-
errors::CastEnumDrop { expr_ty, cast_ty },
1106-
);
1101+
fcx.dcx().emit_err(errors::CastEnumDrop { span: self.span, expr_ty, cast_ty });
11071102
}
11081103
}
11091104

compiler/rustc_hir_typeck/src/errors.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -677,9 +677,11 @@ pub(crate) struct CannotCastToBool<'tcx> {
677677
pub help: CannotCastToBoolHelp,
678678
}
679679

680-
#[derive(LintDiagnostic)]
680+
#[derive(Diagnostic)]
681681
#[diag(hir_typeck_cast_enum_drop)]
682682
pub(crate) struct CastEnumDrop<'tcx> {
683+
#[primary_span]
684+
pub span: Span,
683685
pub expr_ty: Ty<'tcx>,
684686
pub cast_ty: Ty<'tcx>,
685687
}

compiler/rustc_hir_typeck/src/pat.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
570570

571571
fn check_pat_expr_unadjusted(&self, lt: &'tcx hir::PatExpr<'tcx>) -> Ty<'tcx> {
572572
let ty = match &lt.kind {
573-
rustc_hir::PatExprKind::Lit { lit, .. } => {
574-
self.check_expr_lit(lit, Expectation::NoExpectation)
573+
rustc_hir::PatExprKind::Lit { lit, negated } => {
574+
let ty = self.check_expr_lit(lit, Expectation::NoExpectation);
575+
if *negated {
576+
self.register_bound(
577+
ty,
578+
self.tcx.require_lang_item(LangItem::Neg, Some(lt.span)),
579+
ObligationCause::dummy_with_span(lt.span),
580+
);
581+
}
582+
ty
575583
}
576584
rustc_hir::PatExprKind::ConstBlock(c) => {
577585
self.check_expr_const_block(c, Expectation::NoExpectation)

compiler/rustc_lint/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,11 @@ fn register_builtins(store: &mut LintStore) {
595595
<https://github.com/rust-lang/rust/pull/125380> for more information",
596596
);
597597
store.register_removed("unsupported_calling_conventions", "converted into hard error");
598+
store.register_removed(
599+
"cenum_impl_drop_cast",
600+
"converted into hard error, \
601+
see <https://github.com/rust-lang/rust/issues/73333> for more information",
602+
);
598603
}
599604

600605
fn register_internals(store: &mut LintStore) {

compiler/rustc_lint_defs/src/builtin.rs

-53
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ declare_lint_pass! {
2727
BARE_TRAIT_OBJECTS,
2828
BINDINGS_WITH_VARIANT_NAME,
2929
BREAK_WITH_LABEL_AND_LOOP,
30-
CENUM_IMPL_DROP_CAST,
3130
COHERENCE_LEAK_CHECK,
3231
CONFLICTING_REPR_HINTS,
3332
CONST_EVALUATABLE_UNCHECKED,
@@ -2612,58 +2611,6 @@ declare_lint! {
26122611
@edition Edition2024 => Warn;
26132612
}
26142613

2615-
declare_lint! {
2616-
/// The `cenum_impl_drop_cast` lint detects an `as` cast of a field-less
2617-
/// `enum` that implements [`Drop`].
2618-
///
2619-
/// [`Drop`]: https://doc.rust-lang.org/std/ops/trait.Drop.html
2620-
///
2621-
/// ### Example
2622-
///
2623-
/// ```rust,compile_fail
2624-
/// # #![allow(unused)]
2625-
/// enum E {
2626-
/// A,
2627-
/// }
2628-
///
2629-
/// impl Drop for E {
2630-
/// fn drop(&mut self) {
2631-
/// println!("Drop");
2632-
/// }
2633-
/// }
2634-
///
2635-
/// fn main() {
2636-
/// let e = E::A;
2637-
/// let i = e as u32;
2638-
/// }
2639-
/// ```
2640-
///
2641-
/// {{produces}}
2642-
///
2643-
/// ### Explanation
2644-
///
2645-
/// Casting a field-less `enum` that does not implement [`Copy`] to an
2646-
/// integer moves the value without calling `drop`. This can result in
2647-
/// surprising behavior if it was expected that `drop` should be called.
2648-
/// Calling `drop` automatically would be inconsistent with other move
2649-
/// operations. Since neither behavior is clear or consistent, it was
2650-
/// decided that a cast of this nature will no longer be allowed.
2651-
///
2652-
/// This is a [future-incompatible] lint to transition this to a hard error
2653-
/// in the future. See [issue #73333] for more details.
2654-
///
2655-
/// [future-incompatible]: ../index.md#future-incompatible-lints
2656-
/// [issue #73333]: https://github.com/rust-lang/rust/issues/73333
2657-
/// [`Copy`]: https://doc.rust-lang.org/std/marker/trait.Copy.html
2658-
pub CENUM_IMPL_DROP_CAST,
2659-
Deny,
2660-
"a C-like enum implementing Drop is cast",
2661-
@future_incompatible = FutureIncompatibleInfo {
2662-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
2663-
reference: "issue #73333 <https://github.com/rust-lang/rust/issues/73333>",
2664-
};
2665-
}
2666-
26672614
declare_lint! {
26682615
/// The `fuzzy_provenance_casts` lint detects an `as` cast between an integer
26692616
/// and a pointer.

compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnu.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ pub(crate) fn target() -> Target {
1818
pointer_width: 32,
1919
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
2020
arch: "powerpc".into(),
21-
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
21+
options: TargetOptions {
22+
endian: Endian::Big,
23+
features: "+secure-plt".into(),
24+
mcount: "_mcount".into(),
25+
..base
26+
},
2227
}
2328
}

compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_gnuspe.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub(crate) fn target() -> Target {
2121
options: TargetOptions {
2222
abi: "spe".into(),
2323
endian: Endian::Big,
24+
features: "+secure-plt".into(),
2425
mcount: "_mcount".into(),
2526
..base
2627
},

0 commit comments

Comments
 (0)