Skip to content

we still sometimes permit coercion into ! #50350

@nikomatsakis

Description

@nikomatsakis
Contributor

While looking into the precise behavior around ! for #47291, we realized that we still sometimes permit coercion into !, in the coerce_lub code:

// Any expression that produces a value of type `!` must have diverged
if ty.is_never() {
self.diverges.set(self.diverges.get() | Diverges::Always);
}

@arielb1 tried to remove that earlier #45880 but we missed this case.

Activity

added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Apr 30, 2018
nikomatsakis

nikomatsakis commented on Apr 30, 2018

@nikomatsakis
ContributorAuthor
nikomatsakis

nikomatsakis commented on Apr 30, 2018

@nikomatsakis
ContributorAuthor

It'd be nice to remove this paragraph from the comment on the diverges field, too:

    /// - To permit assignment into a local variable or other place
    ///   (including the "return slot") of type `!`.  This is allowed
    ///   if **either** the type of value being assigned is `!`, which
    ///   means the current code is dead, **or** the expression's
    ///   diverging flag is true, which means that a diverging value was
    ///   wrapped (e.g., `let x: ! = foo(return)`).
nikomatsakis

nikomatsakis commented on Apr 30, 2018

@nikomatsakis
ContributorAuthor

cc @varkor -- who may do this =)

self-assigned this
on Apr 30, 2018
added a commit that references this issue on May 1, 2018
1ecbdc3
added a commit that references this issue on May 15, 2018
eca0da5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @nikomatsakis@varkor

      Issue actions

        we still sometimes permit coercion into `!` · Issue #50350 · rust-lang/rust