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?).
This commit is contained in:
commit
3e937d02a0
3 changed files with 47 additions and 1 deletions
|
@ -728,7 +728,8 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
|||
&& let Some(trait_path_segment) = path.segments.get(0) {
|
||||
let num_generic_args_supplied_to_trait = trait_path_segment.args().num_generic_params();
|
||||
|
||||
if num_assoc_fn_excess_args == num_trait_generics_except_self - num_generic_args_supplied_to_trait {
|
||||
if num_generic_args_supplied_to_trait + num_assoc_fn_excess_args == num_trait_generics_except_self
|
||||
{
|
||||
if let Some(span) = self.gen_args.span_ext()
|
||||
&& let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
|
||||
let sugg = vec![
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue