Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5945ef9

Browse files
committed
Auto merge of rust-lang#15375 - Veykril:hygiene, r=Veykril
Simplify
2 parents 151c750 + 75607fc commit 5945ef9

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

crates/hir-expand/src/hygiene.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ fn make_hygiene_info(
173173
db: &dyn ExpandDatabase,
174174
macro_file: MacroFile,
175175
loc: &MacroCallLoc,
176-
) -> Option<HygieneInfo> {
176+
) -> HygieneInfo {
177177
let def = loc.def.ast_id().left().and_then(|id| {
178178
let def_tt = match id.to_node(db) {
179179
ast::Macro::MacroRules(mac) => mac.token_tree()?,
@@ -204,15 +204,15 @@ fn make_hygiene_info(
204204
))
205205
});
206206

207-
Some(HygieneInfo {
207+
HygieneInfo {
208208
file: macro_file,
209209
attr_input_or_mac_def_start: attr_input_or_mac_def
210210
.map(|it| it.map(|tt| tt.syntax().text_range().start())),
211211
macro_arg_shift: mbe::Shift::new(&macro_arg.0),
212212
macro_arg,
213213
macro_def,
214214
exp_map,
215-
})
215+
}
216216
}
217217

218218
impl HygieneFrame {
@@ -221,8 +221,7 @@ impl HygieneFrame {
221221
None => (None, None, false),
222222
Some(macro_file) => {
223223
let loc = db.lookup_intern_macro_call(macro_file.macro_call_id);
224-
let info =
225-
make_hygiene_info(db, macro_file, &loc).map(|info| (loc.kind.file_id(), info));
224+
let info = Some((make_hygiene_info(db, macro_file, &loc), loc.kind.file_id()));
226225
match loc.def.kind {
227226
MacroDefKind::Declarative(_) => {
228227
(info, Some(loc.def.krate), loc.def.local_inner)
@@ -236,17 +235,14 @@ impl HygieneFrame {
236235
}
237236
};
238237

239-
let (calling_file, info) = match info {
240-
None => {
241-
return HygieneFrame {
242-
expansion: None,
243-
local_inner,
244-
krate,
245-
call_site: None,
246-
def_site: None,
247-
};
238+
let Some((info, calling_file)) = info else {
239+
return HygieneFrame {
240+
expansion: None,
241+
local_inner,
242+
krate,
243+
call_site: None,
244+
def_site: None,
248245
}
249-
Some(it) => it,
250246
};
251247

252248
let def_site = info.attr_input_or_mac_def_start.map(|it| db.hygiene_frame(it.file_id));

crates/mbe/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use crate::{
2828
tt_iter::TtIter,
2929
};
3030

31-
// FIXME: we probably should re-think `token_tree_to_syntax_node` interfaces
3231
pub use self::tt::{Delimiter, DelimiterKind, Punct};
3332
pub use ::parser::TopEntryPoint;
3433

0 commit comments

Comments
 (0)