Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preserve name of type parameter when printing #2951

Closed
nikomatsakis opened this issue Jul 18, 2012 · 5 comments
Closed

preserve name of type parameter when printing #2951

nikomatsakis opened this issue Jul 18, 2012 · 5 comments
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@nikomatsakis
Copy link
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

@catamorphism
Copy link
Contributor

Reproduced as of b60a0be

@graydon
Copy link
Contributor

graydon commented May 8, 2013

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
Copy link
Contributor

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

@graydon
Copy link
Contributor

graydon commented Jun 6, 2013

accepted for production-ready milestone

@pnkfelix
Copy link
Member

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

bors added a commit that referenced this issue Sep 4, 2018
Update RLS and Rustfmt

RLS
* Allow project model to download crates ([#1020](rust-lang/rls#1020))
* Support simple external builds ([#988](rust-lang/rls#988))
* Support using external Rustfmt ([#990](rust-lang/rls#990))

Rustfmt (0.99.4)
* Format chains with comment ([#2899](https://github.com/rust-lang-nursery/rls/pull/2899))
* Do not show wildcard pattern in slice pattern ([#2912](https://github.com/rust-lang-nursery/rls/pull/2912))
* Impl only use ([#2951](https://github.com/rust-lang-nursery/rls/pull/2951))
* ... and [more](rust-lang/rustfmt@5c9a2b6...1c40881)

Bumped in tandem to pull a single version of `rustc-ap-*` libs.

r? @nrc
RalfJung pushed a commit to RalfJung/rust that referenced this issue Jul 8, 2023
cron auto-PR: need to set upstream branch
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Dependency upgrade resulting from `cargo update`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants