Skip to content

preserve name of type parameter when printing #2951

@nikomatsakis

Description

@nikomatsakis
Contributor

Right now type parameters are printed as 'a or 'b where a and b are derived from the index of the type parameter in the list of type parameters. The user gave them names, we should print them! Part of the problem is that they may not be readily available; in the ty_param variant we have the index and the def-id. I guess the latter ought to be enough to recover the name the user gave.

The relevant code is in rustc::util::ppaux

Activity

catamorphism

catamorphism commented on Dec 6, 2012

@catamorphism
Contributor

Reproduced as of b60a0be

graydon

graydon commented on May 8, 2013

@graydon
Contributor

Reproduced with:


fn foo<T>(x: T) -> int {
    return x;
}

fn main() {
    foo("hello");
}

produces error:

3:11: 3:12 error: mismatched types: expected `int` but found `'a` (expected int but found type parameter)
pcwalton

pcwalton commented on May 16, 2013

@pcwalton
Contributor

I don't believe this is backwards incompatible, renominating.

graydon

graydon commented on Jun 6, 2013

@graydon
Contributor

accepted for production-ready milestone

added a commit that references this issue on Jul 10, 2013
e7040e8
pnkfelix

pnkfelix commented on Aug 22, 2013

@pnkfelix
Member

linking to the metabug #3195 so that this ticket gets an entry (with status) in its comments area.

added a commit that references this issue on Jul 8, 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`)E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @graydon@nikomatsakis@pcwalton@pnkfelix@catamorphism

      Issue actions

        preserve name of type parameter when printing · Issue #2951 · rust-lang/rust