Skip to content

Commit 57c6ed0

Browse files
committed
Fix even more clippy warnings
1 parent bfecb18 commit 57c6ed0

File tree

53 files changed

+276
-520
lines changed

Some content is hidden

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

53 files changed

+276
-520
lines changed

compiler/rustc_arena/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl<T> TypedArena<T> {
228228
// bytes, then this chunk will be least double the previous
229229
// chunk's size.
230230
new_cap = last_chunk.storage.len().min(HUGE_PAGE / elem_size / 2);
231-
new_cap = new_cap * 2;
231+
new_cap *= 2;
232232
} else {
233233
new_cap = PAGE / elem_size;
234234
}
@@ -346,7 +346,7 @@ impl DroplessArena {
346346
// bytes, then this chunk will be least double the previous
347347
// chunk's size.
348348
new_cap = last_chunk.storage.len().min(HUGE_PAGE / 2);
349-
new_cap = new_cap * 2;
349+
new_cap *= 2;
350350
} else {
351351
new_cap = PAGE;
352352
}
@@ -562,10 +562,8 @@ impl DropArena {
562562
// Record the destructors after doing the allocation as that may panic
563563
// and would cause `object`'s destructor to run twice if it was recorded before
564564
for i in 0..len {
565-
destructors.push(DropType {
566-
drop_fn: drop_for_type::<T>,
567-
obj: start_ptr.offset(i as isize) as *mut u8,
568-
});
565+
destructors
566+
.push(DropType { drop_fn: drop_for_type::<T>, obj: start_ptr.add(i) as *mut u8 });
569567
}
570568

571569
slice::from_raw_parts_mut(start_ptr, len)

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -639,13 +639,11 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
639639
fn break_offset_if_not_bol(&mut self, n: usize, off: isize) {
640640
if !self.is_beginning_of_line() {
641641
self.break_offset(n, off)
642-
} else {
643-
if off != 0 && self.last_token().is_hardbreak_tok() {
644-
// We do something pretty sketchy here: tuck the nonzero
645-
// offset-adjustment we were going to deposit along with the
646-
// break into the previous hardbreak.
647-
self.replace_last_token(pp::Printer::hardbreak_tok_offset(off));
648-
}
642+
} else if off != 0 && self.last_token().is_hardbreak_tok() {
643+
// We do something pretty sketchy here: tuck the nonzero
644+
// offset-adjustment we were going to deposit along with the
645+
// break into the previous hardbreak.
646+
self.replace_last_token(pp::Printer::hardbreak_tok_offset(off));
649647
}
650648
}
651649

compiler/rustc_attr/src/builtin.rs

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -901,38 +901,36 @@ pub fn find_repr_attrs(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
901901
)
902902
.emit();
903903
}
904-
} else {
905-
if let Some(meta_item) = item.meta_item() {
906-
if meta_item.has_name(sym::align) {
907-
if let MetaItemKind::NameValue(ref value) = meta_item.kind {
908-
recognised = true;
909-
let mut err = struct_span_err!(
910-
diagnostic,
911-
item.span(),
912-
E0693,
913-
"incorrect `repr(align)` attribute format"
914-
);
915-
match value.kind {
916-
ast::LitKind::Int(int, ast::LitIntType::Unsuffixed) => {
917-
err.span_suggestion(
918-
item.span(),
919-
"use parentheses instead",
920-
format!("align({})", int),
921-
Applicability::MachineApplicable,
922-
);
923-
}
924-
ast::LitKind::Str(s, _) => {
925-
err.span_suggestion(
926-
item.span(),
927-
"use parentheses instead",
928-
format!("align({})", s),
929-
Applicability::MachineApplicable,
930-
);
931-
}
932-
_ => {}
904+
} else if let Some(meta_item) = item.meta_item() {
905+
if meta_item.has_name(sym::align) {
906+
if let MetaItemKind::NameValue(ref value) = meta_item.kind {
907+
recognised = true;
908+
let mut err = struct_span_err!(
909+
diagnostic,
910+
item.span(),
911+
E0693,
912+
"incorrect `repr(align)` attribute format"
913+
);
914+
match value.kind {
915+
ast::LitKind::Int(int, ast::LitIntType::Unsuffixed) => {
916+
err.span_suggestion(
917+
item.span(),
918+
"use parentheses instead",
919+
format!("align({})", int),
920+
Applicability::MachineApplicable,
921+
);
922+
}
923+
ast::LitKind::Str(s, _) => {
924+
err.span_suggestion(
925+
item.span(),
926+
"use parentheses instead",
927+
format!("align({})", s),
928+
Applicability::MachineApplicable,
929+
);
933930
}
934-
err.emit();
931+
_ => {}
935932
}
933+
err.emit();
936934
}
937935
}
938936
}

compiler/rustc_codegen_llvm/src/allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub(crate) unsafe fn codegen(
9393
let args = [usize, usize]; // size, align
9494

9595
let ty = llvm::LLVMFunctionType(void, args.as_ptr(), args.len() as c_uint, False);
96-
let name = format!("__rust_alloc_error_handler");
96+
let name = "__rust_alloc_error_handler".to_string();
9797
let llfn = llvm::LLVMRustGetOrInsertFunction(llmod, name.as_ptr().cast(), name.len(), ty);
9898
// -> ! DIFlagNoReturn
9999
llvm::Attribute::NoReturn.apply_llfn(llvm::AttributePlace::Function, llfn);

compiler/rustc_codegen_llvm/src/asm.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,11 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
302302
} else if options.contains(InlineAsmOptions::READONLY) {
303303
llvm::Attribute::ReadOnly.apply_callsite(llvm::AttributePlace::Function, result);
304304
}
305+
} else if options.contains(InlineAsmOptions::NOMEM) {
306+
llvm::Attribute::InaccessibleMemOnly
307+
.apply_callsite(llvm::AttributePlace::Function, result);
305308
} else {
306-
if options.contains(InlineAsmOptions::NOMEM) {
307-
llvm::Attribute::InaccessibleMemOnly
308-
.apply_callsite(llvm::AttributePlace::Function, result);
309-
} else {
310-
// LLVM doesn't have an attribute to represent ReadOnly + SideEffect
311-
}
309+
// LLVM doesn't have an attribute to represent ReadOnly + SideEffect
312310
}
313311

314312
// Write results to outputs

compiler/rustc_codegen_llvm/src/back/lto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ impl ThinLTOKeysMap {
900900
let file = File::open(path)?;
901901
for line in io::BufReader::new(file).lines() {
902902
let line = line?;
903-
let mut split = line.split(" ");
903+
let mut split = line.split(' ');
904904
let module = split.next().unwrap();
905905
let key = split.next().unwrap();
906906
assert_eq!(split.next(), None, "Expected two space-separated values, found {:?}", line);

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
732732
let src_ty = self.cx.val_ty(val);
733733
let float_width = self.cx.float_width(src_ty);
734734
let int_width = self.cx.int_width(dest_ty);
735-
match (int_width, float_width) {
736-
(32, 32) | (32, 64) | (64, 32) | (64, 64) => true,
737-
_ => false,
738-
}
735+
matches!((int_width, float_width), (32, 32) | (32, 64) | (64, 32) | (64, 64))
739736
}
740737

741738
fn fptoui(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value {

compiler/rustc_codegen_llvm/src/consts.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,8 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
397397

398398
// As an optimization, all shared statics which do not have interior
399399
// mutability are placed into read-only memory.
400-
if !is_mutable {
401-
if self.type_is_freeze(ty) {
402-
llvm::LLVMSetGlobalConstant(g, llvm::True);
403-
}
400+
if !is_mutable && self.type_is_freeze(ty) {
401+
llvm::LLVMSetGlobalConstant(g, llvm::True);
404402
}
405403

406404
debuginfo::create_global_var_metadata(&self, def_id, g);

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ pub unsafe fn create_module(
122122
if llvm_util::get_major_version() < 9 {
123123
target_data_layout = strip_function_ptr_alignment(target_data_layout);
124124
}
125-
if llvm_util::get_major_version() < 10 {
126-
if sess.target.arch == "x86" || sess.target.arch == "x86_64" {
127-
target_data_layout = strip_x86_address_spaces(target_data_layout);
128-
}
125+
if llvm_util::get_major_version() < 10
126+
&& (sess.target.arch == "x86" || sess.target.arch == "x86_64")
127+
{
128+
target_data_layout = strip_x86_address_spaces(target_data_layout);
129129
}
130130

131131
// Ensure the data-layout values hardcoded remain the defaults.
@@ -864,7 +864,7 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
864864
// user defined names
865865
let mut name = String::with_capacity(prefix.len() + 6);
866866
name.push_str(prefix);
867-
name.push_str(".");
867+
name.push('.');
868868
base_n::push_str(idx as u128, base_n::ALPHANUMERIC_ONLY, &mut name);
869869
name
870870
}

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
435435
name_to_append_suffix_to.push('<');
436436
for (i, actual_type) in substs.types().enumerate() {
437437
if i != 0 {
438-
name_to_append_suffix_to.push_str(",");
438+
name_to_append_suffix_to.push(',');
439439
}
440440

441441
let actual_type =

0 commit comments

Comments
 (0)