Skip to content

Commit 3f9bddc

Browse files
committed
Auto merge of #69570 - Dylan-DPC:rollup-d6boczt, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #69477 (docs: add mention of async blocks in move keyword docs) - #69504 (Use assert_ne in hash tests) - #69546 (use to_vec() instead of .iter().cloned().collect() to convert slices to vecs.) - #69551 (use is_empty() instead of len() == x to determine if structs are empty.) - #69563 (Fix no_std detection for target triples) - #69567 (use .to_string() instead of format!() macro to create strings) Failed merges: r? @ghost
2 parents 04e7f96 + bbfec7c commit 3f9bddc

File tree

70 files changed

+152
-141
lines changed

Some content is hidden

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

70 files changed

+152
-141
lines changed

src/bootstrap/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub struct Target {
180180
impl Target {
181181
pub fn from_triple(triple: &str) -> Self {
182182
let mut target: Self = Default::default();
183-
if triple.contains("-none-") || triple.contains("nvptx") {
183+
if triple.contains("-none") || triple.contains("nvptx") {
184184
target.no_std = true;
185185
}
186186
target

src/libcore/slice/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3823,7 +3823,7 @@ where
38233823
// The last index of self.v is already checked and found to match
38243824
// by the last iteration, so we start searching a new match
38253825
// one index to the left.
3826-
let remainder = if self.v.len() == 0 { &[] } else { &self.v[..(self.v.len() - 1)] };
3826+
let remainder = if self.v.is_empty() { &[] } else { &self.v[..(self.v.len() - 1)] };
38273827
let idx = remainder.iter().rposition(|x| (self.pred)(x)).map(|idx| idx + 1).unwrap_or(0);
38283828
if idx == 0 {
38293829
self.finished = true;
@@ -4033,7 +4033,7 @@ where
40334033
return None;
40344034
}
40354035

4036-
let idx_opt = if self.v.len() == 0 {
4036+
let idx_opt = if self.v.is_empty() {
40374037
None
40384038
} else {
40394039
// work around borrowck limitations

src/libcore/tests/hash/sip.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ fn test_siphash_2_4() {
238238
#[cfg(target_pointer_width = "32")]
239239
fn test_hash_usize() {
240240
let val = 0xdeadbeef_deadbeef_u64;
241-
assert!(hash(&(val as u64)) != hash(&(val as usize)));
241+
assert_ne!(hash(&(val as u64)), hash(&(val as usize)));
242242
assert_eq!(hash(&(val as u32)), hash(&(val as usize)));
243243
}
244244

@@ -247,7 +247,7 @@ fn test_hash_usize() {
247247
fn test_hash_usize() {
248248
let val = 0xdeadbeef_deadbeef_u64;
249249
assert_eq!(hash(&(val as u64)), hash(&(val as usize)));
250-
assert!(hash(&(val as u32)) != hash(&(val as usize)));
250+
assert_ne!(hash(&(val as u32)), hash(&(val as usize)));
251251
}
252252

253253
#[test]
@@ -262,14 +262,14 @@ fn test_hash_idempotent() {
262262
fn test_hash_no_bytes_dropped_64() {
263263
let val = 0xdeadbeef_deadbeef_u64;
264264

265-
assert!(hash(&val) != hash(&zero_byte(val, 0)));
266-
assert!(hash(&val) != hash(&zero_byte(val, 1)));
267-
assert!(hash(&val) != hash(&zero_byte(val, 2)));
268-
assert!(hash(&val) != hash(&zero_byte(val, 3)));
269-
assert!(hash(&val) != hash(&zero_byte(val, 4)));
270-
assert!(hash(&val) != hash(&zero_byte(val, 5)));
271-
assert!(hash(&val) != hash(&zero_byte(val, 6)));
272-
assert!(hash(&val) != hash(&zero_byte(val, 7)));
265+
assert_ne!(hash(&val), hash(&zero_byte(val, 0)));
266+
assert_ne!(hash(&val), hash(&zero_byte(val, 1)));
267+
assert_ne!(hash(&val), hash(&zero_byte(val, 2)));
268+
assert_ne!(hash(&val), hash(&zero_byte(val, 3)));
269+
assert_ne!(hash(&val), hash(&zero_byte(val, 4)));
270+
assert_ne!(hash(&val), hash(&zero_byte(val, 5)));
271+
assert_ne!(hash(&val), hash(&zero_byte(val, 6)));
272+
assert_ne!(hash(&val), hash(&zero_byte(val, 7)));
273273

274274
fn zero_byte(val: u64, byte: usize) -> u64 {
275275
assert!(byte < 8);
@@ -281,10 +281,10 @@ fn test_hash_no_bytes_dropped_64() {
281281
fn test_hash_no_bytes_dropped_32() {
282282
let val = 0xdeadbeef_u32;
283283

284-
assert!(hash(&val) != hash(&zero_byte(val, 0)));
285-
assert!(hash(&val) != hash(&zero_byte(val, 1)));
286-
assert!(hash(&val) != hash(&zero_byte(val, 2)));
287-
assert!(hash(&val) != hash(&zero_byte(val, 3)));
284+
assert_ne!(hash(&val), hash(&zero_byte(val, 0)));
285+
assert_ne!(hash(&val), hash(&zero_byte(val, 1)));
286+
assert_ne!(hash(&val), hash(&zero_byte(val, 2)));
287+
assert_ne!(hash(&val), hash(&zero_byte(val, 3)));
288288

289289
fn zero_byte(val: u32, byte: usize) -> u32 {
290290
assert!(byte < 4);
@@ -299,14 +299,17 @@ fn test_hash_no_concat_alias() {
299299
let u = ("a", "abb");
300300

301301
assert!(s != t && t != u);
302-
assert!(hash(&s) != hash(&t) && hash(&s) != hash(&u));
302+
assert_ne!(s, t);
303+
assert_ne!(t, u);
304+
assert_ne!(hash(&s), hash(&t));
305+
assert_ne!(hash(&s), hash(&u));
303306

304307
let u = [1, 0, 0, 0];
305308
let v = (&u[..1], &u[1..3], &u[3..]);
306309
let w = (&u[..], &u[4..4], &u[4..4]);
307310

308-
assert!(v != w);
309-
assert!(hash(&v) != hash(&w));
311+
assert_ne!(v, w);
312+
assert_ne!(hash(&v), hash(&w));
310313
}
311314

312315
#[test]

src/librustc/arena.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl<'tcx> Arena<'tcx> {
250250

251251
#[inline]
252252
pub fn alloc_slice<T: Copy>(&self, value: &[T]) -> &mut [T] {
253-
if value.len() == 0 {
253+
if value.is_empty() {
254254
return &mut [];
255255
}
256256
self.dropless.alloc_slice(value)

src/librustc/dep_graph/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ impl DepGraph {
809809
dep_node
810810
);
811811

812-
if unlikely!(diagnostics.len() > 0) {
812+
if unlikely!(!diagnostics.is_empty()) {
813813
self.emit_diagnostics(tcx, data, dep_node_index, prev_dep_node_index, diagnostics);
814814
}
815815

src/librustc/ich/hcx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use smallvec::SmallVec;
1919
use std::cmp::Ord;
2020

2121
fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
22-
debug_assert!(ich::IGNORED_ATTRIBUTES.len() > 0);
22+
debug_assert!(!ich::IGNORED_ATTRIBUTES.is_empty());
2323
ich::IGNORED_ATTRIBUTES.iter().map(|&s| s).collect()
2424
}
2525

src/librustc/ich/impls_syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl<'ctx> rustc_target::HashStableContext for StableHashingContext<'ctx> {}
1414

1515
impl<'a> HashStable<StableHashingContext<'a>> for [ast::Attribute] {
1616
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
17-
if self.len() == 0 {
17+
if self.is_empty() {
1818
self.len().hash_stable(hcx, hasher);
1919
return;
2020
}

src/librustc/mir/interpret/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<'tcx> ConstEvalErr<'tcx> {
171171
// Skip the last, which is just the environment of the constant. The stacktrace
172172
// is sometimes empty because we create "fake" eval contexts in CTFE to do work
173173
// on constant values.
174-
if self.stacktrace.len() > 0 {
174+
if !self.stacktrace.is_empty() {
175175
for frame_info in &self.stacktrace[..self.stacktrace.len() - 1] {
176176
err.span_label(frame_info.call_site, frame_info.to_string());
177177
}

src/librustc/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2219,7 +2219,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
22192219
});
22202220
let region = if print_region {
22212221
let mut region = region.to_string();
2222-
if region.len() > 0 {
2222+
if !region.is_empty() {
22232223
region.push(' ');
22242224
}
22252225
region

src/librustc/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::borrow::Cow;
1818

1919
fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
2020
if def_id.is_top_level_module() {
21-
format!("top-level module")
21+
"top-level module".to_string()
2222
} else {
2323
format!("module `{}`", tcx.def_path_str(def_id))
2424
}

0 commit comments

Comments
 (0)