| author | |
| committer | |
| log | 60830e36e38f49bc797ae731c9dd58d7231039bf |
| tree | acfd10ac5e501668835d80992e8e11574e822f32 |
| parent | e2ec54bb38eb7b157667f0a87c9eb929017c3710 |
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.10 files changed, 18 insertions(+), 18 deletions(-)
src/Sema.zig+1-1| ... | ... | @@ -3571,7 +3571,7 @@ fn ensureResultUsed( |
| 3571 | 3571 | const msg = try sema.errMsg(block, src, "value of type '{}' ignored", .{ty.fmt(sema.mod)}); |
| 3572 | 3572 | errdefer msg.destroy(sema.gpa); |
| 3573 | 3573 | try sema.errNote(block, src, msg, "all non-void values must be used", .{}); |
| 3574 | try sema.errNote(block, src, msg, "this error can be suppressed by assigning the value to '_'", .{}); | |
| 3574 | try sema.errNote(block, src, msg, "to discard the value, assign it to '_'", .{}); | |
| 3575 | 3575 | break :msg msg; |
| 3576 | 3576 | }; |
| 3577 | 3577 | return sema.failWithOwnedErrorMsg(block, msg); |
test/cases/compile_errors/for_loop_body_expression_ignored.zig+4-4| ... | ... | @@ -23,13 +23,13 @@ export fn f4() void { |
| 23 | 23 | // |
| 24 | 24 | // :5:30: error: value of type 'usize' ignored |
| 25 | 25 | // :5:30: note: all non-void values must be used |
| 26 | // :5:30: note: this error can be suppressed by assigning the value to '_' | |
| 26 | // :5:30: note: to discard the value, assign it to '_' | |
| 27 | 27 | // :9:30: error: value of type 'usize' ignored |
| 28 | 28 | // :9:30: note: all non-void values must be used |
| 29 | // :9:30: note: this error can be suppressed by assigning the value to '_' | |
| 29 | // :9:30: note: to discard the value, assign it to '_' | |
| 30 | 30 | // :13:31: error: value of type 'bool' ignored |
| 31 | 31 | // :13:31: note: all non-void values must be used |
| 32 | // :13:31: note: this error can be suppressed by assigning the value to '_' | |
| 32 | // :13:31: note: to discard the value, assign it to '_' | |
| 33 | 33 | // :16:42: error: value of type 'usize' ignored |
| 34 | 34 | // :16:42: note: all non-void values must be used |
| 35 | // :16:42: note: this error can be suppressed by assigning the value to '_' | |
| 35 | // :16:42: note: to discard the value, assign it to '_' |
test/cases/compile_errors/generic_instantiation_failure.zig+1-1| ... | ... | @@ -24,4 +24,4 @@ pub export fn entry() void { |
| 24 | 24 | // |
| 25 | 25 | // :18:43: error: value of type 'type' ignored |
| 26 | 26 | // :18:43: note: all non-void values must be used |
| 27 | // :18:43: note: this error can be suppressed by assigning the value to '_' | |
| 27 | // :18:43: note: to discard the value, assign it to '_' |
test/cases/compile_errors/ignored_assert-err-ok_return_value.zig+1-1| ... | ... | @@ -11,4 +11,4 @@ fn bar() anyerror!i32 { |
| 11 | 11 | // |
| 12 | 12 | // :2:11: error: value of type 'i32' ignored |
| 13 | 13 | // :2:11: note: all non-void values must be used |
| 14 | // :2:11: note: this error can be suppressed by assigning the value to '_' | |
| 14 | // :2:11: note: to discard the value, assign it to '_' |
test/cases/compile_errors/ignored_comptime_statement_value.zig+1-1| ... | ... | @@ -10,4 +10,4 @@ export fn foo() void { |
| 10 | 10 | // |
| 11 | 11 | // :3:9: error: value of type 'comptime_int' ignored |
| 12 | 12 | // :3:9: note: all non-void values must be used |
| 13 | // :3:9: note: this error can be suppressed by assigning the value to '_' | |
| 13 | // :3:9: note: to discard the value, assign it to '_' |
test/cases/compile_errors/ignored_comptime_value.zig+2-2| ... | ... | @@ -14,7 +14,7 @@ fn bar() u8 { |
| 14 | 14 | // |
| 15 | 15 | // :2:5: error: value of type 'comptime_int' ignored |
| 16 | 16 | // :2:5: note: all non-void values must be used |
| 17 | // :2:5: note: this error can be suppressed by assigning the value to '_' | |
| 17 | // :2:5: note: to discard the value, assign it to '_' | |
| 18 | 18 | // :5:5: error: value of type 'u8' ignored |
| 19 | 19 | // :5:5: note: all non-void values must be used |
| 20 | // :5:5: note: this error can be suppressed by assigning the value to '_' | |
| 20 | // :5:5: note: to discard the value, assign it to '_' |
test/cases/compile_errors/ignored_deferred_statement_value.zig+1-1| ... | ... | @@ -10,4 +10,4 @@ export fn foo() void { |
| 10 | 10 | // |
| 11 | 11 | // :3:9: error: value of type 'comptime_int' ignored |
| 12 | 12 | // :3:9: note: all non-void values must be used |
| 13 | // :3:9: note: this error can be suppressed by assigning the value to '_' | |
| 13 | // :3:9: note: to discard the value, assign it to '_' |
test/cases/compile_errors/ignored_return_value.zig+1-1| ... | ... | @@ -11,4 +11,4 @@ fn bar() i32 { |
| 11 | 11 | // |
| 12 | 12 | // :2:8: error: value of type 'i32' ignored |
| 13 | 13 | // :2:8: note: all non-void values must be used |
| 14 | // :2:8: note: this error can be suppressed by assigning the value to '_' | |
| 14 | // :2:8: note: to discard the value, assign it to '_' |
test/cases/compile_errors/ignored_statement_value.zig+1-1| ... | ... | @@ -8,4 +8,4 @@ export fn foo() void { |
| 8 | 8 | // |
| 9 | 9 | // :2:5: error: value of type 'comptime_int' ignored |
| 10 | 10 | // :2:5: note: all non-void values must be used |
| 11 | // :2:5: note: this error can be suppressed by assigning the value to '_' | |
| 11 | // :2:5: note: to discard the value, assign it to '_' |
test/cases/compile_errors/while_loop_body_expression_ignored.zig+5-5| ... | ... | @@ -32,16 +32,16 @@ export fn f5() void { |
| 32 | 32 | // |
| 33 | 33 | // :5:25: error: value of type 'usize' ignored |
| 34 | 34 | // :5:25: note: all non-void values must be used |
| 35 | // :5:25: note: this error can be suppressed by assigning the value to '_' | |
| 35 | // :5:25: note: to discard the value, assign it to '_' | |
| 36 | 36 | // :10:26: error: value of type 'usize' ignored |
| 37 | 37 | // :10:26: note: all non-void values must be used |
| 38 | // :10:26: note: this error can be suppressed by assigning the value to '_' | |
| 38 | // :10:26: note: to discard the value, assign it to '_' | |
| 39 | 39 | // :15:26: error: value of type 'usize' ignored |
| 40 | 40 | // :15:26: note: all non-void values must be used |
| 41 | // :15:26: note: this error can be suppressed by assigning the value to '_' | |
| 41 | // :15:26: note: to discard the value, assign it to '_' | |
| 42 | 42 | // :20:23: error: value of type 'bool' ignored |
| 43 | 43 | // :20:23: note: all non-void values must be used |
| 44 | // :20:23: note: this error can be suppressed by assigning the value to '_' | |
| 44 | // :20:23: note: to discard the value, assign it to '_' | |
| 45 | 45 | // :25:34: error: value of type 'usize' ignored |
| 46 | 46 | // :25:34: note: all non-void values must be used |
| 47 | // :25:34: note: this error can be suppressed by assigning the value to '_' | |
| 47 | // :25:34: note: to discard the value, assign it to '_' |