Skip to content

Commit d40973f

Browse files
committed
Auto merge of #152965 - JonathanBrouwer:rollup-QnrcBRx, r=JonathanBrouwer
Rollup of 14 pull requests Successful merges: - #150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing) - #151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts) - #151871 (don't use env with infer vars) - #152591 (Simplify internals of `{Rc,Arc}::default`) - #152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned) - #147859 (reduce the amount of panics in `{TokenStream, Literal}::from_str` calls) - #152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7) - #152767 (fix typo in `carryless_mul` macro invocation) - #152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`) - #152871 (Fix warnings in rs{begin,end}.rs files) - #152879 (Remove `impl IntoQueryParam<P> for &'a P`.) - #152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint) - #152937 (remove unneeded reboxing) - #152953 (Fix typo in armv7a-vex-v5.md)
2 parents d8b2222 + 91010cf commit d40973f

File tree

82 files changed

+596
-310
lines changed

Some content is hidden

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

82 files changed

+596
-310
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4211,9 +4211,7 @@ impl ForeignItemKind {
42114211
impl From<ForeignItemKind> for ItemKind {
42124212
fn from(foreign_item_kind: ForeignItemKind) -> ItemKind {
42134213
match foreign_item_kind {
4214-
ForeignItemKind::Static(box static_foreign_item) => {
4215-
ItemKind::Static(Box::new(static_foreign_item))
4216-
}
4214+
ForeignItemKind::Static(static_foreign_item) => ItemKind::Static(static_foreign_item),
42174215
ForeignItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind),
42184216
ForeignItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
42194217
ForeignItemKind::MacCall(a) => ItemKind::MacCall(a),
@@ -4226,7 +4224,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
42264224

42274225
fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> {
42284226
Ok(match item_kind {
4229-
ItemKind::Static(box static_item) => ForeignItemKind::Static(Box::new(static_item)),
4227+
ItemKind::Static(static_item) => ForeignItemKind::Static(static_item),
42304228
ItemKind::Fn(fn_kind) => ForeignItemKind::Fn(fn_kind),
42314229
ItemKind::TyAlias(ty_alias_kind) => ForeignItemKind::TyAlias(ty_alias_kind),
42324230
ItemKind::MacCall(a) => ForeignItemKind::MacCall(a),

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
626626
let predicates = match parent.kind {
627627
hir::ExprKind::Call(callee, _) => {
628628
let ty = typeck_result.node_type_opt(callee.hir_id)?;
629-
let ty::FnDef(fn_def_id, args) = ty.kind() else { return None };
629+
let ty::FnDef(fn_def_id, args) = *ty.kind() else { return None };
630630
tcx.predicates_of(fn_def_id).instantiate(tcx, args)
631631
}
632632
hir::ExprKind::MethodCall(..) => {

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
614614
}
615615
_ => {
616616
let local = &self.body.local_decls[local];
617-
match local.local_info() {
617+
match *local.local_info() {
618618
LocalInfo::StaticRef { def_id, .. } => {
619619
let span = self.infcx.tcx.def_span(def_id);
620620
err.span_label(span, format!("this `static` cannot be {acted_on}"));

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
926926
let tcx = self.infcx.tcx;
927927

928928
let ConstraintCategory::CallArgument(Some(func_ty)) = category else { return };
929-
let ty::FnDef(fn_did, args) = func_ty.kind() else { return };
929+
let ty::FnDef(fn_did, args) = *func_ty.kind() else { return };
930930
debug!(?fn_did, ?args);
931931

932932
// Only suggest this on function calls, not closures
@@ -938,7 +938,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
938938
let Ok(Some(instance)) = ty::Instance::try_resolve(
939939
tcx,
940940
self.infcx.typing_env(self.infcx.param_env),
941-
*fn_did,
941+
fn_did,
942942
self.infcx.resolve_vars_if_possible(args),
943943
) else {
944944
return;

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,12 +1013,12 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
10131013
let is_implicit_coercion = coercion_source == CoercionSource::Implicit;
10141014
let src_ty = op.ty(self.body, tcx);
10151015
let mut src_sig = src_ty.fn_sig(tcx);
1016-
if let ty::FnDef(def_id, _) = src_ty.kind()
1016+
if let ty::FnDef(def_id, _) = *src_ty.kind()
10171017
&& let ty::FnPtr(_, target_hdr) = *ty.kind()
10181018
&& tcx.codegen_fn_attrs(def_id).safe_target_features
10191019
&& target_hdr.safety.is_safe()
10201020
&& let Some(safe_sig) = tcx.adjust_target_feature_sig(
1021-
*def_id,
1021+
def_id,
10221022
src_sig,
10231023
self.body.source.def_id(),
10241024
)

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ use rustc_attr_parsing::eval_config_entry;
1818
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
1919
use rustc_data_structures::memmap::Mmap;
2020
use rustc_data_structures::temp_dir::MaybeTempDir;
21-
use rustc_errors::{DiagCtxtHandle, LintDiagnostic};
21+
use rustc_errors::DiagCtxtHandle;
2222
use rustc_fs_util::{TempDirBuilder, fix_windows_verbatim_for_gcc, try_canonicalize};
2323
use rustc_hir::attrs::NativeLibKind;
2424
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
25-
use rustc_macros::LintDiagnostic;
25+
use rustc_macros::Diagnostic;
2626
use rustc_metadata::fs::{METADATA_FILENAME, copy_to_stdout, emit_wrapper_file};
2727
use rustc_metadata::{
2828
EncodedMetadata, NativeLibSearchFallback, find_native_static_library,
2929
walk_native_lib_search_dirs,
3030
};
3131
use rustc_middle::bug;
32-
use rustc_middle::lint::lint_level;
32+
use rustc_middle::lint::diag_lint_level;
3333
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
3434
use rustc_middle::middle::dependency_format::Linkage;
3535
use rustc_middle::middle::exported_symbols::SymbolExportKind;
@@ -662,7 +662,7 @@ fn link_dwarf_object(sess: &Session, cg_results: &CodegenResults, executable_out
662662
}
663663
}
664664

665-
#[derive(LintDiagnostic)]
665+
#[derive(Diagnostic)]
666666
#[diag("{$inner}")]
667667
/// Translating this is kind of useless. We don't pass translation flags to the linker, so we'd just
668668
/// end up with inconsistent languages within the same diagnostic.
@@ -938,9 +938,7 @@ fn link_natively(
938938

939939
let level = codegen_results.crate_info.lint_levels.linker_messages;
940940
let lint = |msg| {
941-
lint_level(sess, LINKER_MESSAGES, level, None, |diag| {
942-
LinkerOutput { inner: msg }.decorate_lint(diag)
943-
})
941+
diag_lint_level(sess, LINKER_MESSAGES, level, None, LinkerOutput { inner: msg });
944942
};
945943

946944
if !prog.stderr.is_empty() {

compiler/rustc_const_eval/src/check_consts/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
577577

578578
Rvalue::Aggregate(kind, ..) => {
579579
if let AggregateKind::Coroutine(def_id, ..) = kind.as_ref()
580-
&& let Some(coroutine_kind) = self.tcx.coroutine_kind(def_id)
580+
&& let Some(coroutine_kind) = self.tcx.coroutine_kind(*def_id)
581581
{
582582
self.check_op(ops::Coroutine(coroutine_kind));
583583
}

compiler/rustc_const_eval/src/interpret/intrinsics/simd.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use either::Either;
22
use rustc_abi::{BackendRepr, Endian};
33
use rustc_apfloat::ieee::{Double, Half, Quad, Single};
44
use rustc_apfloat::{Float, Round};
5-
use rustc_data_structures::assert_matches;
65
use rustc_middle::mir::interpret::{InterpErrorKind, Pointer, UndefinedBehaviorInfo};
76
use rustc_middle::ty::{FloatTy, ScalarInt, SimdAlign};
87
use rustc_middle::{bug, err_ub_format, mir, span_bug, throw_unsup_format, ty};
@@ -838,7 +837,20 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
838837
vector_layout: TyAndLayout<'tcx>,
839838
alignment: SimdAlign,
840839
) -> InterpResult<'tcx> {
841-
assert_matches!(vector_layout.backend_repr, BackendRepr::SimdVector { .. });
840+
// Packed SIMD types with non-power-of-two element counts use BackendRepr::Memory
841+
// instead of BackendRepr::SimdVector. We need to handle both cases.
842+
// FIXME: remove the BackendRepr::Memory case when SIMD vectors are always passed as BackendRepr::SimdVector.
843+
assert!(vector_layout.ty.is_simd(), "check_simd_ptr_alignment called on non-SIMD type");
844+
match vector_layout.backend_repr {
845+
BackendRepr::SimdVector { .. } | BackendRepr::Memory { .. } => {}
846+
_ => {
847+
span_bug!(
848+
self.cur_span(),
849+
"SIMD type has unexpected backend_repr: {:?}",
850+
vector_layout.backend_repr
851+
);
852+
}
853+
}
842854

843855
let align = match alignment {
844856
ty::SimdAlign::Unaligned => {

compiler/rustc_error_messages/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,18 @@ impl MultiSpan {
109109
MultiSpan { primary_spans: vec, span_labels: vec![] }
110110
}
111111

112+
pub fn push_primary_span(&mut self, primary_span: Span) {
113+
self.primary_spans.push(primary_span);
114+
}
115+
112116
pub fn push_span_label(&mut self, span: Span, label: impl Into<DiagMessage>) {
113117
self.span_labels.push((span, label.into()));
114118
}
115119

120+
pub fn push_span_diag(&mut self, span: Span, diag: DiagMessage) {
121+
self.span_labels.push((span, diag));
122+
}
123+
116124
/// Selects the first primary span (if any).
117125
pub fn primary_span(&self) -> Option<Span> {
118126
self.primary_spans.first().cloned()
@@ -179,6 +187,11 @@ impl MultiSpan {
179187
span_labels
180188
}
181189

190+
/// Returns the span labels as contained by `MultiSpan`.
191+
pub fn span_labels_raw(&self) -> &[(Span, DiagMessage)] {
192+
&self.span_labels
193+
}
194+
182195
/// Returns `true` if any of the span labels is displayable.
183196
pub fn has_span_labels(&self) -> bool {
184197
self.span_labels.iter().any(|(sp, _)| !sp.is_dummy())

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,13 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
13241324
drop(self);
13251325
}
13261326

1327+
/// Cancels this diagnostic and returns its first message, if it exists.
1328+
pub fn cancel_into_message(self) -> Option<String> {
1329+
let s = self.diag.as_ref()?.messages.get(0)?.0.as_str().map(ToString::to_string);
1330+
self.cancel();
1331+
s
1332+
}
1333+
13271334
/// See `DiagCtxt::stash_diagnostic` for details.
13281335
pub fn stash(mut self, span: Span, key: StashKey) -> Option<ErrorGuaranteed> {
13291336
let diag = self.take_diag();

0 commit comments

Comments
 (0)