mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Fix remaining meta-variable expression TODOs
This commit is contained in:
parent
b7511248f9
commit
5d333c155e
@ -337,8 +337,12 @@ fn check_occurrences(
|
||||
let name = MacroRulesNormalizedIdent::new(name);
|
||||
check_ops_is_prefix(sess, node_id, macros, binders, ops, span, name);
|
||||
}
|
||||
// FIXME(c410-f3r) Check token (https://github.com/rust-lang/rust/issues/93902)
|
||||
TokenTree::MetaVarExpr(..) => {}
|
||||
TokenTree::MetaVarExpr(dl, ref mve) => {
|
||||
let Some(name) = mve.ident().map(MacroRulesNormalizedIdent::new) else {
|
||||
return;
|
||||
};
|
||||
check_ops_is_prefix(sess, node_id, macros, binders, ops, dl.entire(), name);
|
||||
}
|
||||
TokenTree::Delimited(_, ref del) => {
|
||||
check_nested_occurrences(sess, node_id, &del.tts, macros, binders, ops, valid);
|
||||
}
|
||||
|
@ -324,8 +324,11 @@ pub(super) fn count_names(ms: &[TokenTree]) -> usize {
|
||||
TokenTree::Delimited(_, ref delim) => count_names(&delim.tts),
|
||||
TokenTree::MetaVar(..) => 0,
|
||||
TokenTree::MetaVarDecl(..) => 1,
|
||||
// FIXME(c410-f3r) MetaVarExpr should be handled instead of being ignored
|
||||
// https://github.com/rust-lang/rust/issues/9390
|
||||
// Panicking here would abort execution because `parse_tree` makes use of this
|
||||
// function. In other words, RHS meta-variable expressions eventually end-up here.
|
||||
//
|
||||
// `0` is still returned to inform that no meta-variable was found. `Meta-variables
|
||||
// != Meta-variable expressions`
|
||||
TokenTree::MetaVarExpr(..) => 0,
|
||||
TokenTree::Sequence(_, ref seq) => seq.num_captures,
|
||||
TokenTree::Token(..) => 0,
|
||||
|
@ -62,9 +62,9 @@ impl MetaVarExpr {
|
||||
Ok(rslt)
|
||||
}
|
||||
|
||||
crate fn ident(&self) -> Option<&Ident> {
|
||||
match self {
|
||||
MetaVarExpr::Count(ident, _) | MetaVarExpr::Ignore(ident) => Some(&ident),
|
||||
crate fn ident(&self) -> Option<Ident> {
|
||||
match *self {
|
||||
MetaVarExpr::Count(ident, _) | MetaVarExpr::Ignore(ident) => Some(ident),
|
||||
MetaVarExpr::Index(..) | MetaVarExpr::Length(..) => None,
|
||||
}
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ fn lockstep_iter_size(
|
||||
TokenTree::MetaVarExpr(_, ref expr) => {
|
||||
let default_rslt = LockstepIterSize::Unconstrained;
|
||||
let Some(ident) = expr.ident() else { return default_rslt; };
|
||||
let name = MacroRulesNormalizedIdent::new(ident.clone());
|
||||
let name = MacroRulesNormalizedIdent::new(ident);
|
||||
match lookup_cur_matched(name, interpolations, repeats) {
|
||||
Some(MatchedSeq(ref ads)) => {
|
||||
default_rslt.with(LockstepIterSize::Constraint(ads.len(), name))
|
||||
@ -479,7 +479,7 @@ fn count_repetitions<'a>(
|
||||
count(cx, 0, depth_opt, matched, sp)
|
||||
}
|
||||
|
||||
/// Returns a `NamedMatch` item declared on the RHS given an arbitrary [Ident]
|
||||
/// Returns a `NamedMatch` item declared on the LHS given an arbitrary [Ident]
|
||||
fn matched_from_ident<'ctx, 'interp, 'rslt>(
|
||||
cx: &ExtCtxt<'ctx>,
|
||||
ident: Ident,
|
||||
|
Loading…
Reference in New Issue
Block a user