]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/rustfmt/src/comment.rs
Rollup merge of #97908 - iago-lito:stabilize_nonzero_checked_ops_constness, r=scottmcm
[rust.git] / src / tools / rustfmt / src / comment.rs
index f9d8a0fa70c00fb6538e76c42af0698d7e2a043b..4d565afc1e0266c7544f2a5be85912856c26cd98 100644 (file)
@@ -730,6 +730,10 @@ fn handle_line(
                     {
                         let mut config = self.fmt.config.clone();
                         config.set().wrap_comments(false);
+                        let comment_max_width = config
+                            .doc_comment_code_block_width()
+                            .min(config.max_width());
+                        config.set().max_width(comment_max_width);
                         if let Some(s) =
                             crate::format_code_block(&self.code_block_buffer, &config, false)
                         {
@@ -796,7 +800,7 @@ fn handle_line(
         // 1) wrap_comments = true is configured
         // 2) The comment is not the start of a markdown header doc comment
         // 3) The comment width exceeds the shape's width
-        // 4) No URLS were found in the commnet
+        // 4) No URLS were found in the comment
         let should_wrap_comment = self.fmt.config.wrap_comments()
             && !is_markdown_header_doc_comment
             && unicode_str_width(line) > self.fmt.shape.width