Sema error: talk about discarding instead of suppressing

Maybe I'm just being pedantic here (most likely) but I don't like how we're
just telling the user here how to "suppress this error" by "assigning the value to '_'".
I think it's better if we use the word "discard" here which I think is
the official terminology and also tells the user what it actually means
to "assign the value to '_'".

Also, using the value would also be a way to "suppress the error".
It is just one of the two options: discard or use.
This commit is contained in:
r00ster91 2023-07-21 02:19:32 +02:00 committed by wooster0
parent e2ec54bb38
commit 60830e36e3
10 changed files with 18 additions and 18 deletions

View File

@ -3571,7 +3571,7 @@ fn ensureResultUsed(
const msg = try sema.errMsg(block, src, "value of type '{}' ignored", .{ty.fmt(sema.mod)});
errdefer msg.destroy(sema.gpa);
try sema.errNote(block, src, msg, "all non-void values must be used", .{});
try sema.errNote(block, src, msg, "this error can be suppressed by assigning the value to '_'", .{});
try sema.errNote(block, src, msg, "to discard the value, assign it to '_'", .{});
break :msg msg;
};
return sema.failWithOwnedErrorMsg(block, msg);

View File

@ -23,13 +23,13 @@ export fn f4() void {
//
// :5:30: error: value of type 'usize' ignored
// :5:30: note: all non-void values must be used
// :5:30: note: this error can be suppressed by assigning the value to '_'
// :5:30: note: to discard the value, assign it to '_'
// :9:30: error: value of type 'usize' ignored
// :9:30: note: all non-void values must be used
// :9:30: note: this error can be suppressed by assigning the value to '_'
// :9:30: note: to discard the value, assign it to '_'
// :13:31: error: value of type 'bool' ignored
// :13:31: note: all non-void values must be used
// :13:31: note: this error can be suppressed by assigning the value to '_'
// :13:31: note: to discard the value, assign it to '_'
// :16:42: error: value of type 'usize' ignored
// :16:42: note: all non-void values must be used
// :16:42: note: this error can be suppressed by assigning the value to '_'
// :16:42: note: to discard the value, assign it to '_'

View File

@ -24,4 +24,4 @@ pub export fn entry() void {
//
// :18:43: error: value of type 'type' ignored
// :18:43: note: all non-void values must be used
// :18:43: note: this error can be suppressed by assigning the value to '_'
// :18:43: note: to discard the value, assign it to '_'

View File

@ -11,4 +11,4 @@ fn bar() anyerror!i32 {
//
// :2:11: error: value of type 'i32' ignored
// :2:11: note: all non-void values must be used
// :2:11: note: this error can be suppressed by assigning the value to '_'
// :2:11: note: to discard the value, assign it to '_'

View File

@ -10,4 +10,4 @@ export fn foo() void {
//
// :3:9: error: value of type 'comptime_int' ignored
// :3:9: note: all non-void values must be used
// :3:9: note: this error can be suppressed by assigning the value to '_'
// :3:9: note: to discard the value, assign it to '_'

View File

@ -14,7 +14,7 @@ fn bar() u8 {
//
// :2:5: error: value of type 'comptime_int' ignored
// :2:5: note: all non-void values must be used
// :2:5: note: this error can be suppressed by assigning the value to '_'
// :2:5: note: to discard the value, assign it to '_'
// :5:5: error: value of type 'u8' ignored
// :5:5: note: all non-void values must be used
// :5:5: note: this error can be suppressed by assigning the value to '_'
// :5:5: note: to discard the value, assign it to '_'

View File

@ -10,4 +10,4 @@ export fn foo() void {
//
// :3:9: error: value of type 'comptime_int' ignored
// :3:9: note: all non-void values must be used
// :3:9: note: this error can be suppressed by assigning the value to '_'
// :3:9: note: to discard the value, assign it to '_'

View File

@ -11,4 +11,4 @@ fn bar() i32 {
//
// :2:8: error: value of type 'i32' ignored
// :2:8: note: all non-void values must be used
// :2:8: note: this error can be suppressed by assigning the value to '_'
// :2:8: note: to discard the value, assign it to '_'

View File

@ -8,4 +8,4 @@ export fn foo() void {
//
// :2:5: error: value of type 'comptime_int' ignored
// :2:5: note: all non-void values must be used
// :2:5: note: this error can be suppressed by assigning the value to '_'
// :2:5: note: to discard the value, assign it to '_'

View File

@ -32,16 +32,16 @@ export fn f5() void {
//
// :5:25: error: value of type 'usize' ignored
// :5:25: note: all non-void values must be used
// :5:25: note: this error can be suppressed by assigning the value to '_'
// :5:25: note: to discard the value, assign it to '_'
// :10:26: error: value of type 'usize' ignored
// :10:26: note: all non-void values must be used
// :10:26: note: this error can be suppressed by assigning the value to '_'
// :10:26: note: to discard the value, assign it to '_'
// :15:26: error: value of type 'usize' ignored
// :15:26: note: all non-void values must be used
// :15:26: note: this error can be suppressed by assigning the value to '_'
// :15:26: note: to discard the value, assign it to '_'
// :20:23: error: value of type 'bool' ignored
// :20:23: note: all non-void values must be used
// :20:23: note: this error can be suppressed by assigning the value to '_'
// :20:23: note: to discard the value, assign it to '_'
// :25:34: error: value of type 'usize' ignored
// :25:34: note: all non-void values must be used
// :25:34: note: this error can be suppressed by assigning the value to '_'
// :25:34: note: to discard the value, assign it to '_'