diff options
| author | Jubilee Young <workingjubilee@gmail.com> | 2024-05-10 11:57:10 -0700 |
|---|---|---|
| committer | Jubilee Young <workingjubilee@gmail.com> | 2024-05-10 12:29:01 -0700 |
| commit | fa5964fa9198e5c23e457821aa88bef34833b571 (patch) | |
| tree | 4dd89a3fbbea9540f72451f135d7d58af1283fc9 | |
| parent | 6a19a87097fbf430d0fe09e15d9266a990c1e0f6 (diff) | |
s/MetaVarExpr::Length/MetaVarExpr::Len/
| -rw-r--r-- | compiler/rustc_expand/src/mbe/metavar_expr.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_expand/src/mbe/quoted.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_expand/src/mbe/transcribe.rs | 4 |
3 files changed, 8 insertions, 8 deletions
diff --git a/compiler/rustc_expand/src/mbe/metavar_expr.rs b/compiler/rustc_expand/src/mbe/metavar_expr.rs index 8239cfd46cb..128e9f48ff5 100644 --- a/compiler/rustc_expand/src/mbe/metavar_expr.rs +++ b/compiler/rustc_expand/src/mbe/metavar_expr.rs @@ -23,7 +23,7 @@ pub(crate) enum MetaVarExpr { /// The length of the repetition at a particular depth, where 0 is the inner-most /// repetition. The `usize` is the depth. - Length(usize), + Len(usize), } impl MetaVarExpr { @@ -48,13 +48,13 @@ impl MetaVarExpr { MetaVarExpr::Ignore(parse_ident(&mut iter, psess, ident.span)?) } "index" => MetaVarExpr::Index(parse_depth(&mut iter, psess, ident.span)?), - "length" => MetaVarExpr::Length(parse_depth(&mut iter, psess, ident.span)?), + "len" => MetaVarExpr::Len(parse_depth(&mut iter, psess, ident.span)?), _ => { let err_msg = "unrecognized meta-variable expression"; let mut err = psess.dcx.struct_span_err(ident.span, err_msg); err.span_suggestion( ident.span, - "supported expressions are count, ignore, index and length", + "supported expressions are count, ignore, index and len", "", Applicability::MachineApplicable, ); @@ -68,7 +68,7 @@ impl MetaVarExpr { pub(crate) fn ident(&self) -> Option<Ident> { match *self { MetaVarExpr::Count(ident, _) | MetaVarExpr::Ignore(ident) => Some(ident), - MetaVarExpr::Index(..) | MetaVarExpr::Length(..) => None, + MetaVarExpr::Index(..) | MetaVarExpr::Len(..) => None, } } } @@ -111,7 +111,7 @@ fn parse_count<'psess>( Ok(MetaVarExpr::Count(ident, depth)) } -/// Parses the depth used by index(depth) and length(depth). +/// Parses the depth used by index(depth) and len(depth). fn parse_depth<'psess>( iter: &mut RefTokenTreeCursor<'_>, psess: &'psess ParseSess, diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index 06c1612ddba..2e5596f51c3 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -357,7 +357,7 @@ fn parse_sep_and_kleene_op<'a>( // `$$` or a meta-variable is the lhs of a macro but shouldn't. // -// For example, `macro_rules! foo { ( ${length()} ) => {} }` +// For example, `macro_rules! foo { ( ${len()} ) => {} }` fn span_dollar_dollar_or_metavar_in_the_lhs_err(sess: &Session, token: &Token) { sess.dcx() .span_err(token.span, format!("unexpected token: {}", pprust::token_to_string(token))); diff --git a/compiler/rustc_expand/src/mbe/transcribe.rs b/compiler/rustc_expand/src/mbe/transcribe.rs index 011aa95c8a1..139d58b3a76 100644 --- a/compiler/rustc_expand/src/mbe/transcribe.rs +++ b/compiler/rustc_expand/src/mbe/transcribe.rs @@ -675,14 +675,14 @@ fn transcribe_metavar_expr<'a>( } None => return Err(out_of_bounds_err(cx, repeats.len(), sp.entire(), "index")), }, - MetaVarExpr::Length(depth) => match repeats.iter().nth_back(depth) { + MetaVarExpr::Len(depth) => match repeats.iter().nth_back(depth) { Some((_, length)) => { result.push(TokenTree::token_alone( TokenKind::lit(token::Integer, sym::integer(*length), None), visited_span(), )); } - None => return Err(out_of_bounds_err(cx, repeats.len(), sp.entire(), "length")), + None => return Err(out_of_bounds_err(cx, repeats.len(), sp.entire(), "len")), }, } Ok(()) |
