Merge pull request #210 from rust-lang/fix/asm-newline

Remove extra newline in asm
This commit is contained in:
antoyo 2022-08-27 20:50:38 -04:00 committed by GitHub
commit 866f9c527a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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: _ } => {