Skip to content

Commit cccf7fe

Browse files
authored
Do not duplicate const keyword on parameters (#4294)
2 parents 8fb4fa5 + 7259619 commit cccf7fe

File tree

6 files changed

+67
-48
lines changed

6 files changed

+67
-48
lines changed

Diff for: Cargo.lock

+38-38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+8-8
Original file line numberDiff line numberDiff line change
@@ -107,32 +107,32 @@ lazy_static = "1.0.0"
107107

108108
[dependencies.rustc_ast]
109109
package = "rustc-ap-rustc_ast"
110-
version = "666.0.0"
110+
version = "667.0.0"
111111

112112
[dependencies.rustc_ast_pretty]
113113
package = "rustc-ap-rustc_ast_pretty"
114-
version = "666.0.0"
114+
version = "667.0.0"
115115

116116
[dependencies.rustc_data_structures]
117117
package = "rustc-ap-rustc_data_structures"
118-
version = "666.0.0"
118+
version = "667.0.0"
119119

120120
[dependencies.rustc_errors]
121121
package = "rustc-ap-rustc_errors"
122-
version = "666.0.0"
122+
version = "667.0.0"
123123

124124
[dependencies.rustc_expand]
125125
package = "rustc-ap-rustc_expand"
126-
version = "666.0.0"
126+
version = "667.0.0"
127127

128128
[dependencies.rustc_parse]
129129
package = "rustc-ap-rustc_parse"
130-
version = "666.0.0"
130+
version = "667.0.0"
131131

132132
[dependencies.rustc_session]
133133
package = "rustc-ap-rustc_session"
134-
version = "666.0.0"
134+
version = "667.0.0"
135135

136136
[dependencies.rustc_span]
137137
package = "rustc-ap-rustc_span"
138-
version = "666.0.0"
138+
version = "667.0.0"

Diff for: src/formatting/spanned.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ impl Spanned for ast::Param {
117117

118118
impl Spanned for ast::GenericParam {
119119
fn span(&self) -> Span {
120-
let lo = if self.attrs.is_empty() {
120+
let lo = if let ast::GenericParamKind::Const { ty: _, kw_span } = self.kind {
121+
kw_span.lo()
122+
} else if self.attrs.is_empty() {
121123
self.ident.span.lo()
122124
} else {
123125
self.attrs[0].span.lo()

Diff for: src/formatting/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ impl Rewrite for ast::GenericParam {
559559
_ => {}
560560
}
561561

562-
if let rustc_ast::ast::GenericParamKind::Const { ref ty } = &self.kind {
562+
if let ast::GenericParamKind::Const { ref ty, kw_span: _ } = &self.kind {
563563
result.push_str("const ");
564564
result.push_str(rewrite_ident(context, self.ident));
565565
result.push_str(": ");

Diff for: tests/source/const_generics.rs

+8
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,11 @@ type Foo<const N: usize> = [i32; N + 1];
3434
pub trait Foo: Bar<{Baz::COUNT}> {
3535
const ASD: usize;
3636
}
37+
38+
// #4263
39+
fn const_generics_on_params<
40+
// AAAA
41+
const BBBB: usize,
42+
/* CCCC */
43+
const DDDD: usize,
44+
>() {}

Diff for: tests/target/const_generics.rs

+9
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,12 @@ type Foo<const N: usize> = [i32; N + 1];
2626
pub trait Foo: Bar<{ Baz::COUNT }> {
2727
const ASD: usize;
2828
}
29+
30+
// #4263
31+
fn const_generics_on_params<
32+
// AAAA
33+
const BBBB: usize,
34+
/* CCCC */
35+
const DDDD: usize,
36+
>() {
37+
}

0 commit comments

Comments
 (0)