Skip to content

Miri engine is too permissive with type-changing MIR assignments #70405

Closed

Description

@oli-obk

src.layout.details == dest.layout.details,
just checks whether the layout of the target and value of an assignment is the same. The only time the types can differ is when assigning a &mut T to a &T variable. We should instead employ a function like

fn mir_assign_valid_types(dst: Ty<'tcx>, src: Ty<'tcx>) {
    dst == src || match (&dst.kind, &src.kind) {
        (ty::Ref(_, _, dst_pointee), ty::Ref(_, _, src_pointee)) => dst_pointee == src_pointee,
        _ => false,
    }
}

(source #69700 (comment))

be sure to also add appropriate mutability checks to the patterns (mutable for the source, immutable for the dest)

Activity

  1. added
    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)
    on Mar 25, 2020
  2. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Mar 25, 2020
  3. changed the title [-]Miri engine is too permissive with MIR assignments[/-] [+]Miri engine is too permissive with type-changing MIR assignments[/+] on Mar 26, 2020
  4. added a commit that references this issue on Apr 3, 2020
  5. RalfJung commented on Apr 3, 2020

    @RalfJung
    Member

    @eddyb do we want to keep this open, as you have some future plans for checking subtyping or some such thing?

  6. eddyb commented on Apr 3, 2020

    @eddyb
    Contributor

    I'm not sure, I think we should experiment with deeper lifetime erasure but I likely won't have the time to get involved myself any time soon. Maybe that should have its own issue though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)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

      Issue actions