mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
feat(hir): Store the Span
of the move
keyword
This commit is contained in:
parent
f81d6f0cb0
commit
8de489918b
@ -1548,7 +1548,10 @@ pub struct QSelf {
|
||||
#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
|
||||
pub enum CaptureBy {
|
||||
/// `move |x| y + x`.
|
||||
Value,
|
||||
Value {
|
||||
/// The span of the `move` keyword.
|
||||
move_kw: Span,
|
||||
},
|
||||
/// `move` keyword was not specified.
|
||||
Ref,
|
||||
}
|
||||
|
@ -2303,13 +2303,16 @@ impl<'a> Parser<'a> {
|
||||
/// Parses an optional `move` prefix to a closure-like construct.
|
||||
fn parse_capture_clause(&mut self) -> PResult<'a, CaptureBy> {
|
||||
if self.eat_keyword(kw::Move) {
|
||||
let move_kw_span = self.prev_token.span;
|
||||
// Check for `move async` and recover
|
||||
if self.check_keyword(kw::Async) {
|
||||
let move_async_span = self.token.span.with_lo(self.prev_token.span.data().lo);
|
||||
Err(errors::AsyncMoveOrderIncorrect { span: move_async_span }
|
||||
.into_diagnostic(&self.sess.span_diagnostic))
|
||||
} else {
|
||||
Ok(CaptureBy::Value)
|
||||
Ok(CaptureBy::Value {
|
||||
move_kw: move_kw_span,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
Ok(CaptureBy::Ref)
|
||||
|
Loading…
Reference in New Issue
Block a user