Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustup update and embark standard lints v0.4 #672

Merged
merged 2 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
avoid-breaking-exported-api = false
18 changes: 9 additions & 9 deletions crates/rustc_codegen_spirv/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,19 +410,19 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
let target = Target::from_item(item);
self.check_spirv_attributes(item.hir_id(), target);
intravisit::walk_item(self, item)
intravisit::walk_item(self, item);
}

fn visit_generic_param(&mut self, generic_param: &'tcx hir::GenericParam<'tcx>) {
let target = Target::from_generic_param(generic_param);
self.check_spirv_attributes(generic_param.hir_id, target);
intravisit::walk_generic_param(self, generic_param)
intravisit::walk_generic_param(self, generic_param);
}

fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
let target = Target::from_trait_item(trait_item);
self.check_spirv_attributes(trait_item.hir_id(), target);
intravisit::walk_trait_item(self, trait_item)
intravisit::walk_trait_item(self, trait_item);
}

fn visit_field_def(&mut self, field: &'tcx hir::FieldDef<'tcx>) {
Expand All @@ -438,21 +438,21 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
fn visit_foreign_item(&mut self, f_item: &'tcx hir::ForeignItem<'tcx>) {
let target = Target::from_foreign_item(f_item);
self.check_spirv_attributes(f_item.hir_id(), target);
intravisit::walk_foreign_item(self, f_item)
intravisit::walk_foreign_item(self, f_item);
}

fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
let target = target_from_impl_item(self.tcx, impl_item);
self.check_spirv_attributes(impl_item.hir_id(), target);
intravisit::walk_impl_item(self, impl_item)
intravisit::walk_impl_item(self, impl_item);
}

fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt<'tcx>) {
// When checking statements ignore expressions, they will be checked later.
if let hir::StmtKind::Local(l) = stmt.kind {
self.check_spirv_attributes(l.hir_id, Target::Statement);
}
intravisit::walk_stmt(self, stmt)
intravisit::walk_stmt(self, stmt);
}

fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
Expand All @@ -462,7 +462,7 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
};

self.check_spirv_attributes(expr.hir_id, target);
intravisit::walk_expr(self, expr)
intravisit::walk_expr(self, expr);
}

fn visit_variant(
Expand All @@ -472,7 +472,7 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
item_id: HirId,
) {
self.check_spirv_attributes(variant.id, Target::Variant);
intravisit::walk_variant(self, variant, generics, item_id)
intravisit::walk_variant(self, variant, generics, item_id);
}

fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef<'tcx>) {
Expand Down Expand Up @@ -528,7 +528,7 @@ pub(crate) fn provide(providers: &mut Providers) {
check_mod_attrs: |tcx, def_id| {
// Run both the default checks, and our `#[spirv(...)]` ones.
(rustc_interface::DEFAULT_QUERY_PROVIDERS.check_mod_attrs)(tcx, def_id);
check_mod_attrs(tcx, def_id)
check_mod_attrs(tcx, def_id);
},
..*providers
};
Expand Down
18 changes: 9 additions & 9 deletions crates/rustc_codegen_spirv/src/builder/builder_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
}

fn br(&mut self, dest: Self::BasicBlock) {
self.emit().branch(dest).unwrap()
self.emit().branch(dest).unwrap();
}

fn cond_br(
Expand All @@ -561,7 +561,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
) {
self.emit()
.branch_conditional(cond.def(self), then_llbb, else_llbb, empty())
.unwrap()
.unwrap();
}

fn switch(
Expand Down Expand Up @@ -638,7 +638,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
let cases = cases
.map(|(i, b)| (construct_case(self, signed, i), b))
.collect::<Vec<_>>();
self.emit().switch(v.def(self), else_llbb, cases).unwrap()
self.emit().switch(v.def(self), else_llbb, cases).unwrap();
}

fn invoke(
Expand All @@ -656,7 +656,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
}

fn unreachable(&mut self) {
self.emit().unreachable().unwrap()
self.emit().unreachable().unwrap();
}

simple_op! {add, i_add}
Expand Down Expand Up @@ -1281,12 +1281,12 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
self.zombie(
result.def(self),
"OpBitcast between ptr and non-ptr without AddressingModel != Logical",
)
);
} else {
self.struct_err("Cannot cast between pointer and non-pointer types")
.note(&format!("from: {}", self.debug_type(val.ty)))
.note(&format!("to: {}", self.debug_type(dest_ty)))
.emit()
.emit();
}
}

Expand Down Expand Up @@ -1717,7 +1717,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
self.zombie(
dst.def(self),
"OpCopyMemorySized without OpCapability Addresses",
)
);
}
}
}
Expand All @@ -1731,7 +1731,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
size: Self::Value,
flags: MemFlags,
) {
self.memcpy(dst, dst_align, src, src_align, size, flags)
self.memcpy(dst, dst_align, src, src_align, size, flags);
}

fn memset(
Expand Down Expand Up @@ -1858,7 +1858,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
fn insert_value(&mut self, agg_val: Self::Value, elt: Self::Value, idx: u64) -> Self::Value {
match self.lookup_type(agg_val.ty) {
SpirvType::Adt { field_types, .. } => {
assert_ty_eq!(self, field_types[idx as usize], elt.ty)
assert_ty_eq!(self, field_types[idx as usize], elt.ty);
}
other => self.fatal(&format!("insert_value not implemented on type {:?}", other)),
};
Expand Down
8 changes: 4 additions & 4 deletions crates/rustc_codegen_spirv/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {

pub fn err(&self, msg: &str) {
if let Some(current_span) = self.current_span {
self.tcx.sess.span_err(current_span, msg)
self.tcx.sess.span_err(current_span, msg);
} else {
self.tcx.sess.err(msg)
self.tcx.sess.err(msg);
}
}

Expand Down Expand Up @@ -286,7 +286,7 @@ impl<'a, 'tcx> ArgAbiMethods<'tcx> for Builder<'a, 'tcx> {
match arg_abi.mode {
PassMode::Ignore => (),
PassMode::Pair(..) => {
OperandValue::Pair(next(self, idx), next(self, idx)).store(self, dst)
OperandValue::Pair(next(self, idx), next(self, idx)).store(self, dst);
}
PassMode::Indirect {
extra_attrs: Some(_),
Expand All @@ -303,7 +303,7 @@ impl<'a, 'tcx> ArgAbiMethods<'tcx> for Builder<'a, 'tcx> {
}
| PassMode::Cast(_) => {
let next_arg = next(self, idx);
self.store_arg(arg_abi, next_arg, dst)
self.store_arg(arg_abi, next_arg, dst);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions crates/rustc_codegen_spirv/src/builder/spirv_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> {
match typeof_kind {
Some(kind) => {
*line.last_mut().unwrap() =
Token::Typeof(&operands[operand_idx], span, kind)
Token::Typeof(&operands[operand_idx], span, kind);
}
None => match &operands[operand_idx] {
InlineAsmOperandRef::Const { string } => line.push(Token::Word(string)),
Expand Down Expand Up @@ -992,21 +992,21 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
};
match (kind, word) {
(OperandKind::IdResultType | OperandKind::IdResult, _) => {
bug!("should be handled by parse_operands")
bug!("should be handled by parse_operands");
}
(OperandKind::IdMemorySemantics, _) => {
if let Some(id) = self.parse_id_in(id_map, token) {
inst.operands.push(dr::Operand::IdMemorySemantics(id))
inst.operands.push(dr::Operand::IdMemorySemantics(id));
}
}
(OperandKind::IdScope, _) => {
if let Some(id) = self.parse_id_in(id_map, token) {
inst.operands.push(dr::Operand::IdScope(id))
inst.operands.push(dr::Operand::IdScope(id));
}
}
(OperandKind::IdRef, _) => {
if let Some(id) = self.parse_id_in(id_map, token) {
inst.operands.push(dr::Operand::IdRef(id))
inst.operands.push(dr::Operand::IdRef(id));
}
}

Expand Down Expand Up @@ -1079,7 +1079,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
}
}
(OperandKind::PairLiteralIntegerIdRef, _) => {
self.err("PairLiteralIntegerIdRef not supported yet")
self.err("PairLiteralIntegerIdRef not supported yet");
}
(OperandKind::PairIdRefLiteralInteger, _) => {
if let Some(id) = self.parse_id_in(id_map, token) {
Expand Down
4 changes: 2 additions & 2 deletions crates/rustc_codegen_spirv/src/builder_spirv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ impl SpirvValue {
zombie_target_undef,
span,
"OpBitcast on ptr without AddressingModel != Logical",
)
);
} else {
cx.tcx
.sess
.struct_span_err(span, "Cannot cast between pointer types")
.note(&format!("from: *{}", cx.debug_type(original_pointee_ty)))
.note(&format!("to: {}", cx.debug_type(self.ty)))
.emit()
.emit();
}

zombie_target_undef
Expand Down
11 changes: 4 additions & 7 deletions crates/rustc_codegen_spirv/src/codegen_cx/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use super::CodegenCx;
use crate::abi::ConvSpirvType;
use crate::attr::AggregatedSpirvAttributes;
use crate::builder_spirv::{SpirvConst, SpirvValue, SpirvValueExt};
use crate::decorations::UnrollLoopsDecoration;
use crate::spirv_type::SpirvType;
use rspirv::spirv::{FunctionControl, LinkageType, StorageClass, Word};
use rustc_attr::InlineAttr;
Expand All @@ -25,10 +24,10 @@ fn attrs_to_spirv(attrs: &CodegenFnAttrs) -> FunctionControl {
InlineAttr::Never => control.insert(FunctionControl::DONT_INLINE),
}
if attrs.flags.contains(CodegenFnAttrFlags::FFI_PURE) {
control.insert(FunctionControl::PURE)
control.insert(FunctionControl::PURE);
}
if attrs.flags.contains(CodegenFnAttrFlags::FFI_CONST) {
control.insert(FunctionControl::CONST)
control.insert(FunctionControl::CONST);
}
control
}
Expand Down Expand Up @@ -117,12 +116,10 @@ impl<'tcx> CodegenCx<'tcx> {
.as_ref()
.map(ToString::to_string)
.unwrap_or_else(|| instance.to_string());
self.entry_stub(&instance, &fn_abi, declared, entry_name, entry)
self.entry_stub(&instance, &fn_abi, declared, entry_name, entry);
}
if attrs.unroll_loops.is_some() {
self.unroll_loops_decorations
.borrow_mut()
.insert(fn_id, UnrollLoopsDecoration {});
self.unroll_loops_decorations.borrow_mut().insert(fn_id);
}
if attrs.internal_buffer_load.is_some() {
self.internal_buffer_load_id.borrow_mut().insert(fn_id);
Expand Down
14 changes: 7 additions & 7 deletions crates/rustc_codegen_spirv/src/codegen_cx/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl<'tcx> CodegenCx<'tcx> {
"PassMode {:?} invalid for entry point return type",
fn_abi.ret.mode
),
)
);
}
let execution_model = entry.execution_model;
let fn_id = if execution_model == ExecutionModel::Kernel {
Expand Down Expand Up @@ -306,7 +306,7 @@ impl<'tcx> CodegenCx<'tcx> {
&mut bx,
&mut call_args,
&mut decoration_locations,
)
);
}
bx.set_span(span);
bx.call(entry_func, &call_args, None);
Expand Down Expand Up @@ -540,15 +540,15 @@ impl<'tcx> CodegenCx<'tcx> {
self.tcx.sess.span_err(
hir_param.ty_span,
"uniform_constant must use &RuntimeArray<T>, not &[T]",
)
);
}
}
_ => {
if is_unsized {
self.tcx.sess.span_err(
hir_param.ty_span,
"only plain slices are supported as unsized types",
)
);
}
}
}
Expand Down Expand Up @@ -686,11 +686,11 @@ impl<'tcx> CodegenCx<'tcx> {
var,
Decoration::InputAttachmentIndex,
std::iter::once(Operand::LiteralInt32(attachment_index.value)),
)
);
} else if is_subpass_input {
self.tcx
.sess
.span_err(hir_param.ty_span, "Missing capability InputAttachment")
.span_err(hir_param.ty_span, "Missing capability InputAttachment");
} else {
self.tcx.sess.span_err(
attachment_index.span,
Expand All @@ -702,7 +702,7 @@ impl<'tcx> CodegenCx<'tcx> {
self.tcx.sess.span_err(
hir_param.ty_span,
"Image types with dim = SubpassData require #[spirv(input_attachment_index)] decoration",
)
);
}

// Assign locations from left to right, incrementing each storage class
Expand Down
Loading