Skip to main content

Options

Struct Options 

Source
pub struct Options {
    pub standard: Standard,
    pub dialect: Dialect,
    pub dollar_in_identifiers: bool,
    pub include_paths: Vec<PathBuf>,
    pub system_include: System,
    pub target: TargetModel,
    pub target_source: TargetSource,
    pub complex: bool,
}
Expand description

Knobs for one macro expansion.

Not Copy, because Options::include_paths owns its list; the front end clones it once per invocation.

Fields§

§standard: Standard

Which standard to accept.

§dialect: Dialect

Whether the plain-spelled GNU extensions are switched on, and whether a feature of a newer revision is accepted silently. See Dialect.

§dollar_in_identifiers: bool

Accept $ in identifiers, like GCC’s -fdollars-in-identifiers.

On by default, which is where GCC and Clang both keep it: WG14 DR027 lets an implementation put characters outside the basic source character set into an identifier, GCC takes $ unconditionally, and Clang takes it with a warning that only -pedantic-errors promotes. A $ that reaches the generated Rust — which has no such spelling — is written _dollar_ there, and the C name is what the symbol still links by.

§include_paths: Vec<PathBuf>

Directories #include searches, after the ones the unit itself names with #pragma cinrs include_path and before the bundled headers.

This is the programmatic way in; see crate::include for the whole search order and for the CINRS_INCLUDE_PATH environment variable, which comes last.

§system_include: System

Whether #include also searches the platform’s own directories, and where in the order they go.

Off by default, which is what keeps a unit self-contained and portable across target models. analyze replaces this with what include::SYSTEM_ENV_VAR says when the caller left it at include::System::Off, and the unit’s own #pragma cinrs system_include replaces it again; see include for the whole order and for the directories themselves.

§target: TargetModel

The data model the generated code is compiled for.

Defaults to the host’s, which analyze replaces with the one TARGET_ENV_VAR names and the unit’s own #pragma cinrs target replaces again; see target for the order. Whatever it ends up being, the expansion states it — the const _: () = { assert!(…); }; block every unit opens with is built from this model, so a unit expanded for one data model and compiled for another fails to compile.

Setting it directly — Options::for_target is the tidy way — marks Options::target_source Explicit, and the environment variable is then left alone.

§target_source: TargetSource

Where Options::target came from, which the diagnostics name.

§complex: bool

Whether the complex types are available.

Defaults to COMPLEX_SUPPORTED, which is this crate’s complex feature — the one the cinrs crate turns on to supply the cinrs-rt runtime the generated code names. With it off, _Complex is a diagnostic, __STDC_NO_COMPLEX__ is predefined, and nothing generated needs more than core. The front end carries the support either way, so a test may set this in either direction.

Implementations§

Source§

impl Options

Source

pub fn new(standard: Standard) -> Self

Default options for standard, in the strict ISO dialect.

Source

pub fn gnu(standard: Standard) -> Self

Default options for standard in the GNU dialect — what gnu99! and friends use.

Source

pub fn with_dialect(standard: Standard, dialect: Dialect) -> Self

Default options for standard in dialect.

Source

pub fn with_complex(self, complex: bool) -> Self

These options with the complex types switched on or off; see Options::complex.

Source

pub fn for_target(self, target: TargetModel) -> Self

These options with target set, and marked as the caller’s choice so that TARGET_ENV_VAR does not override it.

What a test that wants the ILP32 or LLP64 rules uses; a unit still overrides it with #pragma cinrs target.

Source

pub fn macro_name(&self) -> &'static str

The macro that selects this entry point, as a diagnostic names it.

Source

pub fn origin(&self) -> Origin

The origin a real expansion of this entry point has: the names the invocation may be written with, and the crate directory Cargo names.

This is what the procedural macros hand to expand_with, and the only thing that lets capture find the invocation in the crate’s sources when the host reports no positions. expand and analyze deliberately do not use it; see Origin.

Source

pub fn include_origin(&self) -> Origin

The same for the include_…! entry point of this standard and dialect.

Source

pub fn gating(&self) -> Gating

How a pass gates the features of a newer revision.

Trait Implementations§

Source§

impl Clone for Options

Source§

fn clone(&self) -> Self

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 Debug for Options

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Options

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<&Options> for LexOptions

Source§

fn from(o: &Options) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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.