X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fcomment.rs;h=9959ef7fd9e8405487b521d0ea918dce35726f86;hb=269584634a7657d1026cee2db1c38d75cebbbd31;hp=c721f07d0199e3e453b9b6c78d0533eaca67bafe;hpb=69cf48344b14f596bcc91db01c24e76b5b2f37ad;p=rust.git diff --git a/src/comment.rs b/src/comment.rs index c721f07d019..9959ef7fd9e 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -3,7 +3,7 @@ use std::{self, borrow::Cow, iter}; use itertools::{multipeek, MultiPeek}; -use syntax::source_map::Span; +use rustc_span::Span; use crate::config::Config; use crate::rewrite::RewriteContext; @@ -91,8 +91,9 @@ pub(crate) fn closer(&self) -> &'a str { | CommentStyle::TripleSlash | CommentStyle::Custom(..) | CommentStyle::Doc => "", - CommentStyle::DoubleBullet => " **/", - CommentStyle::SingleBullet | CommentStyle::Exclamation => " */", + CommentStyle::SingleBullet | CommentStyle::DoubleBullet | CommentStyle::Exclamation => { + " */" + } } } @@ -101,8 +102,9 @@ pub(crate) fn line_start(&self) -> &'a str { CommentStyle::DoubleSlash => "// ", CommentStyle::TripleSlash => "/// ", CommentStyle::Doc => "//! ", - CommentStyle::SingleBullet | CommentStyle::Exclamation => " * ", - CommentStyle::DoubleBullet => " ** ", + CommentStyle::SingleBullet | CommentStyle::DoubleBullet | CommentStyle::Exclamation => { + " * " + } CommentStyle::Custom(opener) => opener, } } @@ -527,7 +529,6 @@ fn new( .checked_sub(closer.len() + opener.len()) .unwrap_or(1); let indent_str = shape.indent.to_string_with_newline(config).to_string(); - let fmt_indent = shape.indent + (opener.len() - line_start.len()); let mut cr = CommentRewrite { result: String::with_capacity(orig.len() * 2), @@ -538,14 +539,14 @@ fn new( comment_line_separator: format!("{}{}", indent_str, line_start), max_width, indent_str, - fmt_indent, + fmt_indent: shape.indent, fmt: StringFormat { opener: "", closer: "", line_start, line_end: "", - shape: Shape::legacy(max_width, fmt_indent), + shape: Shape::legacy(max_width, shape.indent), trim_end: true, config, }, @@ -658,7 +659,7 @@ fn handle_line( config.set().wrap_comments(false); if config.format_code_in_doc_comments() { if let Some(s) = - crate::format_code_block(&self.code_block_buffer, &config) + crate::format_code_block(&self.code_block_buffer, &config, false) { trim_custom_comment_prefix(&s.snippet) } else { @@ -1556,10 +1557,10 @@ pub(crate) fn recover_comment_removed( // We missed some comments. Warn and keep the original text. if context.config.error_on_unformatted() { context.report.append( - context.source_map.span_to_filename(span).into(), + context.parse_sess.span_to_filename(span), vec![FormattingError::from_span( span, - &context.source_map, + &context.parse_sess, ErrorKind::LostComment, )], );