Skip to content

Commit

Permalink
Avoid using Symbol::intern
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro committed Jun 19, 2020
1 parent 5ac191d commit 3b7fd26
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ bytecount = "0.6"
dunce = "1.0"
ignore = "0.4.11"
itertools = "0.8"
lazy_static = "1.0.0"
log = "0.4"
regex = "1.0"
thiserror = "1.0"
Expand All @@ -104,6 +103,7 @@ toml = { version = "0.5", optional = true }

[dev-dependencies]
env_logger = "0.7"
lazy_static = "1.0.0"

[dependencies.rustc_ast]
package = "rustc-ap-rustc_ast"
Expand Down
8 changes: 2 additions & 6 deletions src/formatting/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ mod visitor;

type FileModMap<'ast> = BTreeMap<FileName, Module<'ast>>;

lazy_static! {
static ref CFG_IF: Symbol = Symbol::intern("cfg_if");
}

/// Represents module with its inner attributes.
#[derive(Debug, Clone)]
pub(crate) struct Module<'a> {
Expand Down Expand Up @@ -479,8 +475,8 @@ fn find_path_value(attrs: &[ast::Attribute]) -> Option<Symbol> {
fn is_cfg_if(item: &ast::Item) -> bool {
match item.kind {
ast::ItemKind::MacCall(ref mac) => {
if let Some(first_segment) = mac.path.segments.first() {
if first_segment.ident.name == *CFG_IF {
if let Some(last_segment) = mac.path.segments.last() {
if last_segment.ident.name.as_str() == "cfg_if" {
return true;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/formatting/modules/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ impl<'a, 'ast: 'a> CfgIfVisitor<'a> {
// extern crate cfg_if;
// cfg_if! {..}
// ```
match mac.path.segments.first() {
Some(first_segment) => {
if first_segment.ident.name != Symbol::intern("cfg_if") {
match mac.path.segments.last() {
Some(last_segment) => {
if last_segment.ident.name != Symbol::intern("cfg_if") {
return Err("Expected cfg_if");
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#![warn(unreachable_pub)]
#![feature(cell_leak)]

#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;

Expand Down

0 comments on commit 3b7fd26

Please sign in to comment.