Skip to content
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
3 changes: 2 additions & 1 deletion src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,6 @@ pub(crate) fn format_impl(
context: &RewriteContext<'_>,
item: &ast::Item,
offset: Indent,
where_span_end: Option<BytePos>,
) -> Option<String> {
if let ast::ItemKind::Impl(_, _, _, ref generics, _, ref self_ty, ref items) = item.node {
let mut result = String::with_capacity(128);
Expand All @@ -691,6 +690,8 @@ pub(crate) fn format_impl(
option.compress_where();
}

let misssing_span = mk_sp(self_ty.span.hi(), item.span.hi());
let where_span_end = context.snippet_provider.opt_span_before(misssing_span, "{");
let where_clause_str = rewrite_where_clause(
context,
&generics.where_clause,
Expand Down
9 changes: 2 additions & 7 deletions src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use syntax::source_map::{self, BytePos, Pos, SourceMap, Span};
use syntax::{ast, visit};

use crate::attr::*;
use crate::comment::{CodeCharKind, CommentCodeSlices, FindUncommented};
use crate::comment::{CodeCharKind, CommentCodeSlices};
use crate::config::file_lines::FileName;
use crate::config::{BraceStyle, Config, Version};
use crate::expr::{format_expr, ExprType};
Expand Down Expand Up @@ -359,13 +359,8 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
match item.node {
ast::ItemKind::Use(ref tree) => self.format_import(item, tree),
ast::ItemKind::Impl(..) => {
let snippet = self.snippet(item.span);
let where_span_end = snippet
.find_uncommented("{")
.map(|x| BytePos(x as u32) + source!(self, item.span).lo());
let block_indent = self.block_indent;
let rw = self
.with_context(|ctx| format_impl(&ctx, item, block_indent, where_span_end));
let rw = self.with_context(|ctx| format_impl(&ctx, item, block_indent));
self.push_rewrite(item.span, rw);
}
ast::ItemKind::Trait(..) => {
Expand Down
4 changes: 4 additions & 0 deletions tests/target/issue-3554.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![feature(const_generics)]

pub struct S<const N: usize>;
impl S<{ 0 }> {}