Skip to content

Commit 55393b6

Browse files
committed
rustc_session: implement latent TODO
1 parent 45bad64 commit 55393b6

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

compiler/rustc_lint/src/context.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use rustc_middle::ty::{self, print::Printer, GenericArg, RegisteredTools, Ty, Ty
3636
use rustc_session::config::ExpectedValues;
3737
use rustc_session::lint::{BuiltinLintDiagnostics, LintExpectationId};
3838
use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId};
39-
use rustc_session::Session;
39+
use rustc_session::{LintStoreMarker, Session};
4040
use rustc_span::edit_distance::find_best_match_for_name;
4141
use rustc_span::symbol::{sym, Ident, Symbol};
4242
use rustc_span::{BytePos, Span};
@@ -77,6 +77,8 @@ pub struct LintStore {
7777
lint_groups: FxHashMap<&'static str, LintGroup>,
7878
}
7979

80+
impl LintStoreMarker for LintStore {}
81+
8082
/// The target of the `by_name` map, which accounts for renaming/deprecation.
8183
#[derive(Debug)]
8284
enum TargetLint {

compiler/rustc_lint/src/late.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ use rustc_span::Span;
3030
use std::any::Any;
3131
use std::cell::Cell;
3232

33-
/// Extract the `LintStore` from the query context.
34-
/// This function exists because we've erased `LintStore` as `dyn Any` in the session.
33+
/// Extract the [`LintStore`] from [`Session`].
34+
///
35+
/// This function exists because [`Session::lint_store`] is type-erased.
3536
pub fn unerased_lint_store(sess: &Session) -> &LintStore {
3637
let store: &Lrc<_> = sess.lint_store.as_ref().unwrap();
3738
let store: &dyn Any = &**store;

compiler/rustc_lint/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#![feature(min_specialization)]
4040
#![feature(never_type)]
4141
#![feature(rustc_attrs)]
42+
#![cfg_attr(bootstrap, feature(trait_upcasting))]
4243
#![recursion_limit = "256"]
4344
#![deny(rustc::untranslatable_diagnostic)]
4445
#![deny(rustc::diagnostic_outside_of_impl)]

compiler/rustc_session/src/session.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ pub struct CompilerIO {
139139
pub temps_dir: Option<PathBuf>,
140140
}
141141

142+
pub trait LintStoreMarker: Any + DynSync + DynSend {}
143+
142144
/// Represents the data associated with a compilation
143145
/// session for a single crate.
144146
pub struct Session {
@@ -171,10 +173,7 @@ pub struct Session {
171173
pub jobserver: Client,
172174

173175
/// This only ever stores a `LintStore` but we don't want a dependency on that type here.
174-
///
175-
/// FIXME(Centril): consider `dyn LintStoreMarker` once
176-
/// we can upcast to `Any` for some additional type safety.
177-
pub lint_store: Option<Lrc<dyn Any + DynSync + DynSend>>,
176+
pub lint_store: Option<Lrc<dyn LintStoreMarker>>,
178177

179178
/// Should be set if any lints are registered in `lint_store`.
180179
pub registered_lints: bool,

0 commit comments

Comments
 (0)