Skip to content

Commit 722b444

Browse files
committed
Use let chains in pretty_printing_compatibility_hack.
To reduce indentation and improve readability.
1 parent fb3a471 commit 722b444

File tree

1 file changed

+32
-41
lines changed

1 file changed

+32
-41
lines changed

compiler/rustc_expand/src/base.rs

+32-41
Original file line numberDiff line numberDiff line change
@@ -1338,47 +1338,38 @@ pub fn parse_macro_name_and_helper_attrs(
13381338
/// FIXME(#73933): Remove this eventually.
13391339
fn pretty_printing_compatibility_hack(item: &Item, sess: &Session) -> bool {
13401340
let name = item.ident.name;
1341-
if name == sym::ProceduralMasqueradeDummyType {
1342-
if let ast::ItemKind::Enum(enum_def, _) = &item.kind {
1343-
if let [variant] = &*enum_def.variants {
1344-
if variant.ident.name == sym::Input {
1345-
let filename = sess.source_map().span_to_filename(item.ident.span);
1346-
if let FileName::Real(real) = filename {
1347-
if let Some(c) = real
1348-
.local_path()
1349-
.unwrap_or(Path::new(""))
1350-
.components()
1351-
.flat_map(|c| c.as_os_str().to_str())
1352-
.find(|c| c.starts_with("rental") || c.starts_with("allsorts-rental"))
1353-
{
1354-
let crate_matches = if c.starts_with("allsorts-rental") {
1355-
true
1356-
} else {
1357-
let mut version = c.trim_start_matches("rental-").split('.');
1358-
version.next() == Some("0")
1359-
&& version.next() == Some("5")
1360-
&& version
1361-
.next()
1362-
.and_then(|c| c.parse::<u32>().ok())
1363-
.is_some_and(|v| v < 6)
1364-
};
1365-
1366-
if crate_matches {
1367-
sess.psess.buffer_lint(
1368-
PROC_MACRO_BACK_COMPAT,
1369-
item.ident.span,
1370-
ast::CRATE_NODE_ID,
1371-
BuiltinLintDiag::ProcMacroBackCompat {
1372-
crate_name: "rental".to_string(),
1373-
fixed_version: "0.5.6".to_string(),
1374-
},
1375-
);
1376-
return true;
1377-
}
1378-
}
1379-
}
1380-
}
1381-
}
1341+
if name == sym::ProceduralMasqueradeDummyType
1342+
&& let ast::ItemKind::Enum(enum_def, _) = &item.kind
1343+
&& let [variant] = &*enum_def.variants
1344+
&& variant.ident.name == sym::Input
1345+
&& let FileName::Real(real) = sess.source_map().span_to_filename(item.ident.span)
1346+
&& let Some(c) = real
1347+
.local_path()
1348+
.unwrap_or(Path::new(""))
1349+
.components()
1350+
.flat_map(|c| c.as_os_str().to_str())
1351+
.find(|c| c.starts_with("rental") || c.starts_with("allsorts-rental"))
1352+
{
1353+
let crate_matches = if c.starts_with("allsorts-rental") {
1354+
true
1355+
} else {
1356+
let mut version = c.trim_start_matches("rental-").split('.');
1357+
version.next() == Some("0")
1358+
&& version.next() == Some("5")
1359+
&& version.next().and_then(|c| c.parse::<u32>().ok()).is_some_and(|v| v < 6)
1360+
};
1361+
1362+
if crate_matches {
1363+
sess.psess.buffer_lint(
1364+
PROC_MACRO_BACK_COMPAT,
1365+
item.ident.span,
1366+
ast::CRATE_NODE_ID,
1367+
BuiltinLintDiag::ProcMacroBackCompat {
1368+
crate_name: "rental".to_string(),
1369+
fixed_version: "0.5.6".to_string(),
1370+
},
1371+
);
1372+
return true;
13821373
}
13831374
}
13841375
false

0 commit comments

Comments
 (0)