struct ArgContext {
prefix: String,
expected_known: bool,
expected_at_run_time: Option<TokenStream>,
declared: Option<TokenStream>,
r_name: String,
rust_type: String,
nullable: bool,
}Expand description
The R-facing context of one argument’s conversion failure (#1591).
Fields§
§prefix: StringThe message prefix: '<p>' must be <expected> when the type has an
R-facing expectation (crate::r_preconditions::conversion_expectation),
invalid '<p>' argument otherwise. The error’s reason follows it.
expected_known: boolWhether prefix states the expectation. Passed to the probe
(__mx_conversion_err_parts!(e, expected_known)), so a built-in error’s
reason does not repeat it (got character rather than
expected integer, got character).
expected_at_run_time: Option<TokenStream>An expression yielding the expectation (a String) on the failure
path, when the macro knows it but not its text: the choices of a
match_arg type under an Either<.., R> layer come from
MatchArg::CHOICES. Takes the place of prefix.
declared: Option<TokenStream>An expression yielding what the argument’s type declares (an
Option<String>) on the failure path, when the macro has no wording
for it: set by ArgContext::with_declared where the binding
converts with TryFromSexp, and tried before the error’s own
expectation (declared_expectation).
r_name: StringThe R formal’s name, e$param.
rust_type: StringThe Rust type as written in the signature, e$rust_type: kept for the
package author, out of the user-facing message.
nullable: boolWhether the value may be NULL (an Option<_>, under any Missing):
an expectation the error supplies at run time then reads
NULL or <expected>. Only used when expected_known is false.
Implementations§
Source§impl ArgContext
impl ArgContext
Sourcefn new(r_name: &str, ty: &Type, coerced: bool) -> Self
fn new(r_name: &str, ty: &Type, coerced: bool) -> Self
The context of parameter r_name of type ty; coerced when the
coerce knob applies to it (the expectation widens with the gate).
Sourcefn strict(r_name: &str, ty: &Type) -> Self
fn strict(r_name: &str, ty: &Type) -> Self
The context of a strict lossy-integer parameter (#1594): the
expectation names what strict accepts, a whole number, since a
logical, raw or fractional input is refused.
fn with_expectation(r_name: &str, ty: &Type, expected: Option<String>) -> Self
Sourcefn with_declared(&self, ty: &Type) -> Self
fn with_declared(&self, ty: &Type) -> Self
This context for a binding that converts ty with TryFromSexp: when
the macro has no wording for the type, the failure path asks the type
what it declares (declared_expectation). Only there is
ty: TryFromSexp known; the other conversion paths (a several_ok
Vec<Mode>, a coercion helper) may name a type that has no impl. An
impl Trait type gets no lookup: it cannot name a path, and its
binding is already the compile error.
Sourcefn with_inferred(&self, target: &Ident) -> Self
fn with_inferred(&self, target: &Ident) -> Self
ArgContext::with_declared for a copied trait signature (#2123):
the witness target names the type the method takes.
Sourcefn either_choice(r_name: &str, ty: &Type, leaf: &ChoiceLeaf) -> Option<Self>
fn either_choice(r_name: &str, ty: &Type, leaf: &ChoiceLeaf) -> Option<Self>
The context of a choice parameter of type ty decoded as leaf, when
the type has an Either<.., R> layer; None otherwise. A value R
refuses is reported against the whole parameter, in the words of its
@param line: 'route' must be one of "oral", "bolus", or a data frame (one or more of for several_ok, , a data frame, or NULL
under Option). The choices are MatchArg::CHOICES for a match_arg
type, followed by its listed MatchArg::ALIASES ((or "po" for "oral"), #2148), and the literal list for choices(...), which has
no aliases; the R arm is named by its @param noun
(crate::type_inspect::r_value_noun). The error then supplies only
the reason (got integer).
Trait Implementations§
Auto Trait Implementations§
impl !Send for ArgContext
impl !Sync for ArgContext
impl Freeze for ArgContext
impl RefUnwindSafe for ArgContext
impl Unpin for ArgContext
impl UnsafeUnpin for ArgContext
impl UnwindSafe for ArgContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> SizeHint for Twhere
T: ?Sized,
impl<T> SizeHint for Twhere
T: ?Sized,
Source§default fn lower_bound(&self) -> usize
default fn lower_bound(&self) -> usize
core_io_internals)[u8; 12] could return any value between 0 and
12 inclusively as a correct implementation. Read moreSource§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read moreLayout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 144 bytes