Skip to content

Commit 1805546

Browse files
committed
Fix const generic parameter save analysis
1 parent bf2f62c commit 1805546

File tree

1 file changed

+12
-6
lines changed
  • src/librustc_save_analysis

1 file changed

+12
-6
lines changed

src/librustc_save_analysis/sig.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -622,12 +622,20 @@ impl Sig for ast::Generics {
622622

623623
let mut defs = Vec::with_capacity(self.params.len());
624624
for param in &self.params {
625-
let mut param_text = param.ident.to_string();
625+
let mut param_text = String::new();
626+
if let ast::GenericParamKind::Const { .. } = param.kind {
627+
param_text.push_str("const ");
628+
}
629+
param_text.push_str(&param.ident.as_str());
626630
defs.push(SigElement {
627631
id: id_from_node_id(param.id, scx),
628632
start: offset + text.len(),
629-
end: offset + text.len() + param_text.len(),
633+
end: offset + text.len() + param_text.as_str().len(),
630634
});
635+
if let ast::GenericParamKind::Const { ref ty } = param.kind {
636+
param_text.push_str(": ");
637+
param_text.push_str(&pprust::ty_to_string(&ty));
638+
}
631639
if !param.bounds.is_empty() {
632640
param_text.push_str(": ");
633641
match param.kind {
@@ -646,10 +654,8 @@ impl Sig for ast::Generics {
646654
param_text.push_str(&pprust::bounds_to_string(&param.bounds));
647655
// FIXME descend properly into bounds.
648656
}
649-
ast::GenericParamKind::Const { ref ty } => {
650-
param_text.push_str(&pprust::bounds_to_string(&param.bounds));
651-
param_text.push_str("= ");
652-
param_text.push_str(&pprust::ty_to_string(&ty));
657+
ast::GenericParamKind::Const { .. } => {
658+
// Const generics cannot contain bounds.
653659
}
654660
}
655661
}

0 commit comments

Comments
 (0)