Implement rustc side of report-future-incompat

This commit is contained in:
Aaron Hill 2020-08-13 15:41:52 -04:00
parent ffe52882ed
commit 23018a55d9
No known key found for this signature in database
GPG key ID: B4087E510E98B164
22 changed files with 332 additions and 114 deletions

View file

@ -3,7 +3,7 @@ use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_middle::ty;
use rustc_middle::ty::adjustment::{Adjust, Adjustment};
use rustc_session::lint::FutureIncompatibleInfo;
use rustc_session::lint::FutureBreakage;
use rustc_span::symbol::sym;
declare_lint! {
@ -38,6 +38,9 @@ declare_lint! {
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #66145 <https://github.com/rust-lang/rust/issues/66145>",
edition: None,
future_breakage: Some(FutureBreakage {
date: None
})
};
}

View file

@ -44,7 +44,6 @@ use rustc_middle::lint::LintDiagnosticBuilder;
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::subst::{GenericArgKind, Subst};
use rustc_middle::ty::{self, layout::LayoutError, Ty, TyCtxt};
use rustc_session::lint::FutureIncompatibleInfo;
use rustc_session::Session;
use rustc_span::edition::Edition;
use rustc_span::source_map::Spanned;

View file

@ -22,7 +22,7 @@ use rustc_ast as ast;
use rustc_ast::util::lev_distance::find_best_match_for_name;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync;
use rustc_errors::{struct_span_err, Applicability};
use rustc_errors::{add_elided_lifetime_in_path_suggestion, struct_span_err, Applicability};
use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_hir::def_id::{CrateNum, DefId};
@ -33,9 +33,10 @@ use rustc_middle::middle::stability;
use rustc_middle::ty::layout::{LayoutError, TyAndLayout};
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt};
use rustc_session::lint::{add_elided_lifetime_in_path_suggestion, BuiltinLintDiagnostics};
use rustc_session::lint::BuiltinLintDiagnostics;
use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId};
use rustc_session::Session;
use rustc_session::SessionLintStore;
use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP};
use rustc_target::abi::LayoutOf;
@ -69,6 +70,20 @@ pub struct LintStore {
lint_groups: FxHashMap<&'static str, LintGroup>,
}
impl SessionLintStore for LintStore {
fn name_to_lint(&self, lint_name: &str) -> LintId {
let lints = self
.find_lints(lint_name)
.unwrap_or_else(|_| panic!("Failed to find lint with name `{}`", lint_name));
if let &[lint] = lints.as_slice() {
return lint;
} else {
panic!("Found mutliple lints with name `{}`: {:?}", lint_name, lints);
}
}
}
/// The target of the `by_name` map, which accounts for renaming/deprecation.
enum TargetLint {
/// A direct lint target
@ -543,7 +558,7 @@ pub trait LintContext: Sized {
anon_lts,
) => {
add_elided_lifetime_in_path_suggestion(
sess,
sess.source_map(),
&mut db,
n,
path_span,