Skip to content

Commit 9428f2a

Browse files
committed
feat: omit suffixes in const generics (e.g. 1_i32)
Closes #99255
1 parent aa01891 commit 9428f2a

File tree

48 files changed

+189
-180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+189
-180
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1729,7 +1729,7 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
17291729
}
17301730

17311731
fn print_const(self, ct: ty::Const<'tcx>) -> Result<Self::Const, Self::Error> {
1732-
self.pretty_print_const(ct, true)
1732+
self.pretty_print_const(ct, false)
17331733
}
17341734

17351735
fn path_crate(mut self, cnum: CrateNum) -> Result<Self::Path, Self::Error> {

src/test/rustdoc/const-generics/add-impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub struct Simd<T, const WIDTH: usize> {
77
inner: T,
88
}
99

10-
// @has foo/struct.Simd.html '//div[@id="trait-implementations-list"]//h3[@class="code-header in-band"]' 'impl Add<Simd<u8, 16_usize>> for Simd<u8, 16>'
10+
// @has foo/struct.Simd.html '//div[@id="trait-implementations-list"]//h3[@class="code-header in-band"]' 'impl Add<Simd<u8, 16>> for Simd<u8, 16>'
1111
impl Add for Simd<u8, 16> {
1212
type Output = Self;
1313

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "foo"]
22

33
// @has foo/struct.Foo.html '//pre[@class="rust struct"]' \
4-
// 'pub struct Foo<const M: usize = 10_usize, const N: usize = M, T = i32>(_);'
4+
// 'pub struct Foo<const M: usize = 10, const N: usize = M, T = i32>(_);'
55
pub struct Foo<const M: usize = 10, const N: usize = M, T = i32>(T);

src/test/rustdoc/const-generics/const-generics-docs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ pub use extern_crate::WTrait;
1919

2020
// @has foo/trait.Trait.html '//pre[@class="rust trait"]' \
2121
// 'pub trait Trait<const N: usize>'
22-
// @has - '//*[@id="impl-Trait%3C1_usize%3E-for-u8"]//h3[@class="code-header in-band"]' 'impl Trait<1_usize> for u8'
23-
// @has - '//*[@id="impl-Trait%3C2_usize%3E-for-u8"]//h3[@class="code-header in-band"]' 'impl Trait<2_usize> for u8'
22+
// @has - '//*[@id="impl-Trait%3C1%3E-for-u8"]//h3[@class="code-header in-band"]' 'impl Trait<1> for u8'
23+
// @has - '//*[@id="impl-Trait%3C2%3E-for-u8"]//h3[@class="code-header in-band"]' 'impl Trait<2> for u8'
2424
// @has - '//*[@id="impl-Trait%3C{1%20+%202}%3E-for-u8"]//h3[@class="code-header in-band"]' 'impl Trait<{1 + 2}> for u8'
2525
// @has - '//*[@id="impl-Trait%3CN%3E-for-%5Bu8%3B%20N%5D"]//h3[@class="code-header in-band"]' \
2626
// 'impl<const N: usize> Trait<N> for [u8; N]'

src/test/ui-fulldeps/internal-lints/rustc_pass_by_value_self.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ struct WithParameters<T, const N: usize, M = u32> {
4444
}
4545

4646
impl<T> WithParameters<T, 1> {
47-
fn with_ref(&self) {} //~ ERROR passing `WithParameters<T, 1_usize>` by reference
47+
fn with_ref(&self) {} //~ ERROR passing `WithParameters<T, 1>` by reference
4848
}
4949

5050
impl<T> WithParameters<T, 1, u8> {
51-
fn with_ref(&self) {} //~ ERROR passing `WithParameters<T, 1_usize, u8>` by reference
51+
fn with_ref(&self) {} //~ ERROR passing `WithParameters<T, 1, u8>` by reference
5252
}
5353

5454
fn main() {}

src/test/ui-fulldeps/internal-lints/rustc_pass_by_value_self.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ error: passing `Foo` by reference
2222
LL | fn with_ref(&self) {}
2323
| ^^^^^ help: try passing by value: `Foo`
2424

25-
error: passing `WithParameters<T, 1_usize>` by reference
25+
error: passing `WithParameters<T, 1>` by reference
2626
--> $DIR/rustc_pass_by_value_self.rs:47:17
2727
|
2828
LL | fn with_ref(&self) {}
29-
| ^^^^^ help: try passing by value: `WithParameters<T, 1_usize>`
29+
| ^^^^^ help: try passing by value: `WithParameters<T, 1>`
3030

31-
error: passing `WithParameters<T, 1_usize, u8>` by reference
31+
error: passing `WithParameters<T, 1, u8>` by reference
3232
--> $DIR/rustc_pass_by_value_self.rs:51:17
3333
|
3434
LL | fn with_ref(&self) {}
35-
| ^^^^^ help: try passing by value: `WithParameters<T, 1_usize, u8>`
35+
| ^^^^^ help: try passing by value: `WithParameters<T, 1, u8>`
3636

3737
error: aborting due to 5 previous errors
3838

src/test/ui/array-slice-vec/match_arr_unknown_len.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/match_arr_unknown_len.rs:3:9
33
|
44
LL | [1, 2] => true,
5-
| ^^^^^^ expected `2_usize`, found `N`
5+
| ^^^^^^ expected `2`, found `N`
66
|
77
= note: expected array `[u32; 2]`
88
found array `[u32; N]`

src/test/ui/const-generics/associated-type-bound-fail.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0277]: the trait bound `u16: Bar<N>` is not satisfied
44
LL | type Assoc = u16;
55
| ^^^ the trait `Bar<N>` is not implemented for `u16`
66
|
7-
= help: the trait `Bar<3_usize>` is implemented for `u16`
7+
= help: the trait `Bar<3>` is implemented for `u16`
88
note: required by a bound in `Foo::Assoc`
99
--> $DIR/associated-type-bound-fail.rs:4:17
1010
|

src/test/ui/const-generics/defaults/generic-expr-default-concrete.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ error[E0308]: mismatched types
22
--> $DIR/generic-expr-default-concrete.rs:10:5
33
|
44
LL | Foo::<10, 12>
5-
| ^^^^^^^^^^^^^ expected `11_usize`, found `12_usize`
5+
| ^^^^^^^^^^^^^ expected `11`, found `12`
66
|
7-
= note: expected type `11_usize`
8-
found type `12_usize`
7+
= note: expected type `11`
8+
found type `12`
99

1010
error: aborting due to previous error
1111

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
pub struct Example<const N: usize=13>;
2-
pub struct Example2<T=u32, const N: usize=13>(T);
3-
pub struct Example3<const N: usize=13, T=u32>(T);
4-
pub struct Example4<const N: usize=13, const M: usize=4>;
1+
pub struct Example<const N: usize = 13>;
2+
pub struct Example2<T = u32, const N: usize = 13>(T);
3+
pub struct Example3<const N: usize = 13, T = u32>(T);
4+
pub struct Example4<const N: usize = 13, const M: usize = 4>;
55

66
fn main() {
7-
let e: Example::<13> = ();
7+
let e: Example<13> = ();
88
//~^ Error: mismatched types
99
//~| expected struct `Example`
10-
let e: Example2::<u32, 13> = ();
10+
let e: Example2<u32, 13> = ();
1111
//~^ Error: mismatched types
1212
//~| expected struct `Example2`
13-
let e: Example3::<13, u32> = ();
13+
let e: Example3<13, u32> = ();
1414
//~^ Error: mismatched types
1515
//~| expected struct `Example3`
16-
let e: Example3::<7> = ();
16+
let e: Example3<7> = ();
1717
//~^ Error: mismatched types
18-
//~| expected struct `Example3<7_usize>`
19-
let e: Example4::<7> = ();
18+
//~| expected struct `Example3<7>`
19+
let e: Example4<7> = ();
2020
//~^ Error: mismatched types
21-
//~| expected struct `Example4<7_usize>`
21+
//~| expected struct `Example4<7>`
2222
}

0 commit comments

Comments
 (0)