Skip to content

Commit 592e9c3

Browse files
committed
Auto merge of #69678 - Dylan-DPC:rollup-yoaueud, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #69565 (miri engine: turn some debug_assert into assert) - #69621 (use question mark operator in a few places.) - #69650 (cleanup more iterator usages (and other things)) - #69653 (use conditions directly) - #69665 (Invoke OptimizerLastEPCallbacks in PreLinkThinLTO) - #69670 (Add explanation for E0379) Failed merges: r? @ghost
2 parents 4ad6248 + f8c026b commit 592e9c3

File tree

24 files changed

+100
-56
lines changed

24 files changed

+100
-56
lines changed

src/liballoc/collections/btree/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>, marker::
11911191
let right_len = right_node.len();
11921192

11931193
// necessary for correctness, but in a private module
1194-
assert!(left_len + right_len + 1 <= CAPACITY);
1194+
assert!(left_len + right_len < CAPACITY);
11951195

11961196
unsafe {
11971197
ptr::write(

src/libcore/iter/adapters/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,9 +1894,7 @@ where
18941894
let to_skip = self.n;
18951895
self.n = 0;
18961896
// nth(n) skips n+1
1897-
if self.iter.nth(to_skip - 1).is_none() {
1898-
return None;
1899-
}
1897+
self.iter.nth(to_skip - 1)?;
19001898
}
19011899
self.iter.nth(n)
19021900
}
@@ -1916,9 +1914,7 @@ where
19161914
fn last(mut self) -> Option<I::Item> {
19171915
if self.n > 0 {
19181916
// nth(n) skips n+1
1919-
if self.iter.nth(self.n - 1).is_none() {
1920-
return None;
1921-
}
1917+
self.iter.nth(self.n - 1)?;
19221918
}
19231919
self.iter.last()
19241920
}

src/librustc/hir/map/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,8 @@ impl<'hir> Map<'hir> {
338338
Node::Variant(_) => DefKind::Variant,
339339
Node::Ctor(variant_data) => {
340340
// FIXME(eddyb) is this even possible, if we have a `Node::Ctor`?
341-
if variant_data.ctor_hir_id().is_none() {
342-
return None;
343-
}
341+
variant_data.ctor_hir_id()?;
342+
344343
let ctor_of = match self.find(self.get_parent_node(hir_id)) {
345344
Some(Node::Item(..)) => def::CtorOf::Struct,
346345
Some(Node::Variant(..)) => def::CtorOf::Variant,

src/librustc/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl<'tcx> Body<'tcx> {
189189
) -> Self {
190190
// We need `arg_count` locals, and one for the return place.
191191
assert!(
192-
local_decls.len() >= arg_count + 1,
192+
local_decls.len() > arg_count,
193193
"expected at least {} locals, got {}",
194194
arg_count + 1,
195195
local_decls.len()

src/librustc/ty/instance.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ impl<'tcx> Instance<'tcx> {
115115
}
116116

117117
// If this a non-generic instance, it cannot be a shared monomorphization.
118-
if self.substs.non_erasable_generics().next().is_none() {
119-
return None;
120-
}
118+
self.substs.non_erasable_generics().next()?;
121119

122120
match self.def {
123121
InstanceDef::Item(def_id) => tcx

src/librustc_codegen_llvm/va_arg.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ pub(super) fn emit_va_arg(
117117
// Windows x86_64
118118
("x86_64", true) => {
119119
let target_ty_size = bx.cx.size_of(target_ty).bytes();
120-
let indirect =
121-
if target_ty_size > 8 || !target_ty_size.is_power_of_two() { true } else { false };
120+
let indirect: bool = target_ty_size > 8 || !target_ty_size.is_power_of_two();
122121
emit_ptr_va_arg(bx, addr, target_ty, indirect, Align::from_bytes(8).unwrap(), false)
123122
}
124123
// For all other architecture/OS combinations fall back to using

src/librustc_codegen_ssa/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ pub fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> (PathB
186186
if flavor == LinkerFlavor::Msvc && t.target_vendor == "uwp" {
187187
if let Some(ref tool) = msvc_tool {
188188
let original_path = tool.path();
189-
if let Some(ref root_lib_path) = original_path.ancestors().skip(4).next() {
189+
if let Some(ref root_lib_path) = original_path.ancestors().nth(4) {
190190
let arch = match t.arch.as_str() {
191191
"x86_64" => Some("x64".to_string()),
192192
"x86" => Some("x86".to_string()),

src/librustc_error_codes/error_codes/E0379.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
A trait method was declared const.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0379
6+
#![feature(const_fn)]
7+
8+
trait Foo {
9+
const fn bar() -> u32; // error!
10+
}
11+
```
12+
113
Trait methods cannot be declared `const` by design. For more information, see
214
[RFC 911].
315

src/librustc_expand/mbe/transcribe.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ pub(super) fn transcribe(
119119
let tree = if let Some(tree) = stack.last_mut().unwrap().next() {
120120
// If it still has a TokenTree we have not looked at yet, use that tree.
121121
tree
122-
}
123-
// The else-case never produces a value for `tree` (it `continue`s or `return`s).
124-
else {
122+
} else {
123+
// This else-case never produces a value for `tree` (it `continue`s or `return`s).
124+
125125
// Otherwise, if we have just reached the end of a sequence and we can keep repeating,
126126
// go back to the beginning of the sequence.
127127
if let Frame::Sequence { idx, sep, .. } = stack.last_mut().unwrap() {

src/librustc_incremental/persist/work_product.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ pub fn copy_cgu_workproducts_to_incr_comp_cache_dir(
1313
files: &[(WorkProductFileKind, PathBuf)],
1414
) -> Option<(WorkProductId, WorkProduct)> {
1515
debug!("copy_cgu_workproducts_to_incr_comp_cache_dir({:?},{:?})", cgu_name, files);
16-
if sess.opts.incremental.is_none() {
17-
return None;
18-
}
16+
sess.opts.incremental.as_ref()?;
1917

2018
let saved_files = files
2119
.iter()

0 commit comments

Comments
 (0)