Auto merge of #86320 - hi-rustin:rustin-patch-fix-span, r=estebank
shrinking the deprecated span ref: https://github.com/rust-lang/rust/pull/85617#issuecomment-854947988 part of #85403 r? `@estebank` The reason is that if we use method_span directly, it will cause the in_derive_expansion judgment to fail.
This commit is contained in:
commit
955b9c0d4c
10 changed files with 186 additions and 152 deletions
|
@ -226,18 +226,19 @@ fn late_report_deprecation(
|
|||
suggestion: Option<Symbol>,
|
||||
lint: &'static Lint,
|
||||
span: Span,
|
||||
method_span: Option<Span>,
|
||||
hir_id: HirId,
|
||||
def_id: DefId,
|
||||
) {
|
||||
if span.in_derive_expansion() {
|
||||
return;
|
||||
}
|
||||
|
||||
tcx.struct_span_lint_hir(lint, hir_id, span, |lint| {
|
||||
let method_span = method_span.unwrap_or(span);
|
||||
tcx.struct_span_lint_hir(lint, hir_id, method_span, |lint| {
|
||||
let mut diag = lint.build(message);
|
||||
if let hir::Node::Expr(_) = tcx.hir().get(hir_id) {
|
||||
let kind = tcx.def_kind(def_id).descr(def_id);
|
||||
deprecation_suggestion(&mut diag, kind, suggestion, span);
|
||||
deprecation_suggestion(&mut diag, kind, suggestion, method_span);
|
||||
}
|
||||
diag.emit()
|
||||
});
|
||||
|
@ -306,13 +307,13 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
let path = &with_no_trimmed_paths(|| self.def_path_str(def_id));
|
||||
let kind = self.def_kind(def_id).descr(def_id);
|
||||
let (message, lint) = deprecation_message(&depr_entry.attr, kind, path);
|
||||
let span = method_span.unwrap_or(span);
|
||||
late_report_deprecation(
|
||||
self,
|
||||
&message,
|
||||
depr_entry.attr.suggestion,
|
||||
lint,
|
||||
span,
|
||||
method_span,
|
||||
id,
|
||||
def_id,
|
||||
);
|
||||
|
|
|
@ -875,7 +875,8 @@ impl Visitor<'tcx> for Checker<'tcx> {
|
|||
|
||||
fn visit_path(&mut self, path: &'tcx hir::Path<'tcx>, id: hir::HirId) {
|
||||
if let Some(def_id) = path.res.opt_def_id() {
|
||||
self.tcx.check_stability(def_id, Some(id), path.span, None)
|
||||
let method_span = path.segments.last().map(|s| s.ident.span);
|
||||
self.tcx.check_stability(def_id, Some(id), path.span, method_span)
|
||||
}
|
||||
intravisit::walk_path(self, path)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue