Skip to content

Are those Reference parts completely wrong/outdated? #1587

Closed
@WiktorPrzetacznik

Description

@WiktorPrzetacznik
  1. Path patterns (src):

Qualified path patterns can only refer to associated constants

How about this? -> <Enum>::A
Couldn't this be used as a qualified path pattern, for example in match arms?


  1. Trait bounds (src):

Bounds that don't use the item's parameters or higher-ranked lifetimes are checked when the item is defined. It is an error for such a bound to be false

This below is not checked on definition:

// Compiles on its own
//             vvvvvvv higher-ranked trait bound (HRTB)
fn foo() where for<'a> String: Copy {}

fn main() {
    // error to call it (this is where the HRTB is checked)
    foo();
}

And this is checked on definition:

struct A<'a, T>
where
    i32: Iterator,          // Error: `i32` is not an iterator
{
    f: &'a T,
}

fn main() {
}

So it looks like bounds that don't use the item's parameters are checked on definition, but higher-ranked lifetimes are not.


  1. Temporary scopes (src):

Apart from lifetime extension, the temporary scope of an expression is the smallest scope that contains the expression and is one of the following:
(...)

  • The second operand of a lazy boolean expression.

It looks like LHS is a temporary scope, too.
Playground example provided by @CAD97 from rust.internals

(forum discussion)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions