Avoid follow-up errors if the number of generic parameters already doesn't match#125608
Avoid follow-up errors if the number of generic parameters already doesn't match#125608bors merged 9 commits intorust-lang:masterfrom
Conversation
|
HIR ty lowering was modified cc @fmease |
This comment has been minimized.
This comment has been minimized.
| if !trait_ref.self_ty().references_error() { | ||
| assert_eq!(trait_ref.self_ty(), dummy_self); | ||
| } |
There was a problem hiding this comment.
I am a bit nervous about this change. I feel like the rest of the compiler ought to be able to assume that trait objects are represented "correctly", especially with how we're starting to not end the compilation as early when hitting errors nowadays
Is it possible to make sure we still use the right self ty?
There was a problem hiding this comment.
I reverted the change and instead only marked those generic params as errors that were actually erroneous
|
☔ The latest upstream changes (presumably #125778) made this pull request unmergeable. Please resolve the merge conflicts. |
… are unused, just the number of entries is checked. The indices will be used in a follow-up commit
374cfb1 to
adb2ac0
Compare
| let args = args.unwrap(); | ||
| if args.iter().any(|arg| match arg.unpack() { | ||
| GenericArgKind::Type(ty) => ty.references_error(), | ||
| _ => false, | ||
| }) { | ||
| if let Some(prev) = | ||
| preceding_args.iter().find_map(|arg| match arg.unpack() { | ||
| GenericArgKind::Type(ty) => ty.error_reported().err(), | ||
| _ => None, | ||
| }) | ||
| { | ||
| // Avoid ICE #86756 when type error recovery goes awry. | ||
| return Ty::new_misc_error(tcx).into(); | ||
| return Ty::new_error(tcx, prev).into(); |
There was a problem hiding this comment.
Fishy ICE workaround, but I rather preserved it for now instead of looking into it
|
|
||
| fn provided_kind( | ||
| &mut self, | ||
| _preceding_args: &[ty::GenericArg<'tcx>], |
There was a problem hiding this comment.
Could actually allow generic const generics now here, but there's probably other work required elsewhere to support it properly
There was a problem hiding this comment.
Yeah basically nothing is set up for that at all lol
| gen_args.args[max_expected_args..provided_args].iter().map(|arg| arg.span()), | ||
| ); | ||
| }; | ||
| invalid_args.extend(min_expected_args..provided_args); |
There was a problem hiding this comment.
Will this not give a backwards range (i.e. 2..1) if you have a fn foo<'a: 'a, 'b: 'b> and you call it foo::<'static>?
There was a problem hiding this comment.
Yes, but that's the prev behaviour. I just merged the two loops
|
@bors r+ |
…, r=BoxyUwU Avoid follow-up errors if the number of generic parameters already doesn't match fixes rust-lang#125604 best reviewed commit-by-commit
Rollup of 9 pull requests Successful merges: - rust-lang#122804 (Item bounds can reference self projections and still be object safe) - rust-lang#124486 (Add tracking issue and unstable book page for `"vectorcall"` ABI) - rust-lang#125504 (Change pedantically incorrect OnceCell/OnceLock wording) - rust-lang#125608 (Avoid follow-up errors if the number of generic parameters already doesn't match) - rust-lang#125690 (ARM Target Docs Update) - rust-lang#125750 (Align `Term` methods with `GenericArg` methods, add `Term::expect_*`) - rust-lang#125818 (Handle no values cfgs with `--print=check-cfg`) - rust-lang#125909 (rustdoc: add a regression test for a former blanket impl synthesis ICE) - rust-lang#125919 (Remove stray "this") r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 8 pull requests Successful merges: - rust-lang#124486 (Add tracking issue and unstable book page for `"vectorcall"` ABI) - rust-lang#125504 (Change pedantically incorrect OnceCell/OnceLock wording) - rust-lang#125608 (Avoid follow-up errors if the number of generic parameters already doesn't match) - rust-lang#125690 (ARM Target Docs Update) - rust-lang#125750 (Align `Term` methods with `GenericArg` methods, add `Term::expect_*`) - rust-lang#125818 (Handle no values cfgs with `--print=check-cfg`) - rust-lang#125909 (rustdoc: add a regression test for a former blanket impl synthesis ICE) - rust-lang#125919 (Remove stray "this") r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#125608 - oli-obk:subsequent_lifetime_errors, r=BoxyUwU Avoid follow-up errors if the number of generic parameters already doesn't match fixes rust-lang#125604 best reviewed commit-by-commit
| //@ known-bug: #121134 | ||
| trait Output<'a> { | ||
| type Type; | ||
| } | ||
|
|
||
| struct Wrapper; | ||
|
|
||
| impl Wrapper { | ||
| fn do_something_wrapper<O, F>(&mut self, do_something_wrapper: F) | ||
| where | ||
| FnOnce:, | ||
| F: for<'a> FnOnce(<F as Output<i32, _>>::Type), | ||
| { | ||
| } | ||
| } | ||
|
|
||
| fn main() { | ||
| let mut wrapper = Wrapper; | ||
| wrapper.do_something_wrapper::<i32, _>(|value| ()); | ||
| } |
Add regression test for a gce + effects ICE Fixes rust-lang#125770 I'm not *exactly* sure why this stopped ICEing, I assume its something to do with the fact that there used to be a generic parameter on `Add` for the host generic and we have mismatched args here, which rust-lang#125608 made no longer later cause issues. But now the desugaring is also different so? 🤷♀️ r? `@fee1-dead`
Rollup merge of rust-lang#127711 - BoxyUwU:add_effects_test, r=fee1-dead Add regression test for a gce + effects ICE Fixes rust-lang#125770 I'm not *exactly* sure why this stopped ICEing, I assume its something to do with the fact that there used to be a generic parameter on `Add` for the host generic and we have mismatched args here, which rust-lang#125608 made no longer later cause issues. But now the desugaring is also different so? 🤷♀️ r? `@fee1-dead`
fixes #125604
best reviewed commit-by-commit