Skip to content

Commit e69336e

Browse files
committed
Auto merge of #104492 - matthiaskrgr:rollup-3xyjynz, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #103750 (Fix some misleading target feature aliases) - #104137 (Issue error when -C link-self-contained option is used on unsupported platforms) - #104317 (cleanup and dedupe CTFE and Miri error reporting) - #104335 (Only do parser recovery on retried macro matching) - #104394 (various cleanups to try to reduce the use of spans inside method resolution) - #104459 (rustdoc: remove unused JS IIFE from main.js) - #104462 (rustdoc: remove pointless CSS `.rightside { padding-right: 2px }`) - #104466 (rustdoc: remove no-op CSS `#crate-search-div { display: inline-block }`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 63c748e + 972ad00 commit e69336e

File tree

125 files changed

+922
-735
lines changed

Some content is hidden

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

125 files changed

+922
-735
lines changed

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool {
4747
if let Err(err) = fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), unevaluated, None) {
4848
all_constants_ok = false;
4949
match err {
50-
ErrorHandled::Reported(_) | ErrorHandled::Linted => {
50+
ErrorHandled::Reported(_) => {
5151
fx.tcx.sess.span_err(constant.span, "erroneous constant encountered");
5252
}
5353
ErrorHandled::TooGeneric => {

compiler/rustc_codegen_gcc/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,10 @@ pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
315315
false
316316
}
317317
/*
318-
adx, aes, avx, avx2, avx512bf16, avx512bitalg, avx512bw, avx512cd, avx512dq, avx512er, avx512f, avx512gfni,
319-
avx512ifma, avx512pf, avx512vaes, avx512vbmi, avx512vbmi2, avx512vl, avx512vnni, avx512vp2intersect, avx512vpclmulqdq,
320-
avx512vpopcntdq, bmi1, bmi2, cmpxchg16b, ermsb, f16c, fma, fxsr, lzcnt, movbe, pclmulqdq, popcnt, rdrand, rdseed, rtm,
321-
sha, sse, sse2, sse3, sse4.1, sse4.2, sse4a, ssse3, tbm, xsave, xsavec, xsaveopt, xsaves
318+
adx, aes, avx, avx2, avx512bf16, avx512bitalg, avx512bw, avx512cd, avx512dq, avx512er, avx512f, avx512ifma,
319+
avx512pf, avx512vbmi, avx512vbmi2, avx512vl, avx512vnni, avx512vp2intersect, avx512vpopcntdq,
320+
bmi1, bmi2, cmpxchg16b, ermsb, f16c, fma, fxsr, gfni, lzcnt, movbe, pclmulqdq, popcnt, rdrand, rdseed, rtm,
321+
sha, sse, sse2, sse3, sse4.1, sse4.2, sse4a, ssse3, tbm, vaes, vpclmulqdq, xsave, xsavec, xsaveopt, xsaves
322322
*/
323323
//false
324324
})

compiler/rustc_codegen_llvm/src/llvm_util.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]
163163
("x86", "rdrand") => smallvec!["rdrnd"],
164164
("x86", "bmi1") => smallvec!["bmi"],
165165
("x86", "cmpxchg16b") => smallvec!["cx16"],
166+
// FIXME: These aliases are misleading, and should be removed before avx512_target_feature is
167+
// stabilized. They must remain until std::arch switches off them.
168+
// rust#100752
166169
("x86", "avx512vaes") => smallvec!["vaes"],
167170
("x86", "avx512gfni") => smallvec!["gfni"],
168171
("x86", "avx512vpclmulqdq") => smallvec!["vpclmulqdq"],

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,9 @@ fn detect_self_contained_mingw(sess: &Session) -> bool {
15881588
/// We only provide such support for a very limited number of targets.
15891589
fn self_contained(sess: &Session, crate_type: CrateType) -> bool {
15901590
if let Some(self_contained) = sess.opts.cg.link_self_contained {
1591+
if sess.target.link_self_contained == LinkSelfContainedDefault::False {
1592+
sess.emit_err(errors::UnsupportedLinkSelfContained);
1593+
}
15911594
return self_contained;
15921595
}
15931596

compiler/rustc_codegen_ssa/src/errors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,3 +530,7 @@ pub enum AppleSdkRootError<'a> {
530530
pub struct ReadFileError {
531531
pub message: std::io::Error,
532532
}
533+
534+
#[derive(Diagnostic)]
535+
#[diag(codegen_ssa_unsupported_link_self_contained)]
536+
pub struct UnsupportedLinkSelfContained;

compiler/rustc_codegen_ssa/src/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
189189
all_consts_ok = false;
190190
match err {
191191
// errored or at least linted
192-
ErrorHandled::Reported(_) | ErrorHandled::Linted => {}
192+
ErrorHandled::Reported(_) => {}
193193
ErrorHandled::TooGeneric => {
194194
span_bug!(const_.span, "codegen encountered polymorphic constant: {:?}", err)
195195
}

compiler/rustc_codegen_ssa/src/target_features.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ const X86_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
179179
("f16c", Some(sym::f16c_target_feature)),
180180
("fma", None),
181181
("fxsr", None),
182+
("gfni", Some(sym::avx512_target_feature)),
182183
("lzcnt", None),
183184
("movbe", Some(sym::movbe_target_feature)),
184185
("pclmulqdq", None),
@@ -195,6 +196,8 @@ const X86_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
195196
("sse4a", Some(sym::sse4a_target_feature)),
196197
("ssse3", None),
197198
("tbm", Some(sym::tbm_target_feature)),
199+
("vaes", Some(sym::avx512_target_feature)),
200+
("vpclmulqdq", Some(sym::avx512_target_feature)),
198201
("xsave", None),
199202
("xsavec", None),
200203
("xsaveopt", None),

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl Error for ConstEvalErrKind {}
5555
/// When const-evaluation errors, this type is constructed with the resulting information,
5656
/// and then used to emit the error as a lint or hard error.
5757
#[derive(Debug)]
58-
pub struct ConstEvalErr<'tcx> {
58+
pub(super) struct ConstEvalErr<'tcx> {
5959
pub span: Span,
6060
pub error: InterpError<'tcx>,
6161
pub stacktrace: Vec<FrameInfo<'tcx>>,
@@ -82,8 +82,8 @@ impl<'tcx> ConstEvalErr<'tcx> {
8282
ConstEvalErr { error: error.into_kind(), stacktrace, span }
8383
}
8484

85-
pub fn report_as_error(&self, tcx: TyCtxtAt<'tcx>, message: &str) -> ErrorHandled {
86-
self.struct_error(tcx, message, |_| {})
85+
pub(super) fn report(&self, tcx: TyCtxtAt<'tcx>, message: &str) -> ErrorHandled {
86+
self.report_decorated(tcx, message, |_| {})
8787
}
8888

8989
/// Create a diagnostic for this const eval error.
@@ -95,7 +95,7 @@ impl<'tcx> ConstEvalErr<'tcx> {
9595
/// If `lint_root.is_some()` report it as a lint, else report it as a hard error.
9696
/// (Except that for some errors, we ignore all that -- see `must_error` below.)
9797
#[instrument(skip(self, tcx, decorate), level = "debug")]
98-
pub fn struct_error(
98+
pub(super) fn report_decorated(
9999
&self,
100100
tcx: TyCtxtAt<'tcx>,
101101
message: &str,

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ pub fn eval_to_const_value_raw_provider<'tcx>(
255255
return eval_nullary_intrinsic(tcx, key.param_env, def_id, substs).map_err(|error| {
256256
let span = tcx.def_span(def_id);
257257
let error = ConstEvalErr { error: error.into_kind(), stacktrace: vec![], span };
258-
error.report_as_error(tcx.at(span), "could not evaluate nullary intrinsic")
258+
error.report(tcx.at(span), "could not evaluate nullary intrinsic")
259259
});
260260
}
261261

@@ -333,7 +333,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
333333
}
334334
};
335335

336-
Err(err.report_as_error(ecx.tcx.at(err.span), &msg))
336+
Err(err.report(ecx.tcx.at(err.span), &msg))
337337
}
338338
Ok(mplace) => {
339339
// Since evaluation had no errors, validate the resulting constant.
@@ -358,7 +358,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
358358
if let Err(error) = validation {
359359
// Validation failed, report an error. This is always a hard error.
360360
let err = ConstEvalErr::new(&ecx, error, None);
361-
Err(err.struct_error(
361+
Err(err.report_decorated(
362362
ecx.tcx,
363363
"it is undefined behavior to use this value",
364364
|diag| {

compiler/rustc_const_eval/src/const_eval/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub(crate) fn try_destructure_mir_constant<'tcx>(
103103
) -> InterpResult<'tcx, mir::DestructuredConstant<'tcx>> {
104104
trace!("destructure_mir_constant: {:?}", val);
105105
let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, false);
106-
let op = ecx.const_to_op(&val, None)?;
106+
let op = ecx.eval_mir_constant(&val, None, None)?;
107107

108108
// We go to `usize` as we cannot allocate anything bigger anyway.
109109
let (field_count, variant, down) = match val.ty().kind() {
@@ -139,7 +139,7 @@ pub(crate) fn deref_mir_constant<'tcx>(
139139
val: mir::ConstantKind<'tcx>,
140140
) -> mir::ConstantKind<'tcx> {
141141
let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, false);
142-
let op = ecx.const_to_op(&val, None).unwrap();
142+
let op = ecx.eval_mir_constant(&val, None, None).unwrap();
143143
let mplace = ecx.deref_operand(&op).unwrap();
144144
if let Some(alloc_id) = mplace.ptr.provenance {
145145
assert_eq!(

0 commit comments

Comments
 (0)