rustup update and embark standard lints v0.4 (#672)

* rustup update

* update to embark standard lints v0.4
This commit is contained in:
Ashley Hauck 2021-06-17 13:10:19 +02:00 committed by GitHub
parent 04dfa80266
commit db5e5fd336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 284 additions and 138 deletions

1
clippy.toml Normal file
View File

@ -0,0 +1 @@
avoid-breaking-exported-api = false

View File

@ -410,19 +410,19 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
let target = Target::from_item(item); let target = Target::from_item(item);
self.check_spirv_attributes(item.hir_id(), target); 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>) { fn visit_generic_param(&mut self, generic_param: &'tcx hir::GenericParam<'tcx>) {
let target = Target::from_generic_param(generic_param); let target = Target::from_generic_param(generic_param);
self.check_spirv_attributes(generic_param.hir_id, target); 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>) { fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
let target = Target::from_trait_item(trait_item); let target = Target::from_trait_item(trait_item);
self.check_spirv_attributes(trait_item.hir_id(), target); 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>) { fn visit_field_def(&mut self, field: &'tcx hir::FieldDef<'tcx>) {
@ -438,13 +438,13 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
fn visit_foreign_item(&mut self, f_item: &'tcx hir::ForeignItem<'tcx>) { fn visit_foreign_item(&mut self, f_item: &'tcx hir::ForeignItem<'tcx>) {
let target = Target::from_foreign_item(f_item); let target = Target::from_foreign_item(f_item);
self.check_spirv_attributes(f_item.hir_id(), target); 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>) { fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
let target = target_from_impl_item(self.tcx, impl_item); let target = target_from_impl_item(self.tcx, impl_item);
self.check_spirv_attributes(impl_item.hir_id(), target); 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>) { fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt<'tcx>) {
@ -452,7 +452,7 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
if let hir::StmtKind::Local(l) = stmt.kind { if let hir::StmtKind::Local(l) = stmt.kind {
self.check_spirv_attributes(l.hir_id, Target::Statement); 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>) { fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
@ -462,7 +462,7 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
}; };
self.check_spirv_attributes(expr.hir_id, target); self.check_spirv_attributes(expr.hir_id, target);
intravisit::walk_expr(self, expr) intravisit::walk_expr(self, expr);
} }
fn visit_variant( fn visit_variant(
@ -472,7 +472,7 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
item_id: HirId, item_id: HirId,
) { ) {
self.check_spirv_attributes(variant.id, Target::Variant); 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>) { fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef<'tcx>) {
@ -528,7 +528,7 @@ pub(crate) fn provide(providers: &mut Providers) {
check_mod_attrs: |tcx, def_id| { check_mod_attrs: |tcx, def_id| {
// Run both the default checks, and our `#[spirv(...)]` ones. // Run both the default checks, and our `#[spirv(...)]` ones.
(rustc_interface::DEFAULT_QUERY_PROVIDERS.check_mod_attrs)(tcx, def_id); (rustc_interface::DEFAULT_QUERY_PROVIDERS.check_mod_attrs)(tcx, def_id);
check_mod_attrs(tcx, def_id) check_mod_attrs(tcx, def_id);
}, },
..*providers ..*providers
}; };

View File

@ -550,7 +550,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
} }
fn br(&mut self, dest: Self::BasicBlock) { fn br(&mut self, dest: Self::BasicBlock) {
self.emit().branch(dest).unwrap() self.emit().branch(dest).unwrap();
} }
fn cond_br( fn cond_br(
@ -561,7 +561,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
) { ) {
self.emit() self.emit()
.branch_conditional(cond.def(self), then_llbb, else_llbb, empty()) .branch_conditional(cond.def(self), then_llbb, else_llbb, empty())
.unwrap() .unwrap();
} }
fn switch( fn switch(
@ -638,7 +638,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
let cases = cases let cases = cases
.map(|(i, b)| (construct_case(self, signed, i), b)) .map(|(i, b)| (construct_case(self, signed, i), b))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
self.emit().switch(v.def(self), else_llbb, cases).unwrap() self.emit().switch(v.def(self), else_llbb, cases).unwrap();
} }
fn invoke( fn invoke(
@ -656,7 +656,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
} }
fn unreachable(&mut self) { fn unreachable(&mut self) {
self.emit().unreachable().unwrap() self.emit().unreachable().unwrap();
} }
simple_op! {add, i_add} simple_op! {add, i_add}
@ -1281,12 +1281,12 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
self.zombie( self.zombie(
result.def(self), result.def(self),
"OpBitcast between ptr and non-ptr without AddressingModel != Logical", "OpBitcast between ptr and non-ptr without AddressingModel != Logical",
) );
} else { } else {
self.struct_err("Cannot cast between pointer and non-pointer types") self.struct_err("Cannot cast between pointer and non-pointer types")
.note(&format!("from: {}", self.debug_type(val.ty))) .note(&format!("from: {}", self.debug_type(val.ty)))
.note(&format!("to: {}", self.debug_type(dest_ty))) .note(&format!("to: {}", self.debug_type(dest_ty)))
.emit() .emit();
} }
} }
@ -1717,7 +1717,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
self.zombie( self.zombie(
dst.def(self), dst.def(self),
"OpCopyMemorySized without OpCapability Addresses", "OpCopyMemorySized without OpCapability Addresses",
) );
} }
} }
} }
@ -1731,7 +1731,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
size: Self::Value, size: Self::Value,
flags: MemFlags, flags: MemFlags,
) { ) {
self.memcpy(dst, dst_align, src, src_align, size, flags) self.memcpy(dst, dst_align, src, src_align, size, flags);
} }
fn memset( fn memset(
@ -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 { fn insert_value(&mut self, agg_val: Self::Value, elt: Self::Value, idx: u64) -> Self::Value {
match self.lookup_type(agg_val.ty) { match self.lookup_type(agg_val.ty) {
SpirvType::Adt { field_types, .. } => { 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)), other => self.fatal(&format!("insert_value not implemented on type {:?}", other)),
}; };

View File

@ -76,9 +76,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
pub fn err(&self, msg: &str) { pub fn err(&self, msg: &str) {
if let Some(current_span) = self.current_span { 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 { } else {
self.tcx.sess.err(msg) self.tcx.sess.err(msg);
} }
} }
@ -286,7 +286,7 @@ impl<'a, 'tcx> ArgAbiMethods<'tcx> for Builder<'a, 'tcx> {
match arg_abi.mode { match arg_abi.mode {
PassMode::Ignore => (), PassMode::Ignore => (),
PassMode::Pair(..) => { 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 { PassMode::Indirect {
extra_attrs: Some(_), extra_attrs: Some(_),
@ -303,7 +303,7 @@ impl<'a, 'tcx> ArgAbiMethods<'tcx> for Builder<'a, 'tcx> {
} }
| PassMode::Cast(_) => { | PassMode::Cast(_) => {
let next_arg = next(self, idx); let next_arg = next(self, idx);
self.store_arg(arg_abi, next_arg, dst) self.store_arg(arg_abi, next_arg, dst);
} }
} }
} }

View File

@ -121,7 +121,7 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> {
match typeof_kind { match typeof_kind {
Some(kind) => { Some(kind) => {
*line.last_mut().unwrap() = *line.last_mut().unwrap() =
Token::Typeof(&operands[operand_idx], span, kind) Token::Typeof(&operands[operand_idx], span, kind);
} }
None => match &operands[operand_idx] { None => match &operands[operand_idx] {
InlineAsmOperandRef::Const { string } => line.push(Token::Word(string)), InlineAsmOperandRef::Const { string } => line.push(Token::Word(string)),
@ -992,21 +992,21 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
}; };
match (kind, word) { match (kind, word) {
(OperandKind::IdResultType | OperandKind::IdResult, _) => { (OperandKind::IdResultType | OperandKind::IdResult, _) => {
bug!("should be handled by parse_operands") bug!("should be handled by parse_operands");
} }
(OperandKind::IdMemorySemantics, _) => { (OperandKind::IdMemorySemantics, _) => {
if let Some(id) = self.parse_id_in(id_map, token) { 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, _) => { (OperandKind::IdScope, _) => {
if let Some(id) = self.parse_id_in(id_map, token) { 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, _) => { (OperandKind::IdRef, _) => {
if let Some(id) = self.parse_id_in(id_map, token) { 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));
} }
} }
@ -1079,7 +1079,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
} }
} }
(OperandKind::PairLiteralIntegerIdRef, _) => { (OperandKind::PairLiteralIntegerIdRef, _) => {
self.err("PairLiteralIntegerIdRef not supported yet") self.err("PairLiteralIntegerIdRef not supported yet");
} }
(OperandKind::PairIdRefLiteralInteger, _) => { (OperandKind::PairIdRefLiteralInteger, _) => {
if let Some(id) = self.parse_id_in(id_map, token) { if let Some(id) = self.parse_id_in(id_map, token) {

View File

@ -177,14 +177,14 @@ impl SpirvValue {
zombie_target_undef, zombie_target_undef,
span, span,
"OpBitcast on ptr without AddressingModel != Logical", "OpBitcast on ptr without AddressingModel != Logical",
) );
} else { } else {
cx.tcx cx.tcx
.sess .sess
.struct_span_err(span, "Cannot cast between pointer types") .struct_span_err(span, "Cannot cast between pointer types")
.note(&format!("from: *{}", cx.debug_type(original_pointee_ty))) .note(&format!("from: *{}", cx.debug_type(original_pointee_ty)))
.note(&format!("to: {}", cx.debug_type(self.ty))) .note(&format!("to: {}", cx.debug_type(self.ty)))
.emit() .emit();
} }
zombie_target_undef zombie_target_undef

View File

@ -2,7 +2,6 @@ use super::CodegenCx;
use crate::abi::ConvSpirvType; use crate::abi::ConvSpirvType;
use crate::attr::AggregatedSpirvAttributes; use crate::attr::AggregatedSpirvAttributes;
use crate::builder_spirv::{SpirvConst, SpirvValue, SpirvValueExt}; use crate::builder_spirv::{SpirvConst, SpirvValue, SpirvValueExt};
use crate::decorations::UnrollLoopsDecoration;
use crate::spirv_type::SpirvType; use crate::spirv_type::SpirvType;
use rspirv::spirv::{FunctionControl, LinkageType, StorageClass, Word}; use rspirv::spirv::{FunctionControl, LinkageType, StorageClass, Word};
use rustc_attr::InlineAttr; use rustc_attr::InlineAttr;
@ -25,10 +24,10 @@ fn attrs_to_spirv(attrs: &CodegenFnAttrs) -> FunctionControl {
InlineAttr::Never => control.insert(FunctionControl::DONT_INLINE), InlineAttr::Never => control.insert(FunctionControl::DONT_INLINE),
} }
if attrs.flags.contains(CodegenFnAttrFlags::FFI_PURE) { if attrs.flags.contains(CodegenFnAttrFlags::FFI_PURE) {
control.insert(FunctionControl::PURE) control.insert(FunctionControl::PURE);
} }
if attrs.flags.contains(CodegenFnAttrFlags::FFI_CONST) { if attrs.flags.contains(CodegenFnAttrFlags::FFI_CONST) {
control.insert(FunctionControl::CONST) control.insert(FunctionControl::CONST);
} }
control control
} }
@ -117,12 +116,10 @@ impl<'tcx> CodegenCx<'tcx> {
.as_ref() .as_ref()
.map(ToString::to_string) .map(ToString::to_string)
.unwrap_or_else(|| instance.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() { if attrs.unroll_loops.is_some() {
self.unroll_loops_decorations self.unroll_loops_decorations.borrow_mut().insert(fn_id);
.borrow_mut()
.insert(fn_id, UnrollLoopsDecoration {});
} }
if attrs.internal_buffer_load.is_some() { if attrs.internal_buffer_load.is_some() {
self.internal_buffer_load_id.borrow_mut().insert(fn_id); self.internal_buffer_load_id.borrow_mut().insert(fn_id);

View File

@ -83,7 +83,7 @@ impl<'tcx> CodegenCx<'tcx> {
"PassMode {:?} invalid for entry point return type", "PassMode {:?} invalid for entry point return type",
fn_abi.ret.mode fn_abi.ret.mode
), ),
) );
} }
let execution_model = entry.execution_model; let execution_model = entry.execution_model;
let fn_id = if execution_model == ExecutionModel::Kernel { let fn_id = if execution_model == ExecutionModel::Kernel {
@ -306,7 +306,7 @@ impl<'tcx> CodegenCx<'tcx> {
&mut bx, &mut bx,
&mut call_args, &mut call_args,
&mut decoration_locations, &mut decoration_locations,
) );
} }
bx.set_span(span); bx.set_span(span);
bx.call(entry_func, &call_args, None); bx.call(entry_func, &call_args, None);
@ -540,7 +540,7 @@ impl<'tcx> CodegenCx<'tcx> {
self.tcx.sess.span_err( self.tcx.sess.span_err(
hir_param.ty_span, hir_param.ty_span,
"uniform_constant must use &RuntimeArray<T>, not &[T]", "uniform_constant must use &RuntimeArray<T>, not &[T]",
) );
} }
} }
_ => { _ => {
@ -548,7 +548,7 @@ impl<'tcx> CodegenCx<'tcx> {
self.tcx.sess.span_err( self.tcx.sess.span_err(
hir_param.ty_span, hir_param.ty_span,
"only plain slices are supported as unsized types", "only plain slices are supported as unsized types",
) );
} }
} }
} }
@ -686,11 +686,11 @@ impl<'tcx> CodegenCx<'tcx> {
var, var,
Decoration::InputAttachmentIndex, Decoration::InputAttachmentIndex,
std::iter::once(Operand::LiteralInt32(attachment_index.value)), std::iter::once(Operand::LiteralInt32(attachment_index.value)),
) );
} else if is_subpass_input { } else if is_subpass_input {
self.tcx self.tcx
.sess .sess
.span_err(hir_param.ty_span, "Missing capability InputAttachment") .span_err(hir_param.ty_span, "Missing capability InputAttachment");
} else { } else {
self.tcx.sess.span_err( self.tcx.sess.span_err(
attachment_index.span, attachment_index.span,
@ -702,7 +702,7 @@ impl<'tcx> CodegenCx<'tcx> {
self.tcx.sess.span_err( self.tcx.sess.span_err(
hir_param.ty_span, hir_param.ty_span,
"Image types with dim = SubpassData require #[spirv(input_attachment_index)] decoration", "Image types with dim = SubpassData require #[spirv(input_attachment_index)] decoration",
) );
} }
// Assign locations from left to right, incrementing each storage class // Assign locations from left to right, incrementing each storage class

View File

@ -66,7 +66,7 @@ pub struct CodegenCx<'tcx> {
/// Functions that have `#[spirv(unroll_loops)]`, and therefore should /// Functions that have `#[spirv(unroll_loops)]`, and therefore should
/// get `LoopControl::UNROLL` applied to all of their loops' `OpLoopMerge` /// get `LoopControl::UNROLL` applied to all of their loops' `OpLoopMerge`
/// instructions, during structuralization. /// instructions, during structuralization.
unroll_loops_decorations: RefCell<FxHashMap<Word, UnrollLoopsDecoration>>, unroll_loops_decorations: RefCell<FxHashSet<Word>>,
/// Cache of all the builtin symbols we need /// Cache of all the builtin symbols we need
pub sym: Rc<Symbols>, pub sym: Rc<Symbols>,
pub instruction_table: InstructionTable, pub instruction_table: InstructionTable,
@ -211,7 +211,7 @@ impl<'tcx> CodegenCx<'tcx> {
} }
} }
pub fn zombie_no_span(&self, word: Word, reason: &str) { pub fn zombie_no_span(&self, word: Word, reason: &str) {
self.zombie_with_span(word, DUMMY_SP, reason) self.zombie_with_span(word, DUMMY_SP, reason);
} }
pub fn zombie_even_in_user_code(&self, word: Word, span: Span, reason: &str) { pub fn zombie_even_in_user_code(&self, word: Word, span: Span, reason: &str) {
self.zombie_decorations.borrow_mut().insert( self.zombie_decorations.borrow_mut().insert(
@ -255,7 +255,7 @@ impl<'tcx> CodegenCx<'tcx> {
self.unroll_loops_decorations self.unroll_loops_decorations
.into_inner() .into_inner()
.into_iter() .into_iter()
.map(|(id, unroll_loops)| unroll_loops.encode(id)), .map(|id| UnrollLoopsDecoration {}.encode(id)),
), ),
); );
result result
@ -266,7 +266,7 @@ impl<'tcx> CodegenCx<'tcx> {
target, target,
Decoration::LinkageAttributes, Decoration::LinkageAttributes,
once(Operand::LiteralString(name)).chain(once(Operand::LinkageType(linkage))), once(Operand::LiteralString(name)).chain(once(Operand::LinkageType(linkage))),
) );
} }
} }
@ -371,20 +371,20 @@ impl CodegenArgs {
let mut remap = std::collections::HashMap::new(); let mut remap = std::collections::HashMap::new();
let mut insert = |current_id: &mut u32| { let mut insert = |current_id: &mut u32| {
let len = remap.len(); let len = remap.len();
*current_id = *remap.entry(*current_id).or_insert_with(|| len as u32 + 1) *current_id = *remap.entry(*current_id).or_insert_with(|| len as u32 + 1);
}; };
module.all_inst_iter_mut().for_each(|inst| { module.all_inst_iter_mut().for_each(|inst| {
if let Some(ref mut result_id) = &mut inst.result_id { if let Some(ref mut result_id) = &mut inst.result_id {
insert(result_id) insert(result_id);
} }
if let Some(ref mut result_type) = &mut inst.result_type { if let Some(ref mut result_type) = &mut inst.result_type {
insert(result_type) insert(result_type);
} }
inst.operands.iter_mut().for_each(|op| { inst.operands.iter_mut().for_each(|op| {
if let Some(w) = op.id_ref_any_mut() { if let Some(w) = op.id_ref_any_mut() {
insert(w) insert(w);
} }
}) });
}); });
remap.len() as u32 + 1 remap.len() as u32 + 1
} }

View File

@ -71,7 +71,7 @@ impl<'tcx> LayoutTypeMethods<'tcx> for CodegenCx<'tcx> {
fn backend_field_index(&self, layout: TyAndLayout<'tcx>, index: usize) -> u64 { fn backend_field_index(&self, layout: TyAndLayout<'tcx>, index: usize) -> u64 {
match layout.abi { match layout.abi {
Abi::Scalar(_) | Abi::ScalarPair(..) => { Abi::Scalar(_) | Abi::ScalarPair(..) => {
bug!("backend_field_index({:?}): not applicable", layout) bug!("backend_field_index({:?}): not applicable", layout);
} }
_ => {} _ => {}
} }

View File

@ -75,7 +75,7 @@ pub trait CustomDecoration: for<'de> Deserialize<'de> + Serialize {
fn remove_all(module: &mut Module) { fn remove_all(module: &mut Module) {
module module
.annotations .annotations
.retain(|inst| Self::try_decode(inst).is_none()) .retain(|inst| Self::try_decode(inst).is_none());
} }
} }

View File

@ -18,30 +18,39 @@
#![feature(rustc_private)] #![feature(rustc_private)]
#![feature(assert_matches)] #![feature(assert_matches)]
#![feature(once_cell)] #![feature(once_cell)]
// BEGIN - Embark standard lints v0.3 // BEGIN - Embark standard lints v0.4
// do not change or add/remove here, but one can add exceptions after this section // do not change or add/remove here, but one can add exceptions after this section
// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59> // for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![warn( #![warn(
clippy::all, clippy::all,
clippy::await_holding_lock, clippy::await_holding_lock,
clippy::char_lit_as_u8,
clippy::checked_conversions,
clippy::dbg_macro, clippy::dbg_macro,
clippy::debug_assert_with_mut_call, clippy::debug_assert_with_mut_call,
clippy::doc_markdown, clippy::doc_markdown,
clippy::empty_enum, clippy::empty_enum,
clippy::enum_glob_use, clippy::enum_glob_use,
clippy::exit, clippy::exit,
clippy::expl_impl_clone_on_copy,
clippy::explicit_deref_methods,
clippy::explicit_into_iter_loop, clippy::explicit_into_iter_loop,
clippy::fallible_impl_from,
clippy::filter_map_next, clippy::filter_map_next,
clippy::float_cmp_const,
clippy::fn_params_excessive_bools, clippy::fn_params_excessive_bools,
clippy::if_let_mutex, clippy::if_let_mutex,
clippy::implicit_clone,
clippy::imprecise_flops, clippy::imprecise_flops,
clippy::inefficient_to_string, clippy::inefficient_to_string,
clippy::invalid_upcast_comparisons,
clippy::large_types_passed_by_value, clippy::large_types_passed_by_value,
clippy::let_unit_value, clippy::let_unit_value,
clippy::linkedlist, clippy::linkedlist,
clippy::lossy_float_literal, clippy::lossy_float_literal,
clippy::macro_use_imports, clippy::macro_use_imports,
clippy::manual_ok_or,
clippy::map_err_ignore, clippy::map_err_ignore,
clippy::map_flatten, clippy::map_flatten,
clippy::map_unwrap_or, clippy::map_unwrap_or,
@ -50,26 +59,34 @@
clippy::match_wildcard_for_single_variants, clippy::match_wildcard_for_single_variants,
clippy::mem_forget, clippy::mem_forget,
clippy::mismatched_target_os, clippy::mismatched_target_os,
clippy::mut_mut,
clippy::mutex_integer,
clippy::needless_borrow, clippy::needless_borrow,
clippy::needless_continue, clippy::needless_continue,
clippy::option_option, clippy::option_option,
clippy::pub_enum_variant_names, clippy::path_buf_push_overwrite,
clippy::ptr_as_ptr,
clippy::ref_option_ref, clippy::ref_option_ref,
clippy::rest_pat_in_fully_bound_structs, clippy::rest_pat_in_fully_bound_structs,
clippy::same_functions_in_if_condition,
clippy::semicolon_if_nothing_returned,
clippy::string_add_assign, clippy::string_add_assign,
clippy::string_add, clippy::string_add,
clippy::string_lit_as_bytes,
clippy::string_to_string, clippy::string_to_string,
clippy::suboptimal_flops,
clippy::todo, clippy::todo,
clippy::trait_duplication_in_bounds,
clippy::unimplemented, clippy::unimplemented,
clippy::unnested_or_patterns, clippy::unnested_or_patterns,
clippy::unused_self, clippy::unused_self,
clippy::useless_transmute,
clippy::verbose_file_reads, clippy::verbose_file_reads,
clippy::zero_sized_map_values,
future_incompatible, future_incompatible,
nonstandard_style, nonstandard_style,
rust_2018_idioms rust_2018_idioms
)] )]
// END - Embark standard lints v0.3 // END - Embark standard lints v0.4
// crate-specific exceptions: // crate-specific exceptions:
#![allow( #![allow(
unsafe_code, // still quite a bit of unsafe unsafe_code, // still quite a bit of unsafe
@ -182,7 +199,7 @@ fn dump_mir<'tcx>(
if matches!(instance.def, InstanceDef::Item(_)) { if matches!(instance.def, InstanceDef::Item(_)) {
let mut mir = Cursor::new(Vec::new()); let mut mir = Cursor::new(Vec::new());
if write_mir_pretty(tcx, Some(instance.def_id()), &mut mir).is_ok() { if write_mir_pretty(tcx, Some(instance.def_id()), &mut mir).is_ok() {
writeln!(file, "{}", String::from_utf8(mir.into_inner()).unwrap()).unwrap() writeln!(file, "{}", String::from_utf8(mir.into_inner()).unwrap()).unwrap();
} }
} }
} }
@ -378,7 +395,7 @@ impl CodegenBackend for SpirvCodegenBackend {
sess, sess,
&codegen_results, &codegen_results,
outputs, outputs,
&codegen_results.crate_name.as_str(), &codegen_results.crate_info.local_crate_name.as_str(),
); );
drop(timer); drop(timer);
@ -561,7 +578,7 @@ impl ExtraBackendMethods for SpirvCodegenBackend {
if let Ok(ref path) = env::var("DUMP_MODULE_ON_PANIC") { if let Ok(ref path) = env::var("DUMP_MODULE_ON_PANIC") {
let module_dumper = DumpModuleOnPanic { cx: &cx, path }; let module_dumper = DumpModuleOnPanic { cx: &cx, path };
with_no_trimmed_paths(do_codegen); with_no_trimmed_paths(do_codegen);
drop(module_dumper) drop(module_dumper);
} else { } else {
with_no_trimmed_paths(do_codegen); with_no_trimmed_paths(do_codegen);
} }

View File

@ -64,7 +64,7 @@ pub fn link<'a>(
link_rlib(sess, codegen_results, &out_filename); link_rlib(sess, codegen_results, &out_filename);
} }
CrateType::Executable | CrateType::Cdylib | CrateType::Dylib => { CrateType::Executable | CrateType::Cdylib | CrateType::Dylib => {
link_exe(sess, crate_type, &out_filename, codegen_results) link_exe(sess, crate_type, &out_filename, codegen_results);
} }
other => sess.err(&format!("CrateType {:?} not supported yet", other)), other => sess.err(&format!("CrateType {:?} not supported yet", other)),
} }

View File

@ -112,6 +112,6 @@ pub fn dce_phi(func: &mut Function) {
for block in &mut func.blocks { for block in &mut func.blocks {
block block
.instructions .instructions
.retain(|inst| inst.class.opcode != Op::Phi || used.contains(&inst.result_id.unwrap())) .retain(|inst| inst.class.opcode != Op::Phi || used.contains(&inst.result_id.unwrap()));
} }
} }

View File

@ -146,7 +146,7 @@ fn make_dedupe_key(
0 0
}); });
if let Some(annos) = annotations.get(&id) { if let Some(annos) = annotations.get(&id) {
data.extend_from_slice(annos) data.extend_from_slice(annos);
} }
if inst.class.opcode == Op::Variable { if inst.class.opcode == Op::Variable {
// Names only matter for OpVariable. // Names only matter for OpVariable.

View File

@ -176,7 +176,7 @@ fn replace_all_uses_with(module: &mut Module, rules: &FxHashMap<u32, u32>) {
*w = rewrite; *w = rewrite;
} }
} }
}) });
}); });
} }
@ -201,7 +201,7 @@ fn kill_linkage_instructions(module: &mut Module, rewrite_rules: &FxHashMap<u32,
module.capabilities.retain(|inst| { module.capabilities.retain(|inst| {
inst.class.opcode != Op::Capability inst.class.opcode != Op::Capability
|| inst.operands[0].unwrap_capability() != Capability::Linkage || inst.operands[0].unwrap_capability() != Capability::Linkage
}) });
} }
fn import_kill_annotations_and_debug( fn import_kill_annotations_and_debug(
@ -228,7 +228,7 @@ fn import_kill_annotations_and_debug(
op.id_ref_any().map_or(true, |id| { op.id_ref_any().map_or(true, |id| {
!rewrite_rules.contains_key(&id) && !killed_parameters.contains(&id) !rewrite_rules.contains_key(&id) && !killed_parameters.contains(&id)
}) })
}) });
} }
} }
} }

View File

@ -344,9 +344,9 @@ fn get_inlined_blocks(
Operand::IdRef(return_value), Operand::IdRef(return_value),
], ],
), ),
) );
} else { } else {
assert!(return_variable.is_none()) assert!(return_variable.is_none());
} }
*block.instructions.last_mut().unwrap() = *block.instructions.last_mut().unwrap() =
Instruction::new(Op::Branch, None, None, vec![Operand::IdRef(return_jump)]); Instruction::new(Op::Branch, None, None, vec![Operand::IdRef(return_jump)]);

View File

@ -219,7 +219,7 @@ fn collect_access_chains(
indices: { indices: {
let mut base_indicies = base.indices.clone(); let mut base_indicies = base.indices.clone();
for op in inst.operands.iter().skip(1) { for op in inst.operands.iter().skip(1) {
base_indicies.push(*constants.get(&op.id_ref_any().unwrap())?) base_indicies.push(*constants.get(&op.id_ref_any().unwrap())?);
} }
base_indicies base_indicies
}, },
@ -302,7 +302,7 @@ fn insert_phis(
while let Some(x) = work_list.pop() { while let Some(x) = work_list.pop() {
for &y in &dominance_frontier[x] { for &y in &dominance_frontier[x] {
if blocks_with_phi.insert(y) && ever_on_work_list.insert(y) { if blocks_with_phi.insert(y) && ever_on_work_list.insert(y) {
work_list.push(y) work_list.push(y);
} }
} }
} }
@ -515,6 +515,6 @@ fn remove_old_variables(
.all(|(var_map, _)| !var_map.contains_key(&id)) .all(|(var_map, _)| !var_map.contains_key(&id))
}) })
}) })
}) });
} }
} }

View File

@ -16,7 +16,7 @@ use crate::decorations::{CustomDecoration, UnrollLoopsDecoration};
use rspirv::binary::Consumer; use rspirv::binary::Consumer;
use rspirv::dr::{Block, Instruction, Loader, Module, ModuleHeader, Operand}; use rspirv::dr::{Block, Instruction, Loader, Module, ModuleHeader, Operand};
use rspirv::spirv::{Op, StorageClass, Word}; use rspirv::spirv::{Op, StorageClass, Word};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::ErrorReported; use rustc_errors::ErrorReported;
use rustc_session::Session; use rustc_session::Session;
@ -63,7 +63,7 @@ fn apply_rewrite_rules(rewrite_rules: &FxHashMap<Word, Word>, blocks: &mut [Bloc
*id = rewrite; *id = rewrite;
} }
} }
}) });
}; };
for block in blocks { for block in blocks {
for inst in &mut block.label { for inst in &mut block.label {
@ -183,8 +183,8 @@ pub fn link(sess: &Session, mut inputs: Vec<Module>, opts: &Options) -> Result<L
} }
let unroll_loops_decorations = UnrollLoopsDecoration::decode_all(&output) let unroll_loops_decorations = UnrollLoopsDecoration::decode_all(&output)
.map(|(id, unroll_loops)| (id, unroll_loops.deserialize())) .map(|(id, _)| id)
.collect::<FxHashMap<_, _>>(); .collect::<FxHashSet<_>>();
UnrollLoopsDecoration::remove_all(&mut output); UnrollLoopsDecoration::remove_all(&mut output);
let mut output = if opts.structurize { let mut output = if opts.structurize {

View File

@ -15,9 +15,9 @@ pub fn shift_ids(module: &mut Module, add: u32) {
inst.operands.iter_mut().for_each(|op| { inst.operands.iter_mut().for_each(|op| {
if let Some(w) = op.id_ref_any_mut() { if let Some(w) = op.id_ref_any_mut() {
*w += add *w += add;
} }
}) });
}); });
} }
@ -118,7 +118,7 @@ pub fn compact_ids(module: &mut Module) -> u32 {
if let Some(w) = op.id_ref_any_mut() { if let Some(w) = op.id_ref_any_mut() {
*w = insert(*w); *w = insert(*w);
} }
}) });
}); });
remap.len() as u32 + 1 remap.len() as u32 + 1

View File

@ -261,7 +261,7 @@ impl CallGraph {
visited[func] = true; visited[func] = true;
for &callee in &self.callees[func] { for &callee in &self.callees[func] {
self.post_order_step(callee, visited, post_order) self.post_order_step(callee, visited, post_order);
} }
post_order.push(func); post_order.push(func);

View File

@ -1,8 +1,7 @@
use crate::decorations::UnrollLoopsDecoration;
use indexmap::{indexmap, IndexMap}; use indexmap::{indexmap, IndexMap};
use rspirv::dr::{Block, Builder, Function, InsertPoint, Module, Operand}; use rspirv::dr::{Block, Builder, Function, InsertPoint, Module, Operand};
use rspirv::spirv::{LoopControl, Op, SelectionControl, Word}; use rspirv::spirv::{LoopControl, Op, SelectionControl, Word};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use std::{iter, mem}; use std::{iter, mem};
/// Cached IDs of `OpTypeBool`, `OpConstantFalse`, and `OpConstantTrue`. /// Cached IDs of `OpTypeBool`, `OpConstantFalse`, and `OpConstantTrue`.
@ -38,10 +37,7 @@ impl FuncBuilder<'_> {
} }
} }
pub fn structurize( pub fn structurize(module: Module, unroll_loops_decorations: FxHashSet<Word>) -> Module {
module: Module,
unroll_loops_decorations: FxHashMap<Word, UnrollLoopsDecoration>,
) -> Module {
let mut builder = Builder::new_from_module(module); let mut builder = Builder::new_from_module(module);
// Get the `OpTypeBool` type (it will only be created if it's missing). // Get the `OpTypeBool` type (it will only be created if it's missing).
@ -78,9 +74,10 @@ pub fn structurize(
let func_id = func.function().def_id().unwrap(); let func_id = func.function().def_id().unwrap();
let loop_control = match unroll_loops_decorations.get(&func_id) { let loop_control = if unroll_loops_decorations.contains(&func_id) {
Some(UnrollLoopsDecoration {}) => LoopControl::UNROLL, LoopControl::UNROLL
None => LoopControl::NONE, } else {
LoopControl::NONE
}; };
let block_id_to_idx = func let block_id_to_idx = func
@ -570,7 +567,7 @@ impl Structurizer<'_> {
for target in for target in
super::simple_passes::outgoing_edges(&self.func.blocks()[block]).collect::<Vec<_>>() super::simple_passes::outgoing_edges(&self.func.blocks()[block]).collect::<Vec<_>>()
{ {
self.post_order_step(self.block_id_to_idx[&target], visited, post_order) self.post_order_step(self.block_id_to_idx[&target], visited, post_order);
} }
post_order.push(block); post_order.push(block);

View File

@ -136,7 +136,7 @@ fn without_header_eq(mut result: Module, expected: &str) {
\n{}\ \n{}\
\n", \n",
pretty_assertions::Comparison::new(&PrettyString(&result), &PrettyString(&expected)) pretty_assertions::Comparison::new(&PrettyString(&result), &PrettyString(&expected))
) );
} }
} }

View File

@ -186,7 +186,7 @@ pub fn remove_zombies(sess: &Session, module: &mut Module) {
} }
_ => format!("{}", name_id), _ => format!("{}", name_id),
}; };
println!("Function removed {:?} because {:?}", name, reason.reason) println!("Function removed {:?} because {:?}", name, reason.reason);
} }
} }
} }

View File

@ -304,7 +304,7 @@ impl SpirvType {
result, result,
def_span, def_span,
"function pointer types are not allowed", "function pointer types are not allowed",
) );
} }
result result
} }

View File

@ -766,7 +766,7 @@ pub fn instruction_signatures(op: Op) -> Option<&'static [InstSig<'static>]> {
| Op::CooperativeMatrixLengthNV => reserved!(SPV_NV_cooperative_matrix), | Op::CooperativeMatrixLengthNV => reserved!(SPV_NV_cooperative_matrix),
// SPV_EXT_fragment_shader_interlock // SPV_EXT_fragment_shader_interlock
Op::BeginInvocationInterlockEXT | Op::EndInvocationInterlockEXT => { Op::BeginInvocationInterlockEXT | Op::EndInvocationInterlockEXT => {
reserved!(SPV_EXT_fragment_shader_interlock) reserved!(SPV_EXT_fragment_shader_interlock);
} }
// SPV_EXT_demote_to_helper_invocation // SPV_EXT_demote_to_helper_invocation
Op::DemoteToHelperInvocationEXT | Op::IsHelperInvocationEXT => { Op::DemoteToHelperInvocationEXT | Op::IsHelperInvocationEXT => {
@ -819,7 +819,7 @@ pub fn instruction_signatures(op: Op) -> Option<&'static [InstSig<'static>]> {
// Instructions not present in current SPIR-V specification // Instructions not present in current SPIR-V specification
// SPV_INTEL_function_pointers // SPV_INTEL_function_pointers
Op::FunctionPointerINTEL | Op::FunctionPointerCallINTEL => { Op::FunctionPointerINTEL | Op::FunctionPointerCallINTEL => {
reserved!(SPV_INTEL_function_pointers) reserved!(SPV_INTEL_function_pointers);
} }
// SPV_INTEL_device_side_avc_motion_estimation // SPV_INTEL_device_side_avc_motion_estimation
Op::VmeImageINTEL Op::VmeImageINTEL
@ -940,7 +940,7 @@ pub fn instruction_signatures(op: Op) -> Option<&'static [InstSig<'static>]> {
| Op::SubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL | Op::SubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL
| Op::SubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL | Op::SubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL
| Op::SubgroupAvcSicGetInterRawSadsINTEL => { | Op::SubgroupAvcSicGetInterRawSadsINTEL => {
reserved!(SPV_INTEL_device_side_avc_motion_estimation) reserved!(SPV_INTEL_device_side_avc_motion_estimation);
} }
} }

View File

@ -1,27 +1,36 @@
// BEGIN - Embark standard lints v0.3 // BEGIN - Embark standard lints v0.4
// do not change or add/remove here, but one can add exceptions after this section // do not change or add/remove here, but one can add exceptions after this section
// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59> // for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![warn( #![warn(
clippy::all, clippy::all,
clippy::await_holding_lock, clippy::await_holding_lock,
clippy::char_lit_as_u8,
clippy::checked_conversions,
clippy::dbg_macro, clippy::dbg_macro,
clippy::debug_assert_with_mut_call, clippy::debug_assert_with_mut_call,
clippy::doc_markdown, clippy::doc_markdown,
clippy::empty_enum, clippy::empty_enum,
clippy::enum_glob_use, clippy::enum_glob_use,
clippy::exit, clippy::exit,
clippy::expl_impl_clone_on_copy,
clippy::explicit_deref_methods,
clippy::explicit_into_iter_loop, clippy::explicit_into_iter_loop,
clippy::fallible_impl_from,
clippy::filter_map_next, clippy::filter_map_next,
clippy::float_cmp_const,
clippy::fn_params_excessive_bools, clippy::fn_params_excessive_bools,
clippy::if_let_mutex, clippy::if_let_mutex,
clippy::implicit_clone,
clippy::imprecise_flops, clippy::imprecise_flops,
clippy::inefficient_to_string, clippy::inefficient_to_string,
clippy::invalid_upcast_comparisons,
clippy::large_types_passed_by_value, clippy::large_types_passed_by_value,
clippy::let_unit_value, clippy::let_unit_value,
clippy::linkedlist, clippy::linkedlist,
clippy::lossy_float_literal, clippy::lossy_float_literal,
clippy::macro_use_imports, clippy::macro_use_imports,
clippy::manual_ok_or,
clippy::map_err_ignore, clippy::map_err_ignore,
clippy::map_flatten, clippy::map_flatten,
clippy::map_unwrap_or, clippy::map_unwrap_or,
@ -30,26 +39,34 @@
clippy::match_wildcard_for_single_variants, clippy::match_wildcard_for_single_variants,
clippy::mem_forget, clippy::mem_forget,
clippy::mismatched_target_os, clippy::mismatched_target_os,
clippy::mut_mut,
clippy::mutex_integer,
clippy::needless_borrow, clippy::needless_borrow,
clippy::needless_continue, clippy::needless_continue,
clippy::option_option, clippy::option_option,
clippy::pub_enum_variant_names, clippy::path_buf_push_overwrite,
clippy::ptr_as_ptr,
clippy::ref_option_ref, clippy::ref_option_ref,
clippy::rest_pat_in_fully_bound_structs, clippy::rest_pat_in_fully_bound_structs,
clippy::same_functions_in_if_condition,
clippy::semicolon_if_nothing_returned,
clippy::string_add_assign, clippy::string_add_assign,
clippy::string_add, clippy::string_add,
clippy::string_lit_as_bytes,
clippy::string_to_string, clippy::string_to_string,
clippy::suboptimal_flops,
clippy::todo, clippy::todo,
clippy::trait_duplication_in_bounds,
clippy::unimplemented, clippy::unimplemented,
clippy::unnested_or_patterns, clippy::unnested_or_patterns,
clippy::unused_self, clippy::unused_self,
clippy::useless_transmute,
clippy::verbose_file_reads, clippy::verbose_file_reads,
clippy::zero_sized_map_values,
future_incompatible, future_incompatible,
nonstandard_style, nonstandard_style,
rust_2018_idioms rust_2018_idioms
)] )]
// END - Embark standard lints v0.3 // END - Embark standard lints v0.4
// crate-specific exceptions: // crate-specific exceptions:
#![allow()] #![allow()]
@ -268,7 +285,7 @@ impl SpirvBuilder {
match self.print_metadata { match self.print_metadata {
MetadataPrintout::Full | MetadataPrintout::DependencyOnly => { MetadataPrintout::Full | MetadataPrintout::DependencyOnly => {
leaf_deps(&metadata_file, |artifact| { leaf_deps(&metadata_file, |artifact| {
println!("cargo:rerun-if-changed={}", artifact) println!("cargo:rerun-if-changed={}", artifact);
}) })
// Close enough // Close enough
.map_err(SpirvBuilderError::MetadataFileMissing)?; .map_err(SpirvBuilderError::MetadataFileMissing)?;
@ -524,7 +541,7 @@ fn leaf_deps(artifact: &Path, mut handle: impl FnMut(&RawStr)) -> std::io::Resul
match map.get(artifact) { match map.get(artifact) {
Some(entries) => { Some(entries) => {
for entry in entries { for entry in entries {
recurse(map, entry, handle) recurse(map, entry, handle);
} }
} }
None => handle(artifact), None => handle(artifact),

View File

@ -350,7 +350,7 @@ impl quote::ToTokens for ImageType {
{ #crate_root::image::#format }, { #crate_root::image::#format },
{ #access_qualifier }, { #access_qualifier },
> >
}) });
} }
} }

View File

@ -1,27 +1,36 @@
// BEGIN - Embark standard lints v0.3 // BEGIN - Embark standard lints v0.4
// do not change or add/remove here, but one can add exceptions after this section // do not change or add/remove here, but one can add exceptions after this section
// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59> // for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![warn( #![warn(
clippy::all, clippy::all,
clippy::await_holding_lock, clippy::await_holding_lock,
clippy::char_lit_as_u8,
clippy::checked_conversions,
clippy::dbg_macro, clippy::dbg_macro,
clippy::debug_assert_with_mut_call, clippy::debug_assert_with_mut_call,
clippy::doc_markdown, clippy::doc_markdown,
clippy::empty_enum, clippy::empty_enum,
clippy::enum_glob_use, clippy::enum_glob_use,
clippy::exit, clippy::exit,
clippy::expl_impl_clone_on_copy,
clippy::explicit_deref_methods,
clippy::explicit_into_iter_loop, clippy::explicit_into_iter_loop,
clippy::fallible_impl_from,
clippy::filter_map_next, clippy::filter_map_next,
clippy::float_cmp_const,
clippy::fn_params_excessive_bools, clippy::fn_params_excessive_bools,
clippy::if_let_mutex, clippy::if_let_mutex,
clippy::implicit_clone,
clippy::imprecise_flops, clippy::imprecise_flops,
clippy::inefficient_to_string, clippy::inefficient_to_string,
clippy::invalid_upcast_comparisons,
clippy::large_types_passed_by_value, clippy::large_types_passed_by_value,
clippy::let_unit_value, clippy::let_unit_value,
clippy::linkedlist, clippy::linkedlist,
clippy::lossy_float_literal, clippy::lossy_float_literal,
clippy::macro_use_imports, clippy::macro_use_imports,
clippy::manual_ok_or,
clippy::map_err_ignore, clippy::map_err_ignore,
clippy::map_flatten, clippy::map_flatten,
clippy::map_unwrap_or, clippy::map_unwrap_or,
@ -30,26 +39,34 @@
clippy::match_wildcard_for_single_variants, clippy::match_wildcard_for_single_variants,
clippy::mem_forget, clippy::mem_forget,
clippy::mismatched_target_os, clippy::mismatched_target_os,
clippy::mut_mut,
clippy::mutex_integer,
clippy::needless_borrow, clippy::needless_borrow,
clippy::needless_continue, clippy::needless_continue,
clippy::option_option, clippy::option_option,
clippy::pub_enum_variant_names, clippy::path_buf_push_overwrite,
clippy::ptr_as_ptr,
clippy::ref_option_ref, clippy::ref_option_ref,
clippy::rest_pat_in_fully_bound_structs, clippy::rest_pat_in_fully_bound_structs,
clippy::same_functions_in_if_condition,
clippy::semicolon_if_nothing_returned,
clippy::string_add_assign, clippy::string_add_assign,
clippy::string_add, clippy::string_add,
clippy::string_lit_as_bytes,
clippy::string_to_string, clippy::string_to_string,
clippy::suboptimal_flops,
clippy::todo, clippy::todo,
clippy::trait_duplication_in_bounds,
clippy::unimplemented, clippy::unimplemented,
clippy::unnested_or_patterns, clippy::unnested_or_patterns,
clippy::unused_self, clippy::unused_self,
clippy::useless_transmute,
clippy::verbose_file_reads, clippy::verbose_file_reads,
clippy::zero_sized_map_values,
future_incompatible, future_incompatible,
nonstandard_style, nonstandard_style,
rust_2018_idioms rust_2018_idioms
)] )]
// END - Embark standard lints v0.3 // END - Embark standard lints v0.4
// crate-specific exceptions: // crate-specific exceptions:
// `or_patterns` is not stable yet. // `or_patterns` is not stable yet.
#![allow(clippy::unnested_or_patterns)] #![allow(clippy::unnested_or_patterns)]

View File

@ -12,30 +12,39 @@
register_attr(spirv) register_attr(spirv)
)] )]
#![feature(const_generics)] #![feature(const_generics)]
// BEGIN - Embark standard lints v0.3 // BEGIN - Embark standard lints v0.4
// do not change or add/remove here, but one can add exceptions after this section // do not change or add/remove here, but one can add exceptions after this section
// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59> // for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![warn( #![warn(
clippy::all, clippy::all,
clippy::await_holding_lock, clippy::await_holding_lock,
clippy::char_lit_as_u8,
clippy::checked_conversions,
clippy::dbg_macro, clippy::dbg_macro,
clippy::debug_assert_with_mut_call, clippy::debug_assert_with_mut_call,
clippy::doc_markdown, clippy::doc_markdown,
clippy::empty_enum, clippy::empty_enum,
clippy::enum_glob_use, clippy::enum_glob_use,
clippy::exit, clippy::exit,
clippy::expl_impl_clone_on_copy,
clippy::explicit_deref_methods,
clippy::explicit_into_iter_loop, clippy::explicit_into_iter_loop,
clippy::fallible_impl_from,
clippy::filter_map_next, clippy::filter_map_next,
clippy::float_cmp_const,
clippy::fn_params_excessive_bools, clippy::fn_params_excessive_bools,
clippy::if_let_mutex, clippy::if_let_mutex,
clippy::implicit_clone,
clippy::imprecise_flops, clippy::imprecise_flops,
clippy::inefficient_to_string, clippy::inefficient_to_string,
clippy::invalid_upcast_comparisons,
clippy::large_types_passed_by_value, clippy::large_types_passed_by_value,
clippy::let_unit_value, clippy::let_unit_value,
clippy::linkedlist, clippy::linkedlist,
clippy::lossy_float_literal, clippy::lossy_float_literal,
clippy::macro_use_imports, clippy::macro_use_imports,
clippy::manual_ok_or,
clippy::map_err_ignore, clippy::map_err_ignore,
clippy::map_flatten, clippy::map_flatten,
clippy::map_unwrap_or, clippy::map_unwrap_or,
@ -44,26 +53,34 @@
clippy::match_wildcard_for_single_variants, clippy::match_wildcard_for_single_variants,
clippy::mem_forget, clippy::mem_forget,
clippy::mismatched_target_os, clippy::mismatched_target_os,
clippy::mut_mut,
clippy::mutex_integer,
clippy::needless_borrow, clippy::needless_borrow,
clippy::needless_continue, clippy::needless_continue,
clippy::option_option, clippy::option_option,
clippy::pub_enum_variant_names, clippy::path_buf_push_overwrite,
clippy::ptr_as_ptr,
clippy::ref_option_ref, clippy::ref_option_ref,
clippy::rest_pat_in_fully_bound_structs, clippy::rest_pat_in_fully_bound_structs,
clippy::same_functions_in_if_condition,
clippy::semicolon_if_nothing_returned,
clippy::string_add_assign, clippy::string_add_assign,
clippy::string_add, clippy::string_add,
clippy::string_lit_as_bytes,
clippy::string_to_string, clippy::string_to_string,
clippy::suboptimal_flops,
clippy::todo, clippy::todo,
clippy::trait_duplication_in_bounds,
clippy::unimplemented, clippy::unimplemented,
clippy::unnested_or_patterns, clippy::unnested_or_patterns,
clippy::unused_self, clippy::unused_self,
clippy::useless_transmute,
clippy::verbose_file_reads, clippy::verbose_file_reads,
clippy::zero_sized_map_values,
future_incompatible, future_incompatible,
nonstandard_style, nonstandard_style,
rust_2018_idioms rust_2018_idioms
)] )]
// END - Embark standard lints v0.3 // END - Embark standard lints v0.4
// crate-specific exceptions: // crate-specific exceptions:
#![allow( #![allow(
// Needed for `asm!`. // Needed for `asm!`.

View File

@ -1,46 +1,74 @@
// standard Embark lints // BEGIN - Embark standard lints v0.4
// do not change or add/remove here, but one can add exceptions after this section
// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
//#![deny(unsafe_code)] // impractical in this crate dealing with unsafe `ash` //#![deny(unsafe_code)] // impractical in this crate dealing with unsafe `ash`
#![warn( #![warn(
clippy::all, clippy::all,
clippy::await_holding_lock, clippy::await_holding_lock,
clippy::char_lit_as_u8,
clippy::checked_conversions,
clippy::dbg_macro, clippy::dbg_macro,
clippy::debug_assert_with_mut_call, clippy::debug_assert_with_mut_call,
clippy::doc_markdown, clippy::doc_markdown,
clippy::empty_enum, clippy::empty_enum,
clippy::enum_glob_use, clippy::enum_glob_use,
clippy::exit, clippy::exit,
clippy::expl_impl_clone_on_copy,
clippy::explicit_deref_methods,
clippy::explicit_into_iter_loop, clippy::explicit_into_iter_loop,
clippy::fallible_impl_from,
clippy::filter_map_next, clippy::filter_map_next,
clippy::float_cmp_const,
clippy::fn_params_excessive_bools, clippy::fn_params_excessive_bools,
clippy::if_let_mutex, clippy::if_let_mutex,
clippy::implicit_clone,
clippy::imprecise_flops, clippy::imprecise_flops,
clippy::inefficient_to_string, clippy::inefficient_to_string,
clippy::invalid_upcast_comparisons,
clippy::large_types_passed_by_value,
clippy::let_unit_value, clippy::let_unit_value,
clippy::linkedlist, clippy::linkedlist,
clippy::lossy_float_literal, clippy::lossy_float_literal,
clippy::macro_use_imports, clippy::macro_use_imports,
clippy::manual_ok_or,
clippy::map_err_ignore,
clippy::map_flatten, clippy::map_flatten,
clippy::map_unwrap_or, clippy::map_unwrap_or,
clippy::match_on_vec_items, clippy::match_on_vec_items,
clippy::match_same_arms,
clippy::match_wildcard_for_single_variants, clippy::match_wildcard_for_single_variants,
clippy::mem_forget, clippy::mem_forget,
clippy::mismatched_target_os, clippy::mismatched_target_os,
clippy::mut_mut,
clippy::mutex_integer,
clippy::needless_borrow, clippy::needless_borrow,
clippy::needless_continue, clippy::needless_continue,
clippy::option_option, clippy::option_option,
clippy::pub_enum_variant_names, clippy::path_buf_push_overwrite,
clippy::ptr_as_ptr,
clippy::ref_option_ref, clippy::ref_option_ref,
clippy::rest_pat_in_fully_bound_structs, clippy::rest_pat_in_fully_bound_structs,
clippy::same_functions_in_if_condition,
clippy::semicolon_if_nothing_returned,
clippy::string_add_assign,
clippy::string_add,
clippy::string_lit_as_bytes,
clippy::string_to_string, clippy::string_to_string,
clippy::suboptimal_flops,
clippy::todo, clippy::todo,
clippy::trait_duplication_in_bounds,
clippy::unimplemented,
clippy::unnested_or_patterns, clippy::unnested_or_patterns,
clippy::unused_self, clippy::unused_self,
clippy::useless_transmute,
clippy::verbose_file_reads, clippy::verbose_file_reads,
clippy::zero_sized_map_values,
future_incompatible, future_incompatible,
nonstandard_style, nonstandard_style,
rust_2018_idioms rust_2018_idioms
)] )]
// END - Embark standard lints v0.4
// crate-specific exceptions:
#![allow()]
use ash::{ use ash::{
extensions::{ext, khr}, extensions::{ext, khr},
@ -127,7 +155,7 @@ pub fn main() {
ctx.render(); ctx.render();
} }
} else { } else {
ctx.render() ctx.render();
} }
} }
Ok(new_shaders) => { Ok(new_shaders) => {
@ -138,7 +166,7 @@ pub fn main() {
ctx.rebuild_pipelines(vk::PipelineCache::null()); ctx.rebuild_pipelines(vk::PipelineCache::null());
} }
Err(TryRecvError::Disconnected) => { Err(TryRecvError::Disconnected) => {
panic!("compiler reciever disconnected unexpectedly") panic!("compiler reciever disconnected unexpectedly");
} }
}; };
} }
@ -186,7 +214,7 @@ pub fn compile_shaders() -> Vec<SpvFile> {
spv_files.push(SpvFile { spv_files.push(SpvFile {
name: path.file_stem().unwrap().to_str().unwrap().to_owned(), name: path.file_stem().unwrap().to_str().unwrap().to_owned(),
data: read_spv(&mut File::open(path).unwrap()).unwrap(), data: read_spv(&mut File::open(path).unwrap()).unwrap(),
}) });
} }
spv_files spv_files
} }
@ -770,7 +798,9 @@ impl RenderCtx {
.expect("Shader module error") .expect("Shader module error")
}; };
if let Some(old_module) = self.shader_modules.insert(name, shader_module) { if let Some(old_module) = self.shader_modules.insert(name, shader_module) {
unsafe { self.base.device.destroy_shader_module(old_module, None) } unsafe {
self.base.device.destroy_shader_module(old_module, None);
}
}; };
} }
@ -780,7 +810,7 @@ impl RenderCtx {
self.base.device.device_wait_idle().unwrap(); self.base.device.device_wait_idle().unwrap();
// framebuffers // framebuffers
for framebuffer in self.framebuffers.drain(..) { for framebuffer in self.framebuffers.drain(..) {
self.base.device.destroy_framebuffer(framebuffer, None) self.base.device.destroy_framebuffer(framebuffer, None);
} }
// image views // image views
for image_view in self.image_views.drain(..) { for image_view in self.image_views.drain(..) {
@ -801,7 +831,7 @@ impl RenderCtx {
self.rendering_paused = true; self.rendering_paused = true;
return; return;
} else if self.rendering_paused { } else if self.rendering_paused {
self.rendering_paused = false self.rendering_paused = false;
}; };
self.cleanup_swapchain(); self.cleanup_swapchain();
@ -1026,7 +1056,7 @@ impl Drop for RenderCtx {
.device .device
.destroy_command_pool(self.commands.pool, None); .destroy_command_pool(self.commands.pool, None);
for (_, shader_module) in self.shader_modules.drain() { for (_, shader_module) in self.shader_modules.drain() {
self.base.device.destroy_shader_module(shader_module, None) self.base.device.destroy_shader_module(shader_module, None);
} }
} }
} }
@ -1210,7 +1240,7 @@ pub struct FragmentShaderEntryPoint {
} }
unsafe fn any_as_u8_slice<T: Sized>(p: &T) -> &[u8] { unsafe fn any_as_u8_slice<T: Sized>(p: &T) -> &[u8] {
::std::slice::from_raw_parts((p as *const T) as *const u8, ::std::mem::size_of::<T>()) ::std::slice::from_raw_parts((p as *const T).cast::<u8>(), ::std::mem::size_of::<T>())
} }
unsafe extern "system" fn vulkan_debug_callback( unsafe extern "system" fn vulkan_debug_callback(

View File

@ -1,46 +1,74 @@
// standard Embark lints // BEGIN - Embark standard lints v0.4
// do not change or add/remove here, but one can add exceptions after this section
// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![warn( #![warn(
clippy::all, clippy::all,
clippy::await_holding_lock, clippy::await_holding_lock,
clippy::char_lit_as_u8,
clippy::checked_conversions,
clippy::dbg_macro, clippy::dbg_macro,
clippy::debug_assert_with_mut_call, clippy::debug_assert_with_mut_call,
clippy::doc_markdown, clippy::doc_markdown,
clippy::empty_enum, clippy::empty_enum,
clippy::enum_glob_use, clippy::enum_glob_use,
clippy::exit, clippy::exit,
clippy::expl_impl_clone_on_copy,
clippy::explicit_deref_methods,
clippy::explicit_into_iter_loop, clippy::explicit_into_iter_loop,
clippy::fallible_impl_from,
clippy::filter_map_next, clippy::filter_map_next,
clippy::float_cmp_const,
clippy::fn_params_excessive_bools, clippy::fn_params_excessive_bools,
clippy::if_let_mutex, clippy::if_let_mutex,
clippy::implicit_clone,
clippy::imprecise_flops, clippy::imprecise_flops,
clippy::inefficient_to_string, clippy::inefficient_to_string,
clippy::invalid_upcast_comparisons,
clippy::large_types_passed_by_value,
clippy::let_unit_value, clippy::let_unit_value,
clippy::linkedlist, clippy::linkedlist,
clippy::lossy_float_literal, clippy::lossy_float_literal,
clippy::macro_use_imports, clippy::macro_use_imports,
clippy::manual_ok_or,
clippy::map_err_ignore,
clippy::map_flatten, clippy::map_flatten,
clippy::map_unwrap_or, clippy::map_unwrap_or,
clippy::match_on_vec_items, clippy::match_on_vec_items,
clippy::match_same_arms,
clippy::match_wildcard_for_single_variants, clippy::match_wildcard_for_single_variants,
clippy::mem_forget, clippy::mem_forget,
clippy::mismatched_target_os, clippy::mismatched_target_os,
clippy::mut_mut,
clippy::mutex_integer,
clippy::needless_borrow, clippy::needless_borrow,
clippy::needless_continue, clippy::needless_continue,
clippy::option_option, clippy::option_option,
clippy::pub_enum_variant_names, clippy::path_buf_push_overwrite,
clippy::ptr_as_ptr,
clippy::ref_option_ref, clippy::ref_option_ref,
clippy::rest_pat_in_fully_bound_structs, clippy::rest_pat_in_fully_bound_structs,
clippy::same_functions_in_if_condition,
clippy::semicolon_if_nothing_returned,
clippy::string_add_assign,
clippy::string_add,
clippy::string_lit_as_bytes,
clippy::string_to_string, clippy::string_to_string,
clippy::suboptimal_flops,
clippy::todo, clippy::todo,
clippy::trait_duplication_in_bounds,
clippy::unimplemented,
clippy::unnested_or_patterns, clippy::unnested_or_patterns,
clippy::unused_self, clippy::unused_self,
clippy::useless_transmute,
clippy::verbose_file_reads, clippy::verbose_file_reads,
clippy::zero_sized_map_values,
future_incompatible, future_incompatible,
nonstandard_style, nonstandard_style,
rust_2018_idioms rust_2018_idioms
)] )]
// END - Embark standard lints v0.4
// crate-specific exceptions:
#![allow()]
use minifb::{Key, Window, WindowOptions}; use minifb::{Key, Window, WindowOptions};
use rayon::prelude::*; use rayon::prelude::*;

View File

@ -17,7 +17,7 @@ fn block_on<T>(future: impl Future<Output = T>) -> T {
pub fn start(options: &Options) { pub fn start(options: &Options) {
let shader_binary = crate::maybe_watch(options.shader, None); let shader_binary = crate::maybe_watch(options.shader, None);
block_on(start_internal(options, shader_binary)) block_on(start_internal(options, shader_binary));
} }
pub async fn start_internal( pub async fn start_internal(

View File

@ -205,13 +205,10 @@ async fn run(
queue.submit(Some(encoder.finish())); queue.submit(Some(encoder.finish()));
} }
} }
Event::WindowEvent {
event: WindowEvent::CloseRequested,
..
} => *control_flow = ControlFlow::Exit,
Event::WindowEvent { Event::WindowEvent {
event: event:
WindowEvent::KeyboardInput { WindowEvent::CloseRequested
| WindowEvent::KeyboardInput {
input: input:
KeyboardInput { KeyboardInput {
virtual_keycode: Some(VirtualKeyCode::Escape), virtual_keycode: Some(VirtualKeyCode::Escape),

View File

@ -1,46 +1,74 @@
// standard Embark lints // BEGIN - Embark standard lints v0.4
// do not change or add/remove here, but one can add exceptions after this section
// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
//#![deny(unsafe_code)] // quite a bit of unsafe with wgpu still, would be nice to remove //#![deny(unsafe_code)] // quite a bit of unsafe with wgpu still, would be nice to remove
#![warn( #![warn(
clippy::all, clippy::all,
clippy::await_holding_lock, clippy::await_holding_lock,
clippy::char_lit_as_u8,
clippy::checked_conversions,
clippy::dbg_macro, clippy::dbg_macro,
clippy::debug_assert_with_mut_call, clippy::debug_assert_with_mut_call,
clippy::doc_markdown, clippy::doc_markdown,
clippy::empty_enum, clippy::empty_enum,
clippy::enum_glob_use, clippy::enum_glob_use,
clippy::exit, clippy::exit,
clippy::expl_impl_clone_on_copy,
clippy::explicit_deref_methods,
clippy::explicit_into_iter_loop, clippy::explicit_into_iter_loop,
clippy::fallible_impl_from,
clippy::filter_map_next, clippy::filter_map_next,
clippy::float_cmp_const,
clippy::fn_params_excessive_bools, clippy::fn_params_excessive_bools,
clippy::if_let_mutex, clippy::if_let_mutex,
clippy::implicit_clone,
clippy::imprecise_flops, clippy::imprecise_flops,
clippy::inefficient_to_string, clippy::inefficient_to_string,
clippy::invalid_upcast_comparisons,
clippy::large_types_passed_by_value,
clippy::let_unit_value, clippy::let_unit_value,
clippy::linkedlist, clippy::linkedlist,
clippy::lossy_float_literal, clippy::lossy_float_literal,
clippy::macro_use_imports, clippy::macro_use_imports,
clippy::manual_ok_or,
clippy::map_err_ignore,
clippy::map_flatten, clippy::map_flatten,
clippy::map_unwrap_or, clippy::map_unwrap_or,
clippy::match_on_vec_items, clippy::match_on_vec_items,
clippy::match_same_arms,
clippy::match_wildcard_for_single_variants, clippy::match_wildcard_for_single_variants,
clippy::mem_forget, clippy::mem_forget,
clippy::mismatched_target_os, clippy::mismatched_target_os,
clippy::mut_mut,
clippy::mutex_integer,
clippy::needless_borrow, clippy::needless_borrow,
clippy::needless_continue, clippy::needless_continue,
clippy::option_option, clippy::option_option,
clippy::pub_enum_variant_names, clippy::path_buf_push_overwrite,
clippy::ptr_as_ptr,
clippy::ref_option_ref, clippy::ref_option_ref,
clippy::rest_pat_in_fully_bound_structs, clippy::rest_pat_in_fully_bound_structs,
clippy::same_functions_in_if_condition,
clippy::semicolon_if_nothing_returned,
clippy::string_add_assign,
clippy::string_add,
clippy::string_lit_as_bytes,
clippy::string_to_string, clippy::string_to_string,
clippy::suboptimal_flops,
clippy::todo, clippy::todo,
clippy::trait_duplication_in_bounds,
clippy::unimplemented,
clippy::unnested_or_patterns, clippy::unnested_or_patterns,
clippy::unused_self, clippy::unused_self,
clippy::useless_transmute,
clippy::verbose_file_reads, clippy::verbose_file_reads,
clippy::zero_sized_map_values,
future_incompatible, future_incompatible,
nonstandard_style, nonstandard_style,
rust_2018_idioms rust_2018_idioms
)] )]
// END - Embark standard lints v0.4
// crate-specific exceptions:
#![allow()]
use clap::Clap; use clap::Clap;
use strum::{Display, EnumString}; use strum::{Display, EnumString};
@ -144,7 +172,7 @@ pub fn main() {
let options: Options = Options::parse(); let options: Options = Options::parse();
if is_compute_shader(options.shader) { if is_compute_shader(options.shader) {
compute::start(&options) compute::start(&options);
} else { } else {
graphics::start(&options); graphics::start(&options);
} }

View File

@ -5,5 +5,5 @@
# to the user in the error, instead of "error: invalid channel name '[toolchain]'". # to the user in the error, instead of "error: invalid channel name '[toolchain]'".
[toolchain] [toolchain]
channel = "nightly-2021-05-24" channel = "nightly-2021-06-09"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"] components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

View File

@ -179,7 +179,7 @@ fn build_deps(deps_target_dir: &Path, codegen_backend_path: &Path, target: &str)
]) ])
.arg("--target-dir") .arg("--target-dir")
.arg(deps_target_dir) .arg(deps_target_dir)
.env("RUSTFLAGS", rust_flags(&codegen_backend_path)) .env("RUSTFLAGS", rust_flags(codegen_backend_path))
.current_dir(old_cargo_resolver_workaround_cwd) .current_dir(old_cargo_resolver_workaround_cwd)
.stderr(std::process::Stdio::inherit()) .stderr(std::process::Stdio::inherit())
.stdout(std::process::Stdio::inherit()) .stdout(std::process::Stdio::inherit())