Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,15 +550,15 @@ impl<'i: 't, 't> Parser<'i, 't> {
/// `.seen_var_or_env_functions()` method.)
#[inline]
pub fn look_for_var_or_env_functions(&mut self) {
self.input.tokenizer.look_for_var_or_env_functions()
self.input.tokenizer.look_for_var_env_or_attr_functions()
}

/// Return whether a `var()` or `env()` function has been seen by the
/// tokenizer since either `look_for_var_or_env_functions` was called, and
/// stop looking.
#[inline]
pub fn seen_var_or_env_functions(&mut self) -> bool {
self.input.tokenizer.seen_var_or_env_functions()
self.input.tokenizer.seen_var_env_or_attr_functions()
}

/// The old name of `try_parse`, which requires raw identifiers in the Rust 2018 edition.
Expand Down
20 changes: 10 additions & 10 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ pub struct Tokenizer<'a> {
/// of UTF-16 characters.
current_line_start_position: usize,
current_line_number: u32,
var_or_env_functions: SeenStatus,
var_env_or_attr_functions: SeenStatus,
source_map_url: Option<&'a str>,
source_url: Option<&'a str>,
}
Expand All @@ -235,30 +235,30 @@ impl<'a> Tokenizer<'a> {
position: 0,
current_line_start_position: 0,
current_line_number: 0,
var_or_env_functions: SeenStatus::DontCare,
var_env_or_attr_functions: SeenStatus::DontCare,
source_map_url: None,
source_url: None,
}
}

#[inline]
pub fn look_for_var_or_env_functions(&mut self) {
self.var_or_env_functions = SeenStatus::LookingForThem;
pub fn look_for_var_env_or_attr_functions(&mut self) {
self.var_env_or_attr_functions = SeenStatus::LookingForThem;
}

#[inline]
pub fn seen_var_or_env_functions(&mut self) -> bool {
let seen = self.var_or_env_functions == SeenStatus::SeenAtLeastOne;
self.var_or_env_functions = SeenStatus::DontCare;
pub fn seen_var_env_or_attr_functions(&mut self) -> bool {
let seen = self.var_env_or_attr_functions == SeenStatus::SeenAtLeastOne;
self.var_env_or_attr_functions = SeenStatus::DontCare;
seen
}

#[inline]
pub fn see_function(&mut self, name: &str) {
if self.var_or_env_functions == SeenStatus::LookingForThem
&& (name.eq_ignore_ascii_case("var") || name.eq_ignore_ascii_case("env"))
if self.var_env_or_attr_functions == SeenStatus::LookingForThem
&& (name.eq_ignore_ascii_case("var") || name.eq_ignore_ascii_case("env") || name.eq_ignore_ascii_case("attr"))
{
self.var_or_env_functions = SeenStatus::SeenAtLeastOne;
self.var_env_or_attr_functions = SeenStatus::SeenAtLeastOne;
}
}

Expand Down