Skip to main content

Args

Struct Args 

Source
pub struct Args {
    pub proc_macro: bool,
    pub edition: Option<String>,
    pub deps: Vec<Dependency>,
    pub ui: UiExpectations,
}
Expand description

Arguments accepted by the #[subcrate] attribute, e.g. #[subcrate(proc_macro, edition = "2018", other_subcrate)].

The attribute takes a flat, comma-separated list. Each argument is one of:

  • proc_macro (or proc_macro = true) — compile as a proc-macro crate.
  • edition = "2018" — compile with this edition.
  • path::to::dep — depend on the sibling subcrate at that module path, visible inside this subcrate under the path’s last segment.
  • alias = path::to::dep — the same, visible under alias.
  • ::name (or alias = ::name) — an external crate: one the owning package depends on, or — if name is the package’s own library — the owner crate itself. The build helper has Cargo build it for the subcrate. It is visible inside the subcrate under name (or alias).

The remaining arguments turn the subcrate into a UI test — a build-time assertion about the diagnostics rustc produces for it. Each may be given more than once, and every one must hold (they are combined with AND — e.g. two should_error = "…" require a matching error for each string):

  • should_error — the subcrate must fail to compile. Any should_error makes it expected to fail, so it produces no artifact and its module expands to an empty stand-in. With = "…" an error’s rendered text must also contain that string.
  • should_warn — the subcrate must emit at least one warning. With = "…" a warning’s rendered text must contain that string.
  • should_spanned = "…" — some diagnostic must underline source code equal to this string once whitespace is removed from both sides. (A value is required.)

Fields§

§proc_macro: bool

Compile the module as a proc-macro crate rather than an ordinary library crate.

§edition: Option<String>

Compile the subcrate with this edition instead of the owning package’s.

§deps: Vec<Dependency>

The crates this subcrate links against, in the order written.

§ui: UiExpectations

The UI-test expectations (should_error/should_warn/should_spanned).

Implementations§

Source§

impl Args

Source

pub fn is_ui_test(&self) -> bool

Whether these arguments make the subcrate a UI test (any should_*).

Source

pub fn expects_error(&self) -> bool

Whether the subcrate is expected to fail to compile (any should_error), so it produces no artifact.

Trait Implementations§

Source§

impl Clone for Args

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 Args

Source§

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

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

impl Default for Args

Source§

fn default() -> Self

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

impl Eq for Args

Source§

impl Parse for Args

Source§

fn parse(input: ParseStream<'_>) -> Result<Self>

Source§

impl PartialEq for Args

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Args

Auto Trait Implementations§

§

impl Forget for Args

§

impl Freeze for Args

§

impl Move for Args

§

impl RefUnwindSafe for Args

§

impl Send for Args

§

impl Sync for Args

§

impl Unpin for Args

§

impl UnsafeUnpin for Args

§

impl UnwindSafe for Args

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.