From fc56c544165d02e589369a97076ec64fe627a6b5 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 27 Aug 2022 12:12:06 -0400 Subject: [PATCH] Remove extra newline in asm --- failing-ui-tests.txt | 2 -- failing-ui-tests12.txt | 1 + src/asm.rs | 19 +++++++++---------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/failing-ui-tests.txt b/failing-ui-tests.txt index 6d36c963013..9e88859593d 100644 --- a/failing-ui-tests.txt +++ b/failing-ui-tests.txt @@ -8,8 +8,6 @@ src/test/ui/allocator/no_std-alloc-error-handler-default.rs src/test/ui/allocator/xcrate-use.rs src/test/ui/allocator/xcrate-use2.rs src/test/ui/asm/may_unwind.rs -src/test/ui/asm/x86_64/const.rs -src/test/ui/asm/x86_64/issue-96797.rs src/test/ui/asm/x86_64/multiple-clobber-abi.rs src/test/ui/async-await/async-fn-size-moved-locals.rs src/test/ui/async-await/async-fn-size-uninit-locals.rs diff --git a/failing-ui-tests12.txt b/failing-ui-tests12.txt index d0d8a08421a..2aab9c80f8f 100644 --- a/failing-ui-tests12.txt +++ b/failing-ui-tests12.txt @@ -1,3 +1,4 @@ +src/test/ui/asm/x86_64/issue-96797.rs src/test/ui/intrinsics/const-eval-select-x86_64.rs src/test/ui/packed/packed-struct-drop-aligned.rs src/test/ui/packed/packed-struct-generic-layout.rs diff --git a/src/asm.rs b/src/asm.rs index eb37488a6c5..9d9b6a23d07 100644 --- a/src/asm.rs +++ b/src/asm.rs @@ -695,17 +695,16 @@ fn codegen_global_asm(&self, template: &[InlineAsmTemplatePiece], operands: &[Gl for piece in template { match *piece { InlineAsmTemplatePiece::String(ref string) => { - for line in string.lines() { + let mut index = 0; + while index < string.len() { // NOTE: gcc does not allow inline comment, so remove them. - let line = - if let Some(index) = line.rfind("//") { - &line[..index] - } - else { - line - }; - template_str.push_str(line); - template_str.push('\n'); + let comment_index = string[index..].find("//") + .map(|comment_index| comment_index + index) + .unwrap_or(string.len()); + template_str.push_str(&string[index..comment_index]); + index = string[comment_index..].find('\n') + .map(|index| index + comment_index) + .unwrap_or(string.len()); } }, InlineAsmTemplatePiece::Placeholder { operand_idx, modifier: _, span: _ } => {