Skip to content

Commit 433e546

Browse files
Move Level to rustc_session
1 parent 4351698 commit 433e546

File tree

3 files changed

+48
-41
lines changed

3 files changed

+48
-41
lines changed

src/librustc/lint/mod.rs

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ use syntax::ast;
3939
use syntax::source_map::{MultiSpan, ExpnKind, DesugaringKind};
4040
use syntax::early_buffered_lints::BufferedEarlyLintId;
4141
use syntax::edition::Edition;
42-
use syntax::symbol::{Symbol, sym};
42+
use syntax::symbol::Symbol;
4343
use syntax_pos::hygiene::MacroKind;
4444
use syntax_pos::Span;
4545

4646
pub use crate::lint::context::{LateContext, EarlyContext, LintContext, LintStore,
4747
check_crate, check_ast_crate, late_lint_mod, CheckLintNameResult,
4848
BufferedEarlyLint,};
4949

50+
pub use rustc_session::lint::Level;
51+
5052
/// Specification of a single lint.
5153
#[derive(Copy, Clone, Debug)]
5254
pub struct Lint {
@@ -542,46 +544,6 @@ impl LintId {
542544
}
543545
}
544546

545-
/// Setting for how to handle a lint.
546-
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash, HashStable)]
547-
pub enum Level {
548-
Allow, Warn, Deny, Forbid,
549-
}
550-
551-
impl Level {
552-
/// Converts a level to a lower-case string.
553-
pub fn as_str(self) -> &'static str {
554-
match self {
555-
Allow => "allow",
556-
Warn => "warn",
557-
Deny => "deny",
558-
Forbid => "forbid",
559-
}
560-
}
561-
562-
/// Converts a lower-case string to a level.
563-
pub fn from_str(x: &str) -> Option<Level> {
564-
match x {
565-
"allow" => Some(Allow),
566-
"warn" => Some(Warn),
567-
"deny" => Some(Deny),
568-
"forbid" => Some(Forbid),
569-
_ => None,
570-
}
571-
}
572-
573-
/// Converts a symbol to a level.
574-
pub fn from_symbol(x: Symbol) -> Option<Level> {
575-
match x {
576-
sym::allow => Some(Allow),
577-
sym::warn => Some(Warn),
578-
sym::deny => Some(Deny),
579-
sym::forbid => Some(Forbid),
580-
_ => None,
581-
}
582-
}
583-
}
584-
585547
/// How a lint level was set.
586548
#[derive(Clone, Copy, PartialEq, Eq, HashStable)]
587549
pub enum LintSource {

src/librustc_session/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pub mod cgu_reuse_tracker;
22
pub mod utils;
3+
pub mod lint;

src/librustc_session/lint.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
use syntax_pos::{Symbol, sym};
2+
pub use self::Level::*;
3+
4+
/// Setting for how to handle a lint.
5+
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
6+
pub enum Level {
7+
Allow, Warn, Deny, Forbid,
8+
}
9+
10+
rustc_data_structures::impl_stable_hash_via_hash!(Level);
11+
12+
impl Level {
13+
/// Converts a level to a lower-case string.
14+
pub fn as_str(self) -> &'static str {
15+
match self {
16+
Level::Allow => "allow",
17+
Level::Warn => "warn",
18+
Level::Deny => "deny",
19+
Level::Forbid => "forbid",
20+
}
21+
}
22+
23+
/// Converts a lower-case string to a level.
24+
pub fn from_str(x: &str) -> Option<Level> {
25+
match x {
26+
"allow" => Some(Level::Allow),
27+
"warn" => Some(Level::Warn),
28+
"deny" => Some(Level::Deny),
29+
"forbid" => Some(Level::Forbid),
30+
_ => None,
31+
}
32+
}
33+
34+
/// Converts a symbol to a level.
35+
pub fn from_symbol(x: Symbol) -> Option<Level> {
36+
match x {
37+
sym::allow => Some(Level::Allow),
38+
sym::warn => Some(Level::Warn),
39+
sym::deny => Some(Level::Deny),
40+
sym::forbid => Some(Level::Forbid),
41+
_ => None,
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)