diff options
| author | antoyo <antoyo@users.noreply.github.com> | 2022-08-27 20:50:38 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-27 20:50:38 -0400 |
| commit | 866f9c527a2c9e5c7cbde97fc515ffcebdcbee6d (patch) | |
| tree | 427cd12364bc1cc8f056571571aa290477a4fd4d /src | |
| parent | 06b6ec0ebe6ae9322f53b32c7c851899d7e99cd7 (diff) | |
| parent | fc56c544165d02e589369a97076ec64fe627a6b5 (diff) | |
| download | rust-866f9c527a2c9e5c7cbde97fc515ffcebdcbee6d.tar.gz rust-866f9c527a2c9e5c7cbde97fc515ffcebdcbee6d.zip | |
Merge pull request #210 from rust-lang/fix/asm-newline
Remove extra newline in asm
Diffstat (limited to 'src')
| -rw-r--r-- | src/asm.rs | 19 |
1 files changed, 9 insertions, 10 deletions
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 @@ impl<'gcc, 'tcx> AsmMethods<'tcx> for CodegenCx<'gcc, 'tcx> { 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: _ } => { |
