Skip to content

Commit 04c9842

Browse files
committed
Clippy: Fix botstrap fallout
1 parent 78ae132 commit 04c9842

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

src/tools/clippy/clippy_lints/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![feature(control_flow_enum)]
66
#![feature(drain_filter)]
77
#![feature(iter_intersperse)]
8-
#![feature(let_chains)]
98
#![feature(let_else)]
109
#![feature(once_cell)]
1110
#![feature(rustc_private)]
@@ -19,7 +18,7 @@
1918
// warn on rustc internal lints
2019
#![warn(rustc::internal)]
2120
// Disable this rustc lint for now, as it was also done in rustc
22-
#![allow(rustc::potential_query_instability)]
21+
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
2322

2423
// FIXME: switch to something more ergonomic here, once available.
2524
// (Currently there is no way to opt into sysroot crates without `extern crate`.)

src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs

+23-19
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,21 @@ pub(super) fn check<'tcx>(
111111
from_ty_orig, to_ty_orig
112112
),
113113
|diag| {
114-
if let (Some(from_def), Some(to_def)) = (from_ty.ty_adt_def(), to_ty.ty_adt_def())
115-
&& from_def == to_def
116-
{
117-
diag.note(&format!(
118-
"two instances of the same generic type (`{}`) may have different layouts",
119-
cx.tcx.item_name(from_def.did)
120-
));
121-
} else {
122-
if from_ty_orig.peel_refs() != from_ty {
123-
diag.note(&format!("the contained type `{}` has an undefined layout", from_ty));
124-
}
125-
if to_ty_orig.peel_refs() != to_ty {
126-
diag.note(&format!("the contained type `{}` has an undefined layout", to_ty));
114+
if_chain! {
115+
if let (Some(from_def), Some(to_def)) = (from_ty.ty_adt_def(), to_ty.ty_adt_def());
116+
if from_def == to_def;
117+
then {
118+
diag.note(&format!(
119+
"two instances of the same generic type (`{}`) may have different layouts",
120+
cx.tcx.item_name(from_def.did)
121+
));
122+
} else {
123+
if from_ty_orig.peel_refs() != from_ty {
124+
diag.note(&format!("the contained type `{}` has an undefined layout", from_ty));
125+
}
126+
if to_ty_orig.peel_refs() != to_ty {
127+
diag.note(&format!("the contained type `{}` has an undefined layout", to_ty));
128+
}
127129
}
128130
}
129131
},
@@ -279,11 +281,13 @@ fn reduce_ty<'tcx>(cx: &LateContext<'tcx>, mut ty: Ty<'tcx>) -> ReducedTy<'tcx>
279281
}
280282

281283
fn is_zero_sized_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
282-
if let Ok(ty) = cx.tcx.try_normalize_erasing_regions(cx.param_env, ty)
283-
&& let Ok(layout) = cx.tcx.layout_of(cx.param_env.and(ty))
284-
{
285-
layout.layout.size.bytes() == 0
286-
} else {
287-
false
284+
if_chain! {
285+
if let Ok(ty) = cx.tcx.try_normalize_erasing_regions(cx.param_env, ty);
286+
if let Ok(layout) = cx.tcx.layout_of(cx.param_env.and(ty));
287+
then {
288+
layout.layout.size.bytes() == 0
289+
} else {
290+
false
291+
}
288292
}
289293
}

0 commit comments

Comments
 (0)