1 use syntax_pos::{Symbol, sym};
2 pub use self::Level::*;
4 /// Setting for how to handle a lint.
5 #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
7 Allow, Warn, Deny, Forbid,
10 rustc_data_structures::impl_stable_hash_via_hash!(Level);
13 /// Converts a level to a lower-case string.
14 pub fn as_str(self) -> &'static str {
16 Level::Allow => "allow",
17 Level::Warn => "warn",
18 Level::Deny => "deny",
19 Level::Forbid => "forbid",
23 /// Converts a lower-case string to a level.
24 pub fn from_str(x: &str) -> Option<Level> {
26 "allow" => Some(Level::Allow),
27 "warn" => Some(Level::Warn),
28 "deny" => Some(Level::Deny),
29 "forbid" => Some(Level::Forbid),
34 /// Converts a symbol to a level.
35 pub fn from_symbol(x: Symbol) -> Option<Level> {
37 sym::allow => Some(Level::Allow),
38 sym::warn => Some(Level::Warn),
39 sym::deny => Some(Level::Deny),
40 sym::forbid => Some(Level::Forbid),