From 66d317925e0a4ea1dc54c52e9895dd6f5745efe3 Mon Sep 17 00:00:00 2001 From: George Wort Date: Thu, 18 Jan 2024 17:39:41 +0000 Subject: [PATCH] Removed rust-analyzer change and rebased --- compiler/rustc_borrowck/src/type_check/mod.rs | 15 ++++++++++----- compiler/rustc_codegen_ssa/src/mir/block.rs | 6 +++--- compiler/rustc_passes/src/check_attr.rs | 14 +++++++------- .../crates/hir-def/src/attr/builtin.rs | 1 - 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index fa3f3d4409000..b282c678b3a19 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -1628,11 +1628,16 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { if index >= args.len() as u128 { span_mirbug!(self, term, "index out of bounds"); } else { - if !matches!(args[index as usize], Operand::Constant(_)) { - self.tcx().sess.emit_err(IntrinsicConstVectorArgNonConst { - span: term.source_info.span, - index, - }); + if !matches!( + args[index.get() as usize], + Spanned { node: Operand::Constant(_), .. } + ) { + self.tcx().dcx().emit_err( + IntrinsicConstVectorArgNonConst { + span: term.source_info.span, + index: index.get(), + }, + ); } } } diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 0cd0fbc811f3f..9390e10ba1e48 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -867,7 +867,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if let mir::Operand::Constant(constant) = &arg.node { let (llval, ty) = self.early_evaluate_const_vector(bx, constant); let llval = llval.unwrap_or_else(|| { - bx.tcx().sess.emit_err(errors::ShuffleIndicesEvaluation { + bx.tcx().dcx().emit_err(errors::ShuffleIndicesEvaluation { span: constant.span, }); // We've errored, so we don't have to produce working code. @@ -928,7 +928,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { .map(|item: &NestedMetaItem| match item { NestedMetaItem::Lit(MetaItemLit { kind: LitKind::Int(index, _), .. - }) => *index as usize, + }) => index.get() as usize, _ => span_bug!(item.span(), "attribute argument must be an integer"), }) .collect() @@ -947,7 +947,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let (llval, ty) = self.early_evaluate_const_vector(bx, &constant); let llval = llval.unwrap_or_else(|| { bx.tcx() - .sess + .dcx() .emit_err(errors::ConstVectorEvaluation { span: constant.span }); // We've errored, so we don't have to produce working code. let llty = bx.backend_type(bx.layout_of(ty)); diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index b473f0e23a614..aa79eaf983a41 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -2125,10 +2125,10 @@ impl<'tcx> CheckAttrVisitor<'tcx> { for meta in list { if let Some(LitKind::Int(val, _)) = meta.lit().map(|lit| &lit.kind) { if *val >= arg_count { - self.tcx.sess.emit_err(errors::RustcIntrinsicConstVectorArgOutOfBounds { + self.tcx.dcx().emit_err(errors::RustcIntrinsicConstVectorArgOutOfBounds { attr_span: attr.span, span: span, - index: *val, + index: val.get(), arg_count: decl.inputs.len(), }); return false; @@ -2170,7 +2170,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { None } - let param_ty = decl.inputs[*val as usize]; + let param_ty = decl.inputs[val.get() as usize]; let type_id = get_type_def(self.tcx, param_ty); let is_simd = if let Some(type_id) = type_id { self.tcx @@ -2182,15 +2182,15 @@ impl<'tcx> CheckAttrVisitor<'tcx> { false }; if !is_simd { - self.tcx.sess.emit_err(errors::RustcIntrinsicConstVectorArgNonVector { + self.tcx.dcx().emit_err(errors::RustcIntrinsicConstVectorArgNonVector { attr_span: attr.span, param_span: param_ty.span, - index: *val, + index: val.get(), }); return false; } } else { - self.tcx.sess.emit_err(errors::RustcIntrinsicConstVectorArgInvalid { + self.tcx.dcx().emit_err(errors::RustcIntrinsicConstVectorArgInvalid { span: meta.span(), }); return false; @@ -2198,7 +2198,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } else { self.tcx - .sess + .dcx() .emit_err(errors::RustcIntrinsicConstVectorArg { attr_span: attr.span, span }); return false; } diff --git a/src/tools/rust-analyzer/crates/hir-def/src/attr/builtin.rs b/src/tools/rust-analyzer/crates/hir-def/src/attr/builtin.rs index 33b064ec7ec28..48a596f7f53a7 100644 --- a/src/tools/rust-analyzer/crates/hir-def/src/attr/builtin.rs +++ b/src/tools/rust-analyzer/crates/hir-def/src/attr/builtin.rs @@ -497,7 +497,6 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[ rustc_attr!( rustc_const_panic_str, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE ), - rustc_attr!(rustc_intrinsic_const_vector_arg, Normal, template!(List: "arg_index1, arg_index2, ..."), ErrorFollowing, INTERNAL_UNSTABLE), // ========================================================================== // Internal attributes, Layout related: