Skip to main content

Context

Struct Context 

Source
pub struct Context<'a> {
    pub names: &'a Interner,
    pub target: &'a TargetInfo,
    pub std: Std,
    pub gnu: bool,
    pub pedantic: bool,
    pub permissive: bool,
    pub gnu89_inline: bool,
    pub error_limit: usize,
    pub builtins: bool,
    pub no_builtin: &'a [String],
    pub short_enums: bool,
}
Expand description

What the checking needs and does not change.

Fields§

§names: &'a Interner

The spellings, for the diagnostics that name an identifier.

§target: &'a TargetInfo

What the target’s types are, which every layout and every promotion is decided by.

§std: Std

The dialect.

§gnu: bool

Whether the GNU extensions are on.

§pedantic: bool

Whether -pedantic was given.

§permissive: bool

Whether -fpermissive was given, which is read through Context::promoted.

§gnu89_inline: bool

Whether the whole unit is under GNU’s reading of inline, which is -fgnu89-inline.

§error_limit: usize

How many errors to report before stopping, with zero meaning no limit.

§builtins: bool

Whether a C library function written under its own plain name may be taken to mean that function, which is -fno-builtin and -ffreestanding turned around.

§no_builtin: &'a [String]

The names -fno-builtin-<name> took away one at a time, without the prefix.

§short_enums: bool

Whether an enumeration nothing wrote an underlying type for is represented in the smallest integer type that holds it, which is -fshort-enums.

Implementations§

Source§

impl<'a> Context<'a>

Source

pub fn new(names: &'a Interner, target: &'a TargetInfo, std: Std) -> Context<'a>

A context with the defaults, for a caller that has an interner and a target to hand.

Source

pub fn gnu_inline_by_default(&self) -> bool

Whether a name nothing said gnu_inline about is read GNU’s way all the same.

Two things ask for that and they ask for it for the whole unit rather than for one name. C89 is where the older reading came from and has never had any other, and -fgnu89-inline is how a program written against it says so under a later dialect. The dialect wins where the two meet, so -std=c89 -fno-gnu89-inline leaves the reading alone. gcc refuses that command line instead, and there is nothing else it could have meant.

Source

pub fn means_the_library(&self, name: &str) -> bool

Whether a call to name, written as the program wrote it, may be taken to mean the C library function of that name.

The plain names are the ones the flags are about. A __builtin_ spelling is the program saying which function it means, so -fno-builtin leaves it alone and so does -ffreestanding, which is what lets a freestanding build reach one deliberately.

Source§

impl Context<'_>

Source

pub fn promoted(&self, rule: Promoted) -> Option<Severity>

How to report one of the promoted rules, or None when this dialect has nothing to say about it.

Trait Implementations§

Source§

impl<'a> Clone for Context<'a>

Source§

fn clone(&self) -> Context<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Context<'a>

Source§

impl<'a> Debug for Context<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Context<'a>

§

impl<'a> RefUnwindSafe for Context<'a>

§

impl<'a> Send for Context<'a>

§

impl<'a> Sync for Context<'a>

§

impl<'a> Unpin for Context<'a>

§

impl<'a> UnsafeUnpin for Context<'a>

§

impl<'a> UnwindSafe for Context<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.