pub struct PragmaState {Show 13 fields
pub strict_vars: bool,
pub strict_subs: bool,
pub strict_refs: bool,
pub warnings: bool,
pub utf8: bool,
pub encoding: Option<String>,
pub unicode_strings: bool,
pub locale: bool,
pub locale_scope: Option<String>,
pub disabled_warning_categories: Vec<String>,
pub signatures_strict: bool,
pub features: Vec<&'static str>,
pub builtin_imports: Vec<String>,
}Expand description
Pragma state at a given point in the code
Fields§
§strict_vars: boolWhether strict vars is enabled
strict_subs: boolWhether strict subs is enabled
strict_refs: boolWhether strict refs is enabled
warnings: boolWhether warnings are enabled (globally)
utf8: boolWhether use utf8 is enabled.
encoding: Option<String>Active source encoding from use encoding.
unicode_strings: boolWhether use feature 'unicode_strings' or a matching feature bundle is enabled.
locale: boolWhether locale-sensitive behavior is enabled.
locale_scope: Option<String>Locale scope from use locale, if any.
disabled_warning_categories: Vec<String>Warning categories explicitly disabled via no warnings 'CATEGORY'.
When no warnings is used with specific category arguments (e.g.
no warnings 'uninitialized'), the global warnings flag stays true
and the disabled categories are recorded here. Only bare no warnings
(no arguments) clears the global warnings flag.
signatures_strict: boolWhether explicit use feature 'signatures' currently implies strictness.
This is tracked separately from the raw strict flags so no feature 'signatures' can unwind the feature-driven implication without
clobbering explicit use strict or version-implied strict state.
features: Vec<&'static str>Effective language features enabled in the current lexical scope.
This starts with any features implied by use vX.Y declarations and is
then updated by explicit use feature / no feature pragmas.
builtin_imports: Vec<String>Lexically imported builtin short names from use builtin.
Implementations§
Source§impl PragmaState
impl PragmaState
Sourcepub fn all_strict() -> PragmaState
pub fn all_strict() -> PragmaState
Create a new pragma state with all strict modes enabled
Sourcepub fn is_warning_active(&self, category: &str) -> bool
pub fn is_warning_active(&self, category: &str) -> bool
Returns true if warnings are active for the given category.
Warnings for a category are active when:
- The global
warningsflag istrue, and - The category is not listed in
disabled_warning_categories.
If the global warnings flag is false (i.e. no warnings with no
arguments was used), all categories are considered inactive regardless of
the disabled_warning_categories list.
Sourcepub fn has_feature(&self, feature: &str) -> bool
pub fn has_feature(&self, feature: &str) -> bool
Returns true if the given feature name is currently enabled.
Sourcepub fn has_builtin_import(&self, name: &str) -> bool
pub fn has_builtin_import(&self, name: &str) -> bool
Returns true when a builtin short name was lexically imported in scope.
Trait Implementations§
Source§impl Clone for PragmaState
impl Clone for PragmaState
Source§fn clone(&self) -> PragmaState
fn clone(&self) -> PragmaState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more