Skip to content

Commit 866f9c5

Browse files
authored
Merge pull request rust-lang#210 from rust-lang/fix/asm-newline
Remove extra newline in asm
2 parents 06b6ec0 + fc56c54 commit 866f9c5

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

failing-ui-tests.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ src/test/ui/allocator/no_std-alloc-error-handler-default.rs
88
src/test/ui/allocator/xcrate-use.rs
99
src/test/ui/allocator/xcrate-use2.rs
1010
src/test/ui/asm/may_unwind.rs
11-
src/test/ui/asm/x86_64/const.rs
12-
src/test/ui/asm/x86_64/issue-96797.rs
1311
src/test/ui/asm/x86_64/multiple-clobber-abi.rs
1412
src/test/ui/async-await/async-fn-size-moved-locals.rs
1513
src/test/ui/async-await/async-fn-size-uninit-locals.rs

failing-ui-tests12.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
src/test/ui/asm/x86_64/issue-96797.rs
12
src/test/ui/intrinsics/const-eval-select-x86_64.rs
23
src/test/ui/packed/packed-struct-drop-aligned.rs
34
src/test/ui/packed/packed-struct-generic-layout.rs

src/asm.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -695,17 +695,16 @@ impl<'gcc, 'tcx> AsmMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
695695
for piece in template {
696696
match *piece {
697697
InlineAsmTemplatePiece::String(ref string) => {
698-
for line in string.lines() {
698+
let mut index = 0;
699+
while index < string.len() {
699700
// NOTE: gcc does not allow inline comment, so remove them.
700-
let line =
701-
if let Some(index) = line.rfind("//") {
702-
&line[..index]
703-
}
704-
else {
705-
line
706-
};
707-
template_str.push_str(line);
708-
template_str.push('\n');
701+
let comment_index = string[index..].find("//")
702+
.map(|comment_index| comment_index + index)
703+
.unwrap_or(string.len());
704+
template_str.push_str(&string[index..comment_index]);
705+
index = string[comment_index..].find('\n')
706+
.map(|index| index + comment_index)
707+
.unwrap_or(string.len());
709708
}
710709
},
711710
InlineAsmTemplatePiece::Placeholder { operand_idx, modifier: _, span: _ } => {

0 commit comments

Comments
 (0)