Skip to content

Commit

Permalink
Update error formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bfbachmann committed Dec 31, 2024
1 parent 2ec8423 commit 272ac5e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 35 deletions.
45 changes: 22 additions & 23 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,26 @@ The language and compiler are still very young, so they still lack some critical

<!-- TOC -->

* [The Blang Programming Language](#the-blang-programming-language)
* [Function Declarations & Calls: `fn`](#function-declarations--calls-fn)
* [Variable Declarations: `let`](#variable-declarations-let)
* [Constant Declarations: `const`](#constant-declarations-const)
* [Statements as Expressions: `from`, `yield`](#statements-as-expressions-from-yield)
* [Structures: `struct`](#structures-struct)
* [Enumerations: `enum`](#enumerations-enum)
* [Tuples: `{...}`](#tuples-)
* [Arrays: `[...]`](#arrays-)
* [Implementations, Methods, and Method Calls: `impl`, `fn`](#implementations-methods-and-method-calls-impl-fn)
* [Conditionals: `if`, `else if`, `else`](#conditionals-if-elsif-else)
* [Pattern Matching: `match`](#pattern-matching-match)
* [Loops: `for`, `while`, `loop`](#loops-for-while-loop)
* [`for` loops](#for-loops)
* [`while` loops](#while-loops)
* [`loop` loops](#loop-loops)
* [Pointers and Memory Access: `*_`, `*mut _`, `&`, `&mut`, `^`](#pointers-and-memory-access-_-mut-_--mut-)
* [Externs: `extern`](#externs-extern)
* [Imports: `use`](#imports-use)
* [Type Casts: `as`](#type-casts-as)
* [Generics](#generics)
* [Function Declarations & Calls: `fn`](#function-declarations--calls-fn)
* [Variable Declarations: `let`](#variable-declarations-let)
* [Constant Declarations: `const`](#constant-declarations-const)
* [Statements as Expressions: `from`, `yield`](#statements-as-expressions-from-yield)
* [Structures: `struct`](#structures-struct)
* [Enumerations: `enum`](#enumerations-enum)
* [Tuples: `{...}`](#tuples-)
* [Arrays: `[...]`](#arrays-)
* [Implementations, Methods, and Method Calls: `impl`, `fn`](#implementations-methods-and-method-calls-impl-fn)
* [Conditionals: `if`, `else if`, `else`](#conditionals-if-elsif-else)
* [Pattern Matching: `match`](#pattern-matching-match)
* [Loops: `for`, `while`, `loop`](#loops-for-while-loop)
* [`for` loops](#for-loops)
* [`while` loops](#while-loops)
* [`loop` loops](#loop-loops)
* [Pointers and Memory Access: `*_`, `*mut _`, `&`, `&mut`, `^`](#pointers-and-memory-access-_-mut-_--mut-)
* [Externs: `extern`](#externs-extern)
* [Imports: `use`](#imports-use)
* [Type Casts: `as`](#type-casts-as)
* [Generics](#generics)

<!-- TOC -->

Expand Down Expand Up @@ -363,8 +362,8 @@ fn main() {
let mut a = [1, 2, 3]
// Double all elements in the array.
for let mut i: u64 = 0, i < 3, i = i + 1 {
a.(i) = a.(i) * 2
for let mut i = 0uint, i < 3, i = i + 1 {
a.(i) *= 2
}
}
```
Expand Down
13 changes: 1 addition & 12 deletions src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,7 @@ fn print_source_color(file_path: &str, span: &Span) {

// The code spans multiple lines and this is neither the first nor the last.
if mid_lines_printed == 3 {
let ws: String = line
.chars()
.take_while(|c| c.is_whitespace())
.into_iter()
.collect();

println!(
"{} {}{}",
format!("{:>width$}|", "", width = width).blue().bold(),
ws,
"// ...".red().bold()
);
println!("{}", ".".repeat(width+1).blue().bold(),);
} else if mid_lines_printed <= 1 {
println!(
"{} {}",
Expand Down

0 comments on commit 272ac5e

Please sign in to comment.