Add delay_span_bug to AttrWrapper::take_for_recovery

This commit is contained in:
Maybe Waffle 2022-11-13 13:08:58 +00:00
parent 3be81dd0ce
commit df86ad8d36
3 changed files with 26 additions and 13 deletions

View file

@ -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
}