diff --git a/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__use___just_use_in_fn_body.snap b/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__use___just_use_in_fn_body.snap index fa2561fda..c0c3b05c2 100644 --- a/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__use___just_use_in_fn_body.snap +++ b/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__use___just_use_in_fn_body.snap @@ -20,6 +20,8 @@ warning: Incomplete use expression 3 │ use <- wibble() │ ^^^^^^^^^^^^^^^ This code is incomplete -This code will crash if it is run. Be sure to finish it before -running your program. A use expression must always be followed by at least one expression. + +A todo expression has been use in place of the missing code, so +this code will crash if it is run. Be sure to finish it before +running your program. diff --git a/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__use___no_callback_body.snap b/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__use___no_callback_body.snap index 86ceae445..310cf25f1 100644 --- a/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__use___no_callback_body.snap +++ b/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__use___no_callback_body.snap @@ -17,6 +17,8 @@ warning: Incomplete use expression 4 │ use <- thingy() │ ^^^^^^^^^^^^^^^ This code is incomplete -This code will crash if it is run. Be sure to finish it before -running your program. A use expression must always be followed by at least one expression. + +A todo expression has been use in place of the missing code, so +this code will crash if it is run. Be sure to finish it before +running your program. diff --git a/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__warnings__empty_func_warning_test.snap b/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__warnings__empty_func_warning_test.snap index 658f24db9..909ca02b2 100644 --- a/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__warnings__empty_func_warning_test.snap +++ b/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__warnings__empty_func_warning_test.snap @@ -14,5 +14,8 @@ warning: Unimplemented function 2 │ pub fn wibble() { } │ ^^^^^^^^^^^^^^^ This code is incomplete -This code will crash if it is run. Be sure to finish it before +A function must always have an implementation. + +A todo expression has been use in place of the missing body, +so this code will crash if it is run. Be sure to finish it before running your program. diff --git a/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__warnings__incomplete_code_block_raises_warning.snap b/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__warnings__incomplete_code_block_raises_warning.snap index 457fb65dc..f2fa1c58f 100644 --- a/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__warnings__incomplete_code_block_raises_warning.snap +++ b/compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__warnings__incomplete_code_block_raises_warning.snap @@ -16,6 +16,8 @@ warning: Incomplete block 3 │ {} │ ^^ This code is incomplete -This code will crash if it is run. Be sure to finish it before -running your program. A block must always contain at least one expression. + +A todo expression has been use in place of the missing code, +so this code will crash if it is run. Be sure to finish it before +running your program. diff --git a/compiler-core/src/warning.rs b/compiler-core/src/warning.rs index af2732688..471a75b90 100644 --- a/compiler-core/src/warning.rs +++ b/compiler-core/src/warning.rs @@ -440,28 +440,41 @@ comment so it is not attached to any definition.", type_, names, } => { - let mut text = String::new(); - text.push_str( - "\ + let (title, text) = match kind { + TodoKind::Keyword => { + let text = "\ This code will crash if it is run. Be sure to finish it before -running your program.", - ); - let title = match kind { - TodoKind::Keyword => "Todo found", +running your program."; + + ("Todo found", text) + } + TodoKind::EmptyBlock => { - text.push_str( - " -A block must always contain at least one expression.", - ); - "Incomplete block" + let text = "\ +A block must always contain at least one expression. + +A todo expression has been use in place of the missing code, +so this code will crash if it is run. Be sure to finish it before +running your program."; + ("Incomplete block", text) + } + TodoKind::EmptyFunction { .. } => { + let text = "\ +A function must always have an implementation. + +A todo expression has been use in place of the missing body, +so this code will crash if it is run. Be sure to finish it before +running your program."; + ("Unimplemented function", text) } - TodoKind::EmptyFunction { .. } => "Unimplemented function", TodoKind::IncompleteUse => { - text.push_str( - " -A use expression must always be followed by at least one expression.", - ); - "Incomplete use expression" + let text = "\ +A use expression must always be followed by at least one expression. + +A todo expression has been use in place of the missing code, so +this code will crash if it is run. Be sure to finish it before +running your program."; + ("Incomplete use expression", text) } } .into(); @@ -476,8 +489,8 @@ A use expression must always be followed by at least one expression.", }; Diagnostic { - title, - text, + title: title.into(), + text: text.into(), level: diagnostic::Level::Warning, location: Some(Location { path: path.to_path_buf(),