Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not provide suggestions when the spans come from expanded code that doesn't point at user code #109082

Closed
wants to merge 14 commits into from
Closed
Prev Previous commit
Next Next commit
remove DesugaringKind::Resize
  • Loading branch information
estebank committed Apr 26, 2023
commit a220652757f58708b0f17e0454861d1ece43e720
5 changes: 3 additions & 2 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
use Destination::*;

use rustc_span::source_map::SourceMap;
use rustc_span::{DesugaringKind, FileLines, SourceFile, Span};
// use rustc_span::{DesugaringKind, FileLines, SourceFile, Span};
use rustc_span::{FileLines, SourceFile, Span};

use crate::snippet::{
Annotation, AnnotationColumn, AnnotationType, Line, MultilineAnnotation, Style, StyledString,
Expand Down Expand Up @@ -405,7 +406,7 @@ pub trait Emitter: Translate {
for (i, trace) in macro_backtrace.iter().rev().enumerate().filter(|(_, trace)| {
!matches!(
trace.kind,
ExpnKind::Inlined | ExpnKind::Desugaring(DesugaringKind::Resize)
ExpnKind::Inlined //| ExpnKind::Desugaring(DesugaringKind::Resize)
) && !trace.def_site.is_dummy()
}) {
if always_backtrace {
Expand Down
13 changes: 7 additions & 6 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2402,12 +2402,13 @@ impl<'tcx> TyCtxt<'tcx> {
/// `Span` points at an attribute and not user code.
#[inline(always)]
pub fn mark_span_for_resize(self, span: Span) -> Span {
if true {
return span;
}
self.with_stable_hashing_context(|hcx| {
span.mark_with_reason(None, rustc_span::DesugaringKind::Resize, span.edition(), hcx)
})
span
// if true {
// return span;
// }
// self.with_stable_hashing_context(|hcx| {
// span.mark_with_reason(None, rustc_span::DesugaringKind::Resize, span.edition(), hcx)
// })
}

pub fn adjust_ident(self, mut ident: Ident, scope: DefId) -> Ident {
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_span/src/hygiene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,10 +1156,10 @@ pub enum DesugaringKind {
ForLoop,
WhileLoop,
Replace,
/// Used to proactively mark `Span`s that have been modified from another `Span`. This allows
/// the diagnostics machinery to be able to detect spans coming from proc-macros that do not
/// point to user code.
Resize,
// /// Used to proactively mark `Span`s that have been modified from another `Span`. This allows
// /// the diagnostics machinery to be able to detect spans coming from proc-macros that do not
// /// point to user code.
// Resize,
}

impl DesugaringKind {
Expand All @@ -1176,7 +1176,7 @@ impl DesugaringKind {
DesugaringKind::ForLoop => "`for` loop",
DesugaringKind::WhileLoop => "`while` loop",
DesugaringKind::Replace => "drop and replace",
DesugaringKind::Resize => "a resized `Span`",
// DesugaringKind::Resize => "a resized `Span`",
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,15 +884,15 @@ impl Span {
)
}

pub fn peel_ctxt(mut self) -> Span {
loop {
let data = self.data().ctxt.outer_expn_data();
if let ExpnKind::Desugaring(DesugaringKind::Resize) = data.kind {
self = data.call_site;
} else {
break;
}
}
pub fn peel_ctxt(self) -> Span {
// loop {
// let data = self.data().ctxt.outer_expn_data();
// if let ExpnKind::Desugaring(DesugaringKind::Resize) = data.kind {
// self = data.call_site;
// } else {
// break;
// }
// }
self
}

Expand Down