Skip to content

--pretty typed produces non-scalar casts #13552

Closed

Description

@klutzy
pub struct A;

pub fn f() {
    let _a = A;
}

#[deriving(Clone)]
pub struct B;

rustc --pretty=typed produces:

...

pub struct A;

pub fn f() { let _a = (A as A); }

#[deriving(Clone)]
pub struct B;
#[automatically_derived]
impl ::std::clone::Clone for B {
    #[inline]
    fn clone(&self) -> B {
        (match (*(self as &B) as B) { B => (B as B) } as B)
    }
}

where all as is invalid e.g.

a.rs.rs:5:24: 5:30 error: non-scalar cast: `A` as `A`
a.rs.rs:5 pub fn f() { let _a = (A as A); }
                                 ^~~~~~

Activity

  1. klutzy commented on Apr 16, 2014

    @klutzy
    ContributorAuthor

    We may have to print let _a = A /* as A */ like --pretty identified does.

  2. eddyb commented on Apr 16, 2014

    @eddyb
    Contributor

    I would actually prefer /*: A */ - without being wrapped in a comment where it's valid to have a type hint (locals and closure expressions).

  3. steveklabnik commented on Nov 7, 2015

    @steveklabnik
    Contributor

    pretty=typed doesn't exist anymore.

  4. added a commit that references this issue on Nov 16, 2022
  5. added 2 commits that reference this issue on Feb 13, 2023
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-prettyArea: Pretty printing (including `-Z unpretty`)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions