Skip to content

Commit 132b960

Browse files
authored
Upgrade from our standard lints v4 -> v6 (#861)
1 parent 7a2bb36 commit 132b960

File tree

13 files changed

+173
-166
lines changed

13 files changed

+173
-166
lines changed

.cargo/config

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,85 @@
11
[alias]
22
compiletest = "run --release -p compiletests --"
3+
4+
[target.'cfg(all())']
5+
rustflags = [
6+
# BEGIN - Embark standard lints v6 for Rust 1.55+
7+
# do not change or add/remove here, but one can add exceptions after this section
8+
# for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
9+
"-Dunsafe_code",
10+
"-Wclippy::all",
11+
"-Wclippy::await_holding_lock",
12+
"-Wclippy::char_lit_as_u8",
13+
"-Wclippy::checked_conversions",
14+
"-Wclippy::dbg_macro",
15+
"-Wclippy::debug_assert_with_mut_call",
16+
"-Wclippy::doc_markdown",
17+
"-Wclippy::empty_enum",
18+
"-Wclippy::enum_glob_use",
19+
"-Wclippy::exit",
20+
"-Wclippy::expl_impl_clone_on_copy",
21+
"-Wclippy::explicit_deref_methods",
22+
"-Wclippy::explicit_into_iter_loop",
23+
"-Wclippy::fallible_impl_from",
24+
"-Wclippy::filter_map_next",
25+
"-Wclippy::flat_map_option",
26+
"-Wclippy::float_cmp_const",
27+
"-Wclippy::fn_params_excessive_bools",
28+
"-Wclippy::from_iter_instead_of_collect",
29+
"-Wclippy::if_let_mutex",
30+
"-Wclippy::implicit_clone",
31+
"-Wclippy::imprecise_flops",
32+
"-Wclippy::inefficient_to_string",
33+
"-Wclippy::invalid_upcast_comparisons",
34+
"-Wclippy::large_digit_groups",
35+
"-Wclippy::large_stack_arrays",
36+
"-Wclippy::large_types_passed_by_value",
37+
"-Wclippy::let_unit_value",
38+
"-Wclippy::linkedlist",
39+
"-Wclippy::lossy_float_literal",
40+
"-Wclippy::macro_use_imports",
41+
"-Wclippy::manual_ok_or",
42+
"-Wclippy::map_err_ignore",
43+
"-Wclippy::map_flatten",
44+
"-Wclippy::map_unwrap_or",
45+
"-Wclippy::match_on_vec_items",
46+
"-Wclippy::match_same_arms",
47+
"-Wclippy::match_wild_err_arm",
48+
"-Wclippy::match_wildcard_for_single_variants",
49+
"-Wclippy::mem_forget",
50+
"-Wclippy::mismatched_target_os",
51+
"-Wclippy::missing_enforced_import_renames",
52+
"-Wclippy::mut_mut",
53+
"-Wclippy::mutex_integer",
54+
"-Wclippy::needless_borrow",
55+
"-Wclippy::needless_continue",
56+
"-Wclippy::needless_for_each",
57+
"-Wclippy::option_option",
58+
"-Wclippy::path_buf_push_overwrite",
59+
"-Wclippy::ptr_as_ptr",
60+
"-Wclippy::rc_mutex",
61+
"-Wclippy::ref_option_ref",
62+
"-Wclippy::rest_pat_in_fully_bound_structs",
63+
"-Wclippy::same_functions_in_if_condition",
64+
"-Wclippy::semicolon_if_nothing_returned",
65+
"-Wclippy::single_match_else",
66+
"-Wclippy::string_add_assign",
67+
"-Wclippy::string_add",
68+
"-Wclippy::string_lit_as_bytes",
69+
"-Wclippy::string_to_string",
70+
"-Wclippy::todo",
71+
"-Wclippy::trait_duplication_in_bounds",
72+
"-Wclippy::unimplemented",
73+
"-Wclippy::unnested_or_patterns",
74+
"-Wclippy::unused_self",
75+
"-Wclippy::useless_transmute",
76+
"-Wclippy::verbose_file_reads",
77+
"-Wclippy::zero_sized_map_values",
78+
"-Wfuture_incompatible",
79+
"-Wnonstandard_style",
80+
"-Wrust_2018_idioms",
81+
# END - Embark standard lints v6 for Rust 1.55+
82+
83+
# repo specific lints
84+
"-Aunsafe_code",
85+
]

crates/rustc_codegen_spirv-types/src/compile_result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'a> Trie<'a> {
7272
children.sort_unstable_by(|(k1, _), (k2, _)| k1.cmp(k2));
7373
for (child_name, child) in children {
7474
let full_child_name = if full_name.is_empty() {
75-
child_name.to_string()
75+
(*child_name).to_string()
7676
} else {
7777
format!("{}::{}", full_name, child_name)
7878
};

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,18 +2134,15 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
21342134
return_type,
21352135
arguments,
21362136
} => (
2137-
match callee.kind {
2138-
SpirvValueKind::FnAddr { function } => {
2139-
assert_ty_eq!(self, callee_ty, pointee);
2140-
function
2141-
}
2142-
2143-
// Truly indirect call.
2144-
_ => {
2145-
let fn_ptr_val = callee.def(self);
2146-
self.zombie(fn_ptr_val, "indirect calls are not supported in SPIR-V");
2147-
fn_ptr_val
2148-
}
2137+
if let SpirvValueKind::FnAddr { function } = callee.kind {
2138+
assert_ty_eq!(self, callee_ty, pointee);
2139+
function
2140+
}
2141+
// Truly indirect call.
2142+
else {
2143+
let fn_ptr_val = callee.def(self);
2144+
self.zombie(fn_ptr_val, "indirect calls are not supported in SPIR-V");
2145+
fn_ptr_val
21492146
},
21502147
return_type,
21512148
arguments,

crates/rustc_codegen_spirv/src/builder/ext_inst.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ pub struct ExtInst {
1414

1515
impl ExtInst {
1616
pub fn import_glsl<'a, 'tcx>(&mut self, bx: &Builder<'a, 'tcx>) -> Word {
17-
match self.glsl {
18-
Some(id) => id,
19-
None => {
20-
let id = bx.emit_global().ext_inst_import(GLSL_STD_450);
21-
self.glsl = Some(id);
22-
id
23-
}
17+
if let Some(id) = self.glsl {
18+
id
19+
} else {
20+
let id = bx.emit_global().ext_inst_import(GLSL_STD_450);
21+
self.glsl = Some(id);
22+
id
2423
}
2524
}
2625

crates/rustc_codegen_spirv/src/builder/spirv_asm.rs

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -427,19 +427,16 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
427427
Some(result_id) => result_id,
428428
None => return,
429429
};
430-
match tokens.next() {
431-
Some(Token::Word("=")) => (),
432-
_ => {
433-
self.err("expected equals after result id specifier");
434-
return;
435-
}
430+
if let Some(Token::Word("=")) = tokens.next() {
431+
} else {
432+
self.err("expected equals after result id specifier");
433+
return;
436434
}
437-
first_token = match tokens.next() {
438-
Some(tok) => tok,
439-
None => {
440-
self.err("expected instruction after equals");
441-
return;
442-
}
435+
first_token = if let Some(tok) = tokens.next() {
436+
tok
437+
} else {
438+
self.err("expected instruction after equals");
439+
return;
443440
};
444441
Some(result_id)
445442
} else {
@@ -461,12 +458,11 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
461458
let inst_class = inst_name
462459
.strip_prefix("Op")
463460
.and_then(|n| self.instruction_table.table.get(n));
464-
let inst_class = match inst_class {
465-
Some(inst) => inst,
466-
None => {
467-
self.err(&format!("unknown spirv instruction {}", inst_name));
468-
return;
469-
}
461+
let inst_class = if let Some(inst) = inst_class {
462+
inst
463+
} else {
464+
self.err(&format!("unknown spirv instruction {}", inst_name));
465+
return;
470466
};
471467
let result_id = match out_register {
472468
Some(OutRegister::Regular(reg)) => Some(reg),
@@ -808,19 +804,20 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
808804
token: Token<'a, 'cx, 'tcx>,
809805
) -> Option<OutRegister<'a>> {
810806
match token {
811-
Token::Word(word) => match word.strip_prefix('%') {
812-
Some(id) => Some(OutRegister::Regular({
813-
let num = *id_map.entry(id).or_insert_with(|| self.emit().id());
814-
if !defined_ids.insert(num) {
815-
self.err(&format!("%{} is defined more than once", id));
816-
}
817-
num
818-
})),
819-
None => {
807+
Token::Word(word) => {
808+
if let Some(id) = word.strip_prefix('%') {
809+
Some(OutRegister::Regular({
810+
let num = *id_map.entry(id).or_insert_with(|| self.emit().id());
811+
if !defined_ids.insert(num) {
812+
self.err(&format!("%{} is defined more than once", id));
813+
}
814+
num
815+
}))
816+
} else {
820817
self.err("expected ID");
821818
None
822819
}
823-
},
820+
}
824821
Token::String(_) => {
825822
self.err("expected ID, not string");
826823
None
@@ -896,13 +893,14 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
896893
token: Token<'a, 'cx, 'tcx>,
897894
) -> Option<Word> {
898895
match token {
899-
Token::Word(word) => match word.strip_prefix('%') {
900-
Some(id) => Some(*id_map.entry(id).or_insert_with(|| self.emit().id())),
901-
None => {
896+
Token::Word(word) => {
897+
if let Some(id) = word.strip_prefix('%') {
898+
Some(*id_map.entry(id).or_insert_with(|| self.emit().id()))
899+
} else {
902900
self.err("expected ID");
903901
None
904902
}
905-
},
903+
}
906904
Token::String(_) => {
907905
self.err("expected ID, not string");
908906
None

crates/rustc_codegen_spirv/src/codegen_cx/entry.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@ impl<'tcx> CodegenCx<'tcx> {
3333
) {
3434
let span = self.tcx.def_span(instance.def_id());
3535
let hir_params = {
36-
let fn_local_def_id = match instance.def_id().as_local() {
37-
Some(id) => id,
38-
None => {
39-
self.tcx
40-
.sess
41-
.span_err(span, &format!("Cannot declare {} as an entry point", name));
42-
return;
43-
}
36+
let fn_local_def_id = if let Some(id) = instance.def_id().as_local() {
37+
id
38+
} else {
39+
self.tcx
40+
.sess
41+
.span_err(span, &format!("Cannot declare {} as an entry point", name));
42+
return;
4443
};
4544
let fn_hir_id = self.tcx.hir().local_def_id_to_hir_id(fn_local_def_id);
4645
let body = self.tcx.hir().body(self.tcx.hir().body_owned_by(fn_hir_id));

crates/rustc_codegen_spirv/src/lib.rs

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -18,75 +18,6 @@
1818
#![feature(rustc_private)]
1919
#![feature(assert_matches)]
2020
#![feature(once_cell)]
21-
// BEGIN - Embark standard lints v0.4
22-
// do not change or add/remove here, but one can add exceptions after this section
23-
// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
24-
#![deny(unsafe_code)]
25-
#![warn(
26-
clippy::all,
27-
clippy::await_holding_lock,
28-
clippy::char_lit_as_u8,
29-
clippy::checked_conversions,
30-
clippy::dbg_macro,
31-
clippy::debug_assert_with_mut_call,
32-
clippy::doc_markdown,
33-
clippy::empty_enum,
34-
clippy::enum_glob_use,
35-
clippy::exit,
36-
clippy::expl_impl_clone_on_copy,
37-
clippy::explicit_deref_methods,
38-
clippy::explicit_into_iter_loop,
39-
clippy::fallible_impl_from,
40-
clippy::filter_map_next,
41-
clippy::float_cmp_const,
42-
clippy::fn_params_excessive_bools,
43-
clippy::if_let_mutex,
44-
clippy::implicit_clone,
45-
clippy::imprecise_flops,
46-
clippy::inefficient_to_string,
47-
clippy::invalid_upcast_comparisons,
48-
clippy::large_types_passed_by_value,
49-
clippy::let_unit_value,
50-
clippy::linkedlist,
51-
clippy::lossy_float_literal,
52-
clippy::macro_use_imports,
53-
clippy::manual_ok_or,
54-
clippy::map_err_ignore,
55-
clippy::map_flatten,
56-
clippy::map_unwrap_or,
57-
clippy::match_on_vec_items,
58-
clippy::match_same_arms,
59-
clippy::match_wildcard_for_single_variants,
60-
clippy::mem_forget,
61-
clippy::mismatched_target_os,
62-
clippy::mut_mut,
63-
clippy::mutex_integer,
64-
clippy::needless_borrow,
65-
clippy::needless_continue,
66-
clippy::option_option,
67-
clippy::path_buf_push_overwrite,
68-
clippy::ptr_as_ptr,
69-
clippy::ref_option_ref,
70-
clippy::rest_pat_in_fully_bound_structs,
71-
clippy::same_functions_in_if_condition,
72-
clippy::semicolon_if_nothing_returned,
73-
clippy::string_add_assign,
74-
clippy::string_add,
75-
clippy::string_lit_as_bytes,
76-
clippy::string_to_string,
77-
clippy::todo,
78-
clippy::trait_duplication_in_bounds,
79-
clippy::unimplemented,
80-
clippy::unnested_or_patterns,
81-
clippy::unused_self,
82-
clippy::useless_transmute,
83-
clippy::verbose_file_reads,
84-
clippy::zero_sized_map_values,
85-
future_incompatible,
86-
nonstandard_style,
87-
rust_2018_idioms
88-
)]
89-
// END - Embark standard lints v0.4
9021
// crate-specific exceptions:
9122
#![allow(
9223
unsafe_code, // rustc_codegen_ssa requires unsafe functions in traits to be impl'd

crates/spirv-builder/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,10 @@ struct RustcOutput {
544544
fn get_last_artifact(out: &str) -> Option<PathBuf> {
545545
let last = out
546546
.lines()
547-
.filter_map(|line| match serde_json::from_str::<RustcOutput>(line) {
548-
Ok(line) => Some(line),
549-
Err(_) => {
547+
.filter_map(|line| {
548+
if let Ok(line) = serde_json::from_str::<RustcOutput>(line) {
549+
Some(line)
550+
} else {
550551
// Pass through invalid lines
551552
println!("{}", line);
552553
None

0 commit comments

Comments
 (0)