Skip to content

Commit bd7dc77

Browse files
authored
Rollup merge of #150358 - fee1-dead-contrib:push-utvysrrzsvvm, r=oli-obk
fix rustfmt on `const impl Ty {}` r? `@oli-obk` on rust-lang/rust#148434, cc `@ytmimi` for https://github.com/rust-lang/rust/pull/148434/changes#r2637972310 format_constness_right outputs `" const"` whereas format_constness outputs `"const "` Not making this change to rust-lang/rustfmt since I'm not sure if that repo has these changes yet.
2 parents 751f30f + 107c3f4 commit bd7dc77

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ fn format_impl_ref_and_type(
971971
result.push_str(format_defaultness(of_trait.defaultness));
972972
result.push_str(format_safety(of_trait.safety));
973973
} else {
974-
result.push_str(format_constness_right(*constness));
974+
result.push_str(format_constness(*constness));
975975
}
976976

977977
let shape = if context.config.style_edition() >= StyleEdition::Edition2024 {

tests/source/const_trait.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(trait_alias, const_trait_impl)]
2+
3+
const trait Bar {}
4+
5+
const trait Foo = Bar;
6+
7+
impl const Bar for () {}
8+
9+
// const impl gets reformatted to impl const.. for now
10+
const impl Bar for u8 {}
11+
12+
struct X;
13+
14+
const impl X {}

tests/target/const_trait.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,12 @@
33
const trait Bar {}
44

55
const trait Foo = Bar;
6+
7+
impl const Bar for () {}
8+
9+
// const impl gets reformatted to impl const.. for now
10+
impl const Bar for u8 {}
11+
12+
struct X;
13+
14+
const impl X {}

0 commit comments

Comments
 (0)