Enum rustc_ast_lowering::AnonymousLifetimeMode[−][src]

pub(crate) enum AnonymousLifetimeMode {
    CreateParameter,
    ReportError,
    PassThrough,
}
Expand description

What to do when we encounter an anonymous lifetime reference. Anonymous lifetime references come in two flavors. You have implicit, or fully elided, references to lifetimes, like the one in &T or Ref<T>, and you have '_ lifetimes, like &'_ T or Ref<'_, T>. These often behave the same, but not always:

  • certain usages of implicit references are deprecated, like Ref<T>, and we sometimes just give hard errors in those cases as well.
  • for object bounds there is a difference: Box<dyn Foo> is not the same as Box<dyn Foo + '_>.

We describe the effects of the various modes in terms of three cases:

  • Modern – includes all uses of '_, but also the lifetime arg of a & (e.g., the missing lifetime in something like &T)
  • Dyn Bound – if you have something like Box<dyn Foo>, there is an elided lifetime bound (Box<dyn Foo + 'X>). These elided bounds follow special rules. Note that this only covers cases where nothing is written; the '_ in Box<dyn Foo + '_> is a case of “modern” elision.
  • Deprecated – this covers cases like Ref<T>, where the lifetime parameter to ref is completely elided. Ref<'_, T> would be the modern, non-deprecated equivalent.

Currently, the handling of lifetime elision is somewhat spread out between HIR lowering and – as described below – the resolve_lifetime module. Often we “fallthrough” to that code by generating an “elided” or “underscore” lifetime name. In the future, we probably want to move everything into HIR lowering.

Variants

CreateParameter
Expand description

For Modern cases, create a new anonymous region parameter and reference that.

For Dyn Bound cases, pass responsibility to resolve_lifetime code.

For Deprecated cases, report an error.

ReportError
Expand description

Give a hard error when either & or '_ is written. Used to rule out things like where T: Foo<'_>. Does not imply an error on default object bounds (e.g., Box<dyn Foo>).

PassThrough
Expand description

Pass responsibility to resolve_lifetime code for all cases.

Trait Implementations

impl Clone for AnonymousLifetimeMode[src]

fn clone(&self) -> AnonymousLifetimeMode[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for AnonymousLifetimeMode[src]

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

Formats the value using the given formatter. Read more

impl Copy for AnonymousLifetimeMode[src]

Auto Trait Implementations

impl RefUnwindSafe for AnonymousLifetimeMode

impl Send for AnonymousLifetimeMode

impl Sync for AnonymousLifetimeMode

impl Unpin for AnonymousLifetimeMode

impl UnwindSafe for AnonymousLifetimeMode

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<'tcx, T> ArenaAllocatable<'tcx, ()> for T where
    T: Copy, 
[src]

pub fn allocate_on(Self, &'a Arena<'tcx>) -> &'a mut T[src]

pub fn allocate_from_iter(
    &'a Arena<'tcx>,
    impl IntoIterator<Item = T>
) -> &'a mut [T]
[src]

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone, 
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<'a, T> Captures<'a> for T where
    T: ?Sized, 
[src]