Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4351698
commit 433e546
Showing
3 changed files
with
48 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod cgu_reuse_tracker; | ||
pub mod utils; | ||
pub mod lint; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use syntax_pos::{Symbol, sym}; | ||
pub use self::Level::*; | ||
|
||
/// Setting for how to handle a lint. | ||
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] | ||
pub enum Level { | ||
Allow, Warn, Deny, Forbid, | ||
} | ||
|
||
rustc_data_structures::impl_stable_hash_via_hash!(Level); | ||
|
||
impl Level { | ||
/// Converts a level to a lower-case string. | ||
pub fn as_str(self) -> &'static str { | ||
match self { | ||
Level::Allow => "allow", | ||
Level::Warn => "warn", | ||
Level::Deny => "deny", | ||
Level::Forbid => "forbid", | ||
} | ||
} | ||
|
||
/// Converts a lower-case string to a level. | ||
pub fn from_str(x: &str) -> Option<Level> { | ||
match x { | ||
"allow" => Some(Level::Allow), | ||
"warn" => Some(Level::Warn), | ||
"deny" => Some(Level::Deny), | ||
"forbid" => Some(Level::Forbid), | ||
_ => None, | ||
} | ||
} | ||
|
||
/// Converts a symbol to a level. | ||
pub fn from_symbol(x: Symbol) -> Option<Level> { | ||
match x { | ||
sym::allow => Some(Level::Allow), | ||
sym::warn => Some(Level::Warn), | ||
sym::deny => Some(Level::Deny), | ||
sym::forbid => Some(Level::Forbid), | ||
_ => None, | ||
} | ||
} | ||
} |