Skip to content

Commit ea4a983

Browse files
committed
Auto merge of rust-lang#3097 - RalfJung:rustup, r=RalfJung
Rustup
2 parents a456149 + 1191131 commit ea4a983

File tree

260 files changed

+3232
-1613
lines changed

Some content is hidden

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

260 files changed

+3232
-1613
lines changed

.mailmap

+2
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ Nilstrieb <[email protected]> nils <48135649+Nilstrieb
429429
430430
431431
432+
433+
432434
433435
434436

Cargo.lock

+7-11
Original file line numberDiff line numberDiff line change
@@ -6030,19 +6030,21 @@ dependencies = [
60306030

60316031
[[package]]
60326032
name = "windows-bindgen"
6033-
version = "0.49.0"
6033+
version = "0.51.1"
60346034
source = "registry+https://github.com/rust-lang/crates.io-index"
6035-
checksum = "b6935fb09b84ee57929ae92518b475f5dfdfbeb87c5334756acc28ee8e202b60"
6035+
checksum = "bc1f16b778125675feee0d15d6dd9f6af0e3ac52b3233d63a10aa39230c1cd75"
60366036
dependencies = [
6037+
"proc-macro2",
6038+
"rayon",
6039+
"syn 2.0.29",
60376040
"windows-metadata",
6038-
"windows-tokens",
60396041
]
60406042

60416043
[[package]]
60426044
name = "windows-metadata"
6043-
version = "0.49.0"
6045+
version = "0.51.1"
60446046
source = "registry+https://github.com/rust-lang/crates.io-index"
6045-
checksum = "2f5bca94a32bf1e6a376522b6601275a3b611ee885ec0f1b6a05f17e8cfd3385"
6047+
checksum = "753135d996f9da437c0b31dbde3032489a61708361929bcc07d4fba0b161000e"
60466048

60476049
[[package]]
60486050
name = "windows-sys"
@@ -6092,12 +6094,6 @@ dependencies = [
60926094
"windows_x86_64_msvc 0.48.0",
60936095
]
60946096

6095-
[[package]]
6096-
name = "windows-tokens"
6097-
version = "0.48.0"
6098-
source = "registry+https://github.com/rust-lang/crates.io-index"
6099-
checksum = "b34c9a3b28cb41db7385546f7f9a8179348dffc89923dde66857b1ba5312f6b4"
6100-
61016097
[[package]]
61026098
name = "windows_aarch64_gnullvm"
61036099
version = "0.42.2"

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
245245
let Trait(PolyTraitRef { trait_ref, span: trait_span, .. }, _) = bound else { return; };
246246
diag.span_note(
247247
*trait_span,
248-
format!("due to current limitations in the borrow checker, this implies a `'static` lifetime")
248+
"due to current limitations in the borrow checker, this implies a `'static` lifetime"
249249
);
250250
let Some(generics_fn) = hir.get_generics(self.body.source.def_id().expect_local()) else { return; };
251251
let Def(_, trait_res_defid) = trait_ref.path.res else { return; };
@@ -277,7 +277,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
277277
if suggestions.len() > 0 {
278278
suggestions.dedup();
279279
diag.multipart_suggestion_verbose(
280-
format!("consider restricting the type parameter to the `'static` lifetime"),
280+
"consider restricting the type parameter to the `'static` lifetime",
281281
suggestions,
282282
Applicability::MaybeIncorrect,
283283
);

compiler/rustc_codegen_cranelift/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ pub(crate) fn codegen_place<'tcx>(
875875
PlaceElem::Deref => {
876876
cplace = cplace.place_deref(fx);
877877
}
878-
PlaceElem::OpaqueCast(ty) => cplace = cplace.place_opaque_cast(fx, ty),
878+
PlaceElem::OpaqueCast(ty) => bug!("encountered OpaqueCast({ty}) in codegen"),
879879
PlaceElem::Field(field, _ty) => {
880880
cplace = cplace.place_field(fx, field);
881881
}

compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs

+49-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn report_simd_type_validation_error(
2121
pub(super) fn codegen_simd_intrinsic_call<'tcx>(
2222
fx: &mut FunctionCx<'_, '_, 'tcx>,
2323
intrinsic: Symbol,
24-
_args: GenericArgsRef<'tcx>,
24+
generic_args: GenericArgsRef<'tcx>,
2525
args: &[mir::Operand<'tcx>],
2626
ret: CPlace<'tcx>,
2727
target: BasicBlock,
@@ -117,6 +117,54 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
117117
});
118118
}
119119

120+
// simd_shuffle_generic<T, U, const I: &[u32]>(x: T, y: T) -> U
121+
sym::simd_shuffle_generic => {
122+
let [x, y] = args else {
123+
bug!("wrong number of args for intrinsic {intrinsic}");
124+
};
125+
let x = codegen_operand(fx, x);
126+
let y = codegen_operand(fx, y);
127+
128+
if !x.layout().ty.is_simd() {
129+
report_simd_type_validation_error(fx, intrinsic, span, x.layout().ty);
130+
return;
131+
}
132+
133+
let idx = generic_args[2]
134+
.expect_const()
135+
.eval(fx.tcx, ty::ParamEnv::reveal_all(), Some(span))
136+
.unwrap()
137+
.unwrap_branch();
138+
139+
assert_eq!(x.layout(), y.layout());
140+
let layout = x.layout();
141+
142+
let (lane_count, lane_ty) = layout.ty.simd_size_and_type(fx.tcx);
143+
let (ret_lane_count, ret_lane_ty) = ret.layout().ty.simd_size_and_type(fx.tcx);
144+
145+
assert_eq!(lane_ty, ret_lane_ty);
146+
assert_eq!(idx.len() as u64, ret_lane_count);
147+
148+
let total_len = lane_count * 2;
149+
150+
let indexes =
151+
idx.iter().map(|idx| idx.unwrap_leaf().try_to_u16().unwrap()).collect::<Vec<u16>>();
152+
153+
for &idx in &indexes {
154+
assert!(u64::from(idx) < total_len, "idx {} out of range 0..{}", idx, total_len);
155+
}
156+
157+
for (out_idx, in_idx) in indexes.into_iter().enumerate() {
158+
let in_lane = if u64::from(in_idx) < lane_count {
159+
x.value_lane(fx, in_idx.into())
160+
} else {
161+
y.value_lane(fx, u64::from(in_idx) - lane_count)
162+
};
163+
let out_lane = ret.place_lane(fx, u64::try_from(out_idx).unwrap());
164+
out_lane.write_cvalue(fx, in_lane);
165+
}
166+
}
167+
120168
// simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U
121169
sym::simd_shuffle => {
122170
let (x, y, idx) = match args {

compiler/rustc_codegen_cranelift/src/value_and_place.rs

-8
Original file line numberDiff line numberDiff line change
@@ -674,14 +674,6 @@ impl<'tcx> CPlace<'tcx> {
674674
}
675675
}
676676

677-
pub(crate) fn place_opaque_cast(
678-
self,
679-
fx: &mut FunctionCx<'_, '_, 'tcx>,
680-
ty: Ty<'tcx>,
681-
) -> CPlace<'tcx> {
682-
CPlace { inner: self.inner, layout: fx.layout_of(ty) }
683-
}
684-
685677
pub(crate) fn place_field(
686678
self,
687679
fx: &mut FunctionCx<'_, '_, 'tcx>,

compiler/rustc_codegen_llvm/messages.ftl

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ codegen_llvm_lto_disallowed = lto can only be run for executables, cdylibs and s
3737
3838
codegen_llvm_lto_dylib = lto cannot be used for `dylib` crate type without `-Zdylib-lto`
3939
40+
codegen_llvm_lto_proc_macro = lto cannot be used for `proc-macro` crate type without `-Zdylib-lto`
41+
4042
codegen_llvm_missing_features =
4143
add the missing features in a `target_feature` attribute
4244

compiler/rustc_codegen_llvm/src/back/lto.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::back::write::{
22
self, bitcode_section_name, save_temp_bitcode, CodegenDiagnosticsStage, DiagnosticHandlers,
33
};
44
use crate::errors::{
5-
DynamicLinkingWithLTO, LlvmError, LtoBitcodeFromRlib, LtoDisallowed, LtoDylib,
5+
DynamicLinkingWithLTO, LlvmError, LtoBitcodeFromRlib, LtoDisallowed, LtoDylib, LtoProcMacro,
66
};
77
use crate::llvm::{self, build_string};
88
use crate::{LlvmCodegenBackend, ModuleLlvm};
@@ -36,8 +36,12 @@ pub const THIN_LTO_KEYS_INCR_COMP_FILE_NAME: &str = "thin-lto-past-keys.bin";
3636

3737
pub fn crate_type_allows_lto(crate_type: CrateType) -> bool {
3838
match crate_type {
39-
CrateType::Executable | CrateType::Dylib | CrateType::Staticlib | CrateType::Cdylib => true,
40-
CrateType::Rlib | CrateType::ProcMacro => false,
39+
CrateType::Executable
40+
| CrateType::Dylib
41+
| CrateType::Staticlib
42+
| CrateType::Cdylib
43+
| CrateType::ProcMacro => true,
44+
CrateType::Rlib => false,
4145
}
4246
}
4347

@@ -87,6 +91,11 @@ fn prepare_lto(
8791
diag_handler.emit_err(LtoDylib);
8892
return Err(FatalError);
8993
}
94+
} else if *crate_type == CrateType::ProcMacro {
95+
if !cgcx.opts.unstable_opts.dylib_lto {
96+
diag_handler.emit_err(LtoProcMacro);
97+
return Err(FatalError);
98+
}
9099
}
91100
}
92101

compiler/rustc_codegen_llvm/src/errors.rs

+4
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ pub(crate) struct LtoDisallowed;
138138
#[diag(codegen_llvm_lto_dylib)]
139139
pub(crate) struct LtoDylib;
140140

141+
#[derive(Diagnostic)]
142+
#[diag(codegen_llvm_lto_proc_macro)]
143+
pub(crate) struct LtoProcMacro;
144+
141145
#[derive(Diagnostic)]
142146
#[diag(codegen_llvm_lto_bitcode_from_rlib)]
143147
pub(crate) struct LtoBitcodeFromRlib {

compiler/rustc_codegen_llvm/src/intrinsic.rs

+55-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_codegen_ssa::mir::place::PlaceRef;
1515
use rustc_codegen_ssa::traits::*;
1616
use rustc_hir as hir;
1717
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf};
18-
use rustc_middle::ty::{self, Ty};
18+
use rustc_middle::ty::{self, GenericArgsRef, Ty};
1919
use rustc_middle::{bug, span_bug};
2020
use rustc_span::{sym, symbol::kw, Span, Symbol};
2121
use rustc_target::abi::{self, Align, HasDataLayout, Primitive};
@@ -376,7 +376,9 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
376376
}
377377

378378
_ if name.as_str().starts_with("simd_") => {
379-
match generic_simd_intrinsic(self, name, callee_ty, args, ret_ty, llret_ty, span) {
379+
match generic_simd_intrinsic(
380+
self, name, callee_ty, fn_args, args, ret_ty, llret_ty, span,
381+
) {
380382
Ok(llval) => llval,
381383
Err(()) => return,
382384
}
@@ -911,6 +913,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
911913
bx: &mut Builder<'_, 'll, 'tcx>,
912914
name: Symbol,
913915
callee_ty: Ty<'tcx>,
916+
fn_args: GenericArgsRef<'tcx>,
914917
args: &[OperandRef<'tcx, &'ll Value>],
915918
ret_ty: Ty<'tcx>,
916919
llret_ty: &'ll Type,
@@ -1030,6 +1033,56 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
10301033
));
10311034
}
10321035

1036+
if name == sym::simd_shuffle_generic {
1037+
let idx = fn_args[2]
1038+
.expect_const()
1039+
.eval(tcx, ty::ParamEnv::reveal_all(), Some(span))
1040+
.unwrap()
1041+
.unwrap_branch();
1042+
let n = idx.len() as u64;
1043+
1044+
require_simd!(ret_ty, InvalidMonomorphization::SimdReturn { span, name, ty: ret_ty });
1045+
let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx());
1046+
require!(
1047+
out_len == n,
1048+
InvalidMonomorphization::ReturnLength { span, name, in_len: n, ret_ty, out_len }
1049+
);
1050+
require!(
1051+
in_elem == out_ty,
1052+
InvalidMonomorphization::ReturnElement { span, name, in_elem, in_ty, ret_ty, out_ty }
1053+
);
1054+
1055+
let total_len = in_len * 2;
1056+
1057+
let indices: Option<Vec<_>> = idx
1058+
.iter()
1059+
.enumerate()
1060+
.map(|(arg_idx, val)| {
1061+
let idx = val.unwrap_leaf().try_to_i32().unwrap();
1062+
if idx >= i32::try_from(total_len).unwrap() {
1063+
bx.sess().emit_err(InvalidMonomorphization::ShuffleIndexOutOfBounds {
1064+
span,
1065+
name,
1066+
arg_idx: arg_idx as u64,
1067+
total_len: total_len.into(),
1068+
});
1069+
None
1070+
} else {
1071+
Some(bx.const_i32(idx))
1072+
}
1073+
})
1074+
.collect();
1075+
let Some(indices) = indices else {
1076+
return Ok(bx.const_null(llret_ty));
1077+
};
1078+
1079+
return Ok(bx.shuffle_vector(
1080+
args[0].immediate(),
1081+
args[1].immediate(),
1082+
bx.const_vector(&indices),
1083+
));
1084+
}
1085+
10331086
if name == sym::simd_shuffle {
10341087
// Make sure this is actually an array, since typeck only checks the length-suffixed
10351088
// version of this intrinsic.

compiler/rustc_codegen_ssa/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ codegen_ssa_ignoring_output = ignoring -o because multiple .{$extension} files w
4646
codegen_ssa_illegal_link_ordinal_format = illegal ordinal format in `link_ordinal`
4747
.note = an unsuffixed integer value, e.g., `1`, is expected
4848
49-
codegen_ssa_incompatible_linking_modifiers = link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs
50-
5149
codegen_ssa_insufficient_vs_code_product = VS Code is a different product, and is not sufficient.
5250
5351
codegen_ssa_invalid_link_ordinal_nargs = incorrect number of arguments to `#[link_ordinal]`

compiler/rustc_codegen_ssa/src/back/link.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,9 @@ fn link_rlib<'a>(
365365
// loaded from the libraries found here and then encode that into the
366366
// metadata of the rlib we're generating somehow.
367367
for lib in codegen_results.crate_info.used_libraries.iter() {
368-
let NativeLibKind::Static { bundle: None | Some(true), whole_archive } = lib.kind else {
368+
let NativeLibKind::Static { bundle: None | Some(true), .. } = lib.kind else {
369369
continue;
370370
};
371-
if whole_archive == Some(true)
372-
&& flavor == RlibFlavor::Normal
373-
&& !codegen_results.crate_info.feature_packed_bundled_libs
374-
{
375-
sess.emit_err(errors::IncompatibleLinkingModifiers);
376-
}
377371
if flavor == RlibFlavor::Normal && let Some(filename) = lib.filename {
378372
let path = find_native_static_library(filename.as_str(), true, &lib_search_paths, sess);
379373
let src = read(path).map_err(|e| sess.emit_fatal(errors::ReadFileError {message: e }))?;

compiler/rustc_codegen_ssa/src/base.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
181181
old_info
182182
}
183183
}
184-
(_, &ty::Dynamic(ref data, _, _)) => meth::get_vtable(cx, source, data.principal()),
184+
(_, ty::Dynamic(data, _, _)) => meth::get_vtable(cx, source, data.principal()),
185185
_ => bug!("unsized_info: invalid unsizing {:?} -> {:?}", source, target),
186186
}
187187
}
@@ -857,7 +857,6 @@ impl CrateInfo {
857857
dependency_formats: tcx.dependency_formats(()).clone(),
858858
windows_subsystem,
859859
natvis_debugger_visualizers: Default::default(),
860-
feature_packed_bundled_libs: tcx.features().packed_bundled_libs,
861860
};
862861
let crates = tcx.crates(());
863862

compiler/rustc_codegen_ssa/src/errors.rs

-4
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ pub struct CreateTempDir {
107107
pub error: Error,
108108
}
109109

110-
#[derive(Diagnostic)]
111-
#[diag(codegen_ssa_incompatible_linking_modifiers)]
112-
pub struct IncompatibleLinkingModifiers;
113-
114110
#[derive(Diagnostic)]
115111
#[diag(codegen_ssa_add_native_library)]
116112
pub struct AddNativeLibrary {

compiler/rustc_codegen_ssa/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ pub struct CrateInfo {
164164
pub dependency_formats: Lrc<Dependencies>,
165165
pub windows_subsystem: Option<String>,
166166
pub natvis_debugger_visualizers: BTreeSet<DebuggerVisualizerFile>,
167-
pub feature_packed_bundled_libs: bool, // unstable feature flag.
168167
}
169168

170169
#[derive(Encodable, Decodable)]

compiler/rustc_codegen_ssa/src/mir/place.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
463463
mir::ProjectionElem::Field(ref field, _) => {
464464
cg_base.project_field(bx, field.index())
465465
}
466-
mir::ProjectionElem::OpaqueCast(ty) => cg_base.project_type(bx, ty),
466+
mir::ProjectionElem::OpaqueCast(ty) => {
467+
bug!("encountered OpaqueCast({ty}) in codegen")
468+
}
467469
mir::ProjectionElem::Index(index) => {
468470
let index = &mir::Operand::Copy(mir::Place::from(index));
469471
let index = self.codegen_operand(bx, index);

compiler/rustc_const_eval/src/interpret/projection.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ where
316316
{
317317
use rustc_middle::mir::ProjectionElem::*;
318318
Ok(match proj_elem {
319-
OpaqueCast(ty) => base.transmute(self.layout_of(ty)?, self)?,
319+
OpaqueCast(ty) => {
320+
span_bug!(self.cur_span(), "OpaqueCast({ty}) encountered after borrowck")
321+
}
320322
Field(field, _) => self.project_field(base, field.index())?,
321323
Downcast(_, variant) => self.project_downcast(base, variant)?,
322324
Deref => self.deref_pointer(&base.to_op(self)?)?.into(),

compiler/rustc_const_eval/src/transform/validate.rs

+8
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,14 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
633633
location: Location,
634634
) {
635635
match elem {
636+
ProjectionElem::OpaqueCast(ty)
637+
if self.mir_phase >= MirPhase::Runtime(RuntimePhase::Initial) =>
638+
{
639+
self.fail(
640+
location,
641+
format!("explicit opaque type cast to `{ty}` after `RevealAll`"),
642+
)
643+
}
636644
ProjectionElem::Index(index) => {
637645
let index_ty = self.body.local_decls[index].ty;
638646
if index_ty != self.tcx.types.usize {

0 commit comments

Comments
 (0)