-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid follow-up errors if the number of generic parameters already doesn't match #125608
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted the change and instead only marked those generic params as errors that were actually erroneous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool
☔ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fishy ICE workaround, but I rather preserved it for now instead of looking into it
@@ -1275,6 +1275,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |||
|
|||
fn provided_kind( | |||
&mut self, | |||
_preceding_args: &[ty::GenericArg<'tcx>], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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| ()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this issue is not closed
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