Splits a textual error message into its source position and message. TODO(jmmv): This is a hack to support the current needs of std and allow migrating its code to this new implementation. Once migrated, revisit this.
(&self)
| 153 | /// TODO(jmmv): This is a hack to support the current needs of std and allow migrating its |
| 154 | /// code to this new implementation. Once migrated, revisit this. |
| 155 | fn split_display_message(&self) -> (LineCol, String) { |
| 156 | let display = self.to_string(); |
| 157 | let mut parts = display.splitn(3, ':'); |
| 158 | let line = parts |
| 159 | .next() |
| 160 | .expect("CompilerError display always has line") |
| 161 | .parse() |
| 162 | .expect("CompilerError line is always numeric"); |
| 163 | let col = parts |
| 164 | .next() |
| 165 | .expect("CompilerError display always has column") |
| 166 | .parse() |
| 167 | .expect("CompilerError column is always numeric"); |
| 168 | let message = |
| 169 | parts.next().expect("CompilerError display always has message").trim_start().to_owned(); |
| 170 | (LineCol { line, col }, message) |
| 171 | } |
| 172 | |
| 173 | /// Returns the source position where this compilation error happened. |
| 174 | pub fn pos(&self) -> LineCol { |
no test coverage detected