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

Do not duplicate const keyword on parameters #4294

Merged
merged 2 commits into from
Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 38 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,32 +107,32 @@ lazy_static = "1.0.0"

[dependencies.rustc_ast]
package = "rustc-ap-rustc_ast"
version = "666.0.0"
version = "667.0.0"

[dependencies.rustc_ast_pretty]
package = "rustc-ap-rustc_ast_pretty"
version = "666.0.0"
version = "667.0.0"

[dependencies.rustc_data_structures]
package = "rustc-ap-rustc_data_structures"
version = "666.0.0"
version = "667.0.0"

[dependencies.rustc_errors]
package = "rustc-ap-rustc_errors"
version = "666.0.0"
version = "667.0.0"

[dependencies.rustc_expand]
package = "rustc-ap-rustc_expand"
version = "666.0.0"
version = "667.0.0"

[dependencies.rustc_parse]
package = "rustc-ap-rustc_parse"
version = "666.0.0"
version = "667.0.0"

[dependencies.rustc_session]
package = "rustc-ap-rustc_session"
version = "666.0.0"
version = "667.0.0"

[dependencies.rustc_span]
package = "rustc-ap-rustc_span"
version = "666.0.0"
version = "667.0.0"
4 changes: 3 additions & 1 deletion src/formatting/spanned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ impl Spanned for ast::Param {

impl Spanned for ast::GenericParam {
fn span(&self) -> Span {
let lo = if self.attrs.is_empty() {
let lo = if let ast::GenericParamKind::Const { ty: _, kw_span } = self.kind {
kw_span.lo()
} else if self.attrs.is_empty() {
self.ident.span.lo()
} else {
self.attrs[0].span.lo()
Expand Down
2 changes: 1 addition & 1 deletion src/formatting/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ impl Rewrite for ast::GenericParam {
_ => {}
}

if let rustc_ast::ast::GenericParamKind::Const { ref ty } = &self.kind {
if let ast::GenericParamKind::Const { ref ty, kw_span: _ } = &self.kind {
result.push_str("const ");
result.push_str(rewrite_ident(context, self.ident));
result.push_str(": ");
Expand Down
8 changes: 8 additions & 0 deletions tests/source/const_generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ type Foo<const N: usize> = [i32; N + 1];
pub trait Foo: Bar<{Baz::COUNT}> {
const ASD: usize;
}

// #4263
fn const_generics_on_params<
// AAAA
const BBBB: usize,
/* CCCC */
const DDDD: usize,
>() {}
9 changes: 9 additions & 0 deletions tests/target/const_generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ type Foo<const N: usize> = [i32; N + 1];
pub trait Foo: Bar<{ Baz::COUNT }> {
const ASD: usize;
}

// #4263
fn const_generics_on_params<
// AAAA
const BBBB: usize,
/* CCCC */
const DDDD: usize,
>() {
}