diff options
| author | Yuki Okushi <huyuumi.dev+love@gmail.com> | 2022-11-20 13:15:59 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-20 13:15:59 +0900 |
| commit | 3e937d02a012dbce129cc7773517a9bb24f5bf93 (patch) | |
| tree | af8a1a784bf9297588fe05959ed2757d4bdcfd9d /src | |
| parent | 785237d3924d4fb7b23803c964972dce82de2161 (diff) | |
| parent | 3046af0cf652a4ccecd823d7b5cf81fbf026ab38 (diff) | |
Rollup merge of #104467 - fuzzypixelz:fix/attempt-to-substract-with-overflow, r=compiler-errors
Fix substraction with overflow in `wrong_number_of_generic_args.rs` Fixes #104287 This issue happens in the `suggest_moving_args_from_assoc_fn_to_trait_for_qualified_path` function, which seems to run before the error checking facilities can catch an invalid use of generic arguments. Thus we get a subtraction with overflow because the code implicitly assumes that the source program makes sense (or is this assumption not true even if the program is correct?).
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/suggestions/issue-104287.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/suggestions/issue-104287.stderr | 36 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/issue-104287.rs b/src/test/ui/suggestions/issue-104287.rs new file mode 100644 index 00000000000..b7601a548b9 --- /dev/null +++ b/src/test/ui/suggestions/issue-104287.rs @@ -0,0 +1,9 @@ +// The purpose of this test is not to validate the output of the compiler. +// Instead, it ensures the suggestion is generated without performing an arithmetic overflow. + +fn main() { + let x = not_found; //~ ERROR cannot find value `not_found` in this scope + simd_gt::<()>(x); + //~^ ERROR this associated function takes 0 generic arguments but 1 generic argument was supplied + //~| ERROR cannot find function `simd_gt` in this scope +} diff --git a/src/test/ui/suggestions/issue-104287.stderr b/src/test/ui/suggestions/issue-104287.stderr new file mode 100644 index 00000000000..4b302dd6509 --- /dev/null +++ b/src/test/ui/suggestions/issue-104287.stderr @@ -0,0 +1,36 @@ +error[E0425]: cannot find value `not_found` in this scope + --> $DIR/issue-104287.rs:5:13 + | +LL | let x = not_found; + | ^^^^^^^^^ not found in this scope + +error[E0107]: this associated function takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/issue-104287.rs:6:5 + | +LL | simd_gt::<()>(x); + | ^^^^^^^------ help: remove these generics + | | + | expected 0 generic arguments + | +note: associated function defined here, with 0 generic parameters + --> $SRC_DIR/core/src/../../portable-simd/crates/core_simd/src/ord.rs:LL:COL + | +LL | fn simd_gt(self, other: Self) -> Self::Mask; + | ^^^^^^^ + +error[E0425]: cannot find function `simd_gt` in this scope + --> $DIR/issue-104287.rs:6:5 + | +LL | simd_gt::<()>(x); + | ^^^^^^^ not found in this scope + | +help: use the `.` operator to call the method `SimdPartialOrd::simd_gt` on `[type error]` + | +LL - simd_gt::<()>(x); +LL + x.simd_gt(); + | + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0107, E0425. +For more information about an error, try `rustc --explain E0107`. |
