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

Rustfmt destroys extern types that have generics or rhs #4159

Closed
dtolnay opened this issue May 8, 2020 · 0 comments · Fixed by #4164
Closed

Rustfmt destroys extern types that have generics or rhs #4159

dtolnay opened this issue May 8, 2020 · 0 comments · Fixed by #4164
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@dtolnay
Copy link
Member

dtolnay commented May 8, 2020

Repro as of current master (2da4f63):

$ echo 'extern "Rust" { type T = crate::U; }' | cargo run --bin rustfmt
extern "Rust" {
    type T;
}

The = crate::U is silently dropped.

Similarly this test case in the compiler test suite gets destroyed.

- type A: Ord;
- type A<'a> where 'a: 'static;
- type A<T: Ord> where T: 'static;
- type A = u8;
- type A<'a: 'static, T: Ord + 'static>: Eq + PartialEq where T: 'static + Copy = Vec<u8>;
+ type A;
+ type A;
+ type A;
+ type A;
+ type A;

Relevant to me because I need this syntax for dtolnay/cxx#99.

@topecongiro topecongiro added the bug Panic, non-idempotency, invalid code, etc. label May 8, 2020
ayazhafiz added a commit to ayazhafiz/rustfmt that referenced this issue May 9, 2020
Previously, non-trivial type aliases in extern blocks were dropped by
rustfmt because only the type alias name would be passed to a rewritter.
This commit fixes that by passing all type information (generics,
bounds, and assignments) to a type alias rewritter, and consolidates
`rewrite_type_alias` and `rewrite_associated_type` as one function.

Closes rust-lang#4159
bradleypmartin pushed a commit to bradleypmartin/rustfmt that referenced this issue May 25, 2020
Previously, non-trivial type aliases in extern blocks were dropped by
rustfmt because only the type alias name would be passed to a rewritter.
This commit fixes that by passing all type information (generics,
bounds, and assignments) to a type alias rewritter, and consolidates
`rewrite_type_alias` and `rewrite_associated_type` as one function.

Closes rust-lang#4159
facebook-github-bot pushed a commit to facebook/sapling that referenced this issue Sep 8, 2020
Summary:
Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14).

This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade.

 ---

*Why now?* **:** The 1.x branch is no longer being developed and fixes like rust-lang/rustfmt#4159 (which we need in fbcode) only land to the 2.0 branch.

 ---

Reviewed By: zertosh

Differential Revision: D23568779

fbshipit-source-id: 477200f35b280a4f6471d8e574e37e5f57917baf
facebook-github-bot pushed a commit to facebook/flipper that referenced this issue Sep 8, 2020
Summary:
Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14).

This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade.

 ---

*Why now?* **:** The 1.x branch is no longer being developed and fixes like rust-lang/rustfmt#4159 (which we need in fbcode) only land to the 2.0 branch.

 ---

Reviewed By: zertosh

Differential Revision: D23568784

fbshipit-source-id: 7401066bfc99390686eb3fd9dc6f9888ccef9487
facebook-github-bot pushed a commit to facebook/watchman that referenced this issue Sep 8, 2020
Summary:
Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14).

This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade.

 ---

*Why now?* **:** The 1.x branch is no longer being developed and fixes like rust-lang/rustfmt#4159 (which we need in fbcode) only land to the 2.0 branch.

 ---

Reviewed By: zertosh

Differential Revision: D23568787

fbshipit-source-id: 4f0a79389143369493564dde4233566d3574c86f
facebook-github-bot pushed a commit to facebookincubator/below that referenced this issue Sep 8, 2020
Summary:
Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14).

This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade.

 ---

*Why now?* **:** The 1.x branch is no longer being developed and fixes like rust-lang/rustfmt#4159 (which we need in fbcode) only land to the 2.0 branch.

 ---

Reviewed By: zertosh

Differential Revision: D23568787

fbshipit-source-id: 4f0a79389143369493564dde4233566d3574c86f
facebook-github-bot pushed a commit to facebook/fbthrift that referenced this issue Sep 8, 2020
Summary:
Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14).

This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade.

 ---

*Why now?* **:** The 1.x branch is no longer being developed and fixes like rust-lang/rustfmt#4159 (which we need in fbcode) only land to the 2.0 branch.

 ---

Reviewed By: zertosh

Differential Revision: D23568787

fbshipit-source-id: 4f0a79389143369493564dde4233566d3574c86f
facebook-github-bot pushed a commit to facebookexperimental/rust-shed that referenced this issue Sep 8, 2020
Summary:
Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14).

This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade.

 ---

*Why now?* **:** The 1.x branch is no longer being developed and fixes like rust-lang/rustfmt#4159 (which we need in fbcode) only land to the 2.0 branch.

 ---

Reviewed By: zertosh

Differential Revision: D23568786

fbshipit-source-id: e9beea000c76f0683b8e817ee198eed88e5737f1
facebook-github-bot pushed a commit to facebookincubator/reindeer that referenced this issue Sep 8, 2020
Summary:
Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14).

This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade.

 ---

*Why now?* **:** The 1.x branch is no longer being developed and fixes like rust-lang/rustfmt#4159 (which we need in fbcode) only land to the 2.0 branch.

 ---

Reviewed By: zertosh

Differential Revision: D23568786

fbshipit-source-id: e9beea000c76f0683b8e817ee198eed88e5737f1
facebook-github-bot pushed a commit to facebook/sapling that referenced this issue Sep 8, 2020
Summary:
Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14).

This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade.

 ---

*Why now?* **:** The 1.x branch is no longer being developed and fixes like rust-lang/rustfmt#4159 (which we need in fbcode) only land to the 2.0 branch.

 ---

Reviewed By: StanislavGlebik

Differential Revision: D23568780

fbshipit-source-id: b4b4a0aa683d236e2fdeb5b96d723ac2d84b9faf
facebook-github-bot pushed a commit to facebook/hhvm that referenced this issue Sep 8, 2020
Summary:
Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14).

This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade.

 ---

*Why now?* **:** The 1.x branch is no longer being developed and fixes like rust-lang/rustfmt#4159 (which we need in fbcode) only land to the 2.0 branch.

 ---

Reviewed By: shiqicao

Differential Revision: D23568783

fbshipit-source-id: ccac998bb5edb272b16e9b0b1ad2339e60dad21a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants