diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-08-06 10:17:46 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-08-16 09:07:29 +1000 |
| commit | c8098be41fa767a96cfb3665147fabf06f456be9 (patch) | |
| tree | e2182b48301ad031e61d0527f91792750a0fcc04 /compiler/rustc_parse/src/parser/item.rs | |
| parent | 55906aa2407b10b4f910c221be6f40e549780bb8 (diff) | |
| download | rust-c8098be41fa767a96cfb3665147fabf06f456be9.tar.gz rust-c8098be41fa767a96cfb3665147fabf06f456be9.zip | |
Convert a bool to `Trailing`.
This pre-existing type is suitable for use with the return value of the `f` parameter in `collect_tokens_trailing_token`. The more descriptive name will be useful because the next commit will add another boolean value to the return value of `f`.
Diffstat (limited to 'compiler/rustc_parse/src/parser/item.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index e34e82bcd7b..fb205c5797a 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -145,7 +145,7 @@ impl<'a> Parser<'a> { let span = lo.to(this.prev_token.span); let id = DUMMY_NODE_ID; let item = Item { ident, attrs, id, kind, vis, span, tokens: None }; - return Ok((Some(item), false)); + return Ok((Some(item), Trailing::No)); } // At this point, we have failed to parse an item. @@ -160,7 +160,7 @@ impl<'a> Parser<'a> { if !attrs_allowed { this.recover_attrs_no_item(&attrs)?; } - Ok((None, false)) + Ok((None, Trailing::No)) }) } @@ -1554,7 +1554,7 @@ impl<'a> Parser<'a> { let vis = this.parse_visibility(FollowedByType::No)?; if !this.recover_nested_adt_item(kw::Enum)? { - return Ok((None, false)); + return Ok((None, Trailing::No)); } let ident = this.parse_field_ident("enum", vlo)?; @@ -1566,7 +1566,7 @@ impl<'a> Parser<'a> { this.bump(); this.parse_delim_args()?; - return Ok((None, this.token == token::Comma)); + return Ok((None, Trailing::from(this.token == token::Comma))); } let struct_def = if this.check(&token::OpenDelim(Delimiter::Brace)) { @@ -1623,7 +1623,7 @@ impl<'a> Parser<'a> { is_placeholder: false, }; - Ok((Some(vr), this.token == token::Comma)) + Ok((Some(vr), Trailing::from(this.token == token::Comma))) }, ) .map_err(|mut err| { @@ -1815,7 +1815,7 @@ impl<'a> Parser<'a> { attrs, is_placeholder: false, }, - p.token == token::Comma, + Trailing::from(p.token == token::Comma), )) }) }) @@ -1830,7 +1830,8 @@ impl<'a> Parser<'a> { self.collect_tokens_trailing_token(attrs, ForceCollect::No, |this, attrs| { let lo = this.token.span; let vis = this.parse_visibility(FollowedByType::No)?; - this.parse_single_struct_field(adt_ty, lo, vis, attrs).map(|field| (field, false)) + this.parse_single_struct_field(adt_ty, lo, vis, attrs) + .map(|field| (field, Trailing::No)) }) } @@ -2810,7 +2811,7 @@ impl<'a> Parser<'a> { if let Some(mut param) = this.parse_self_param()? { param.attrs = attrs; let res = if first_param { Ok(param) } else { this.recover_bad_self_param(param) }; - return Ok((res?, false)); + return Ok((res?, Trailing::No)); } let is_name_required = match this.token.kind { @@ -2826,7 +2827,7 @@ impl<'a> Parser<'a> { this.parameter_without_type(&mut err, pat, is_name_required, first_param) { let guar = err.emit(); - Ok((dummy_arg(ident, guar), false)) + Ok((dummy_arg(ident, guar), Trailing::No)) } else { Err(err) }; @@ -2869,7 +2870,7 @@ impl<'a> Parser<'a> { Ok(( Param { attrs, id: ast::DUMMY_NODE_ID, is_placeholder: false, pat, span, ty }, - false, + Trailing::No, )) }) } |
