MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / line_with_location

Method line_with_location

cranelift/srcgen/src/lib.rs:141–151  ·  view source on GitHub ↗

Add an indented lin with a given a `location` appended as a comment to the line (this is useful for identifying where a line was generated).

(&mut self, contents: impl AsRef<str>, location: FileLocation)

Source from the content-addressed store, hash-verified

139 /// Add an indented lin with a given a `location` appended as a comment to
140 /// the line (this is useful for identifying where a line was generated).
141 pub fn line_with_location(&mut self, contents: impl AsRef<str>, location: FileLocation) {
142 let indent = self.get_indent();
143 let contents = contents.as_ref();
144 let indented_line = if self.lang.should_append_location(contents) {
145 let comment_token = self.lang.comment_token();
146 format!("{indent}{contents} {comment_token} {location}\n")
147 } else {
148 format!("{indent}{contents}\n")
149 };
150 self.lines.push(indented_line);
151 }
152
153 /// Pushes an empty line.
154 pub fn empty_line(&mut self) {

Callers

nothing calls this directly

Calls 5

get_indentMethod · 0.80
comment_tokenMethod · 0.80
as_refMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected