Skip to content

Commit 0e34142

Browse files
committed
don't lazily evaulate some trivial values for Option::None replacements (clippy::unnecessary_lazy_evaluations)
1 parent f567287 commit 0e34142

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

compiler/rustc_lint/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &
961961
continue;
962962
}
963963

964-
let span = sugared_span.take().unwrap_or_else(|| attr.span);
964+
let span = sugared_span.take().unwrap_or(attr.span);
965965

966966
if attr.is_doc_comment() || cx.sess().check_name(attr, sym::doc) {
967967
cx.struct_span_lint(UNUSED_DOC_COMMENTS, span, |lint| {

compiler/rustc_metadata/src/native_libs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl Collector<'tcx> {
170170
feature_err(
171171
&self.tcx.sess.parse_sess,
172172
sym::static_nobundle,
173-
span.unwrap_or_else(|| rustc_span::DUMMY_SP),
173+
span.unwrap_or(rustc_span::DUMMY_SP),
174174
"kind=\"static-nobundle\" is unstable",
175175
)
176176
.emit();
@@ -179,7 +179,7 @@ impl Collector<'tcx> {
179179
feature_err(
180180
&self.tcx.sess.parse_sess,
181181
sym::raw_dylib,
182-
span.unwrap_or_else(|| rustc_span::DUMMY_SP),
182+
span.unwrap_or(rustc_span::DUMMY_SP),
183183
"kind=\"raw-dylib\" is unstable",
184184
)
185185
.emit();

compiler/rustc_mir/src/dataflow/move_paths/builder.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
480480
};
481481
let base_ty = base_place.ty(self.builder.body, self.builder.tcx).ty;
482482
let len: u64 = match base_ty.kind() {
483-
ty::Array(_, size) => {
484-
let length: u64 = size.eval_usize(self.builder.tcx, self.builder.param_env);
485-
length
486-
}
483+
ty::Array(_, size) => size.eval_usize(self.builder.tcx, self.builder.param_env),
487484
_ => bug!("from_end: false slice pattern of non-array type"),
488485
};
489486
for offset in from..to {

0 commit comments

Comments
 (0)