Rollup merge of #90519 - estebank:issue-84003, r=petrochenkov
Keep spans for generics in `#[derive(_)]` desugaring Keep the spans for generics coming from a `derive`d Item, so that errors and suggestions have better detail. Fix #84003.
This commit is contained in:
commit
0311cfa88c
14 changed files with 409 additions and 135 deletions
|
@ -551,6 +551,16 @@ impl Span {
|
|||
matches!(self.ctxt().outer_expn_data().kind, ExpnKind::Macro(MacroKind::Derive, _))
|
||||
}
|
||||
|
||||
/// Gate suggestions that would not be appropriate in a context the user didn't write.
|
||||
pub fn can_be_used_for_suggestions(self) -> bool {
|
||||
!self.from_expansion()
|
||||
// FIXME: If this span comes from a `derive` macro but it points at code the user wrote,
|
||||
// the callsite span and the span will be pointing at different places. It also means that
|
||||
// we can safely provide suggestions on this span.
|
||||
|| (matches!(self.ctxt().outer_expn_data().kind, ExpnKind::Macro(MacroKind::Derive, _))
|
||||
&& self.parent_callsite().map(|p| (p.lo(), p.hi())) != Some((self.lo(), self.hi())))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_root_ctxt(lo: BytePos, hi: BytePos) -> Span {
|
||||
Span::new(lo, hi, SyntaxContext::root(), None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue