diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-11-13 13:08:58 +0000 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-11-13 13:09:23 +0000 |
| commit | df86ad8d36a038ee61e3ee977082ea6623613bbd (patch) | |
| tree | 3a116efa93a1a0314ac007037a3a7c51068e3c2f /compiler/rustc_parse/src/parser/attr_wrapper.rs | |
| parent | 3be81dd0cedef3c83fba7047857418633708890f (diff) | |
| download | rust-df86ad8d36a038ee61e3ee977082ea6623613bbd.tar.gz rust-df86ad8d36a038ee61e3ee977082ea6623613bbd.zip | |
Add `delay_span_bug` to `AttrWrapper::take_for_recovery`
Diffstat (limited to 'compiler/rustc_parse/src/parser/attr_wrapper.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/attr_wrapper.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/rustc_parse/src/parser/attr_wrapper.rs b/compiler/rustc_parse/src/parser/attr_wrapper.rs index 1b16ecb5ec2..c8160548763 100644 --- a/compiler/rustc_parse/src/parser/attr_wrapper.rs +++ b/compiler/rustc_parse/src/parser/attr_wrapper.rs @@ -5,7 +5,8 @@ use rustc_ast::tokenstream::{AttrTokenTree, DelimSpan, LazyAttrTokenStream, Spac use rustc_ast::{self as ast}; use rustc_ast::{AttrVec, Attribute, HasAttrs, HasTokens}; use rustc_errors::PResult; -use rustc_span::{sym, Span}; +use rustc_session::parse::ParseSess; +use rustc_span::{sym, Span, DUMMY_SP}; use std::convert::TryInto; use std::ops::Range; @@ -39,8 +40,13 @@ impl AttrWrapper { pub fn empty() -> AttrWrapper { AttrWrapper { attrs: AttrVec::new(), start_pos: usize::MAX } } - // FIXME: Delay span bug here? - pub(crate) fn take_for_recovery(self) -> AttrVec { + + pub(crate) fn take_for_recovery(self, sess: &ParseSess) -> AttrVec { + sess.span_diagnostic.delay_span_bug( + self.attrs.get(0).map(|attr| attr.span).unwrap_or(DUMMY_SP), + "AttrVec is taken for recovery but no error is produced", + ); + self.attrs } |
