-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Don't ICE on missing Unsize
impl
#72194
Conversation
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.
Looks good to me after niko's requests!
@@ -283,6 +283,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { | |||
.unwrap_or(false); | |||
let is_from = format!("{}", trait_ref.print_only_trait_path()) | |||
.starts_with("std::convert::From<"); | |||
let is_unsize = | |||
{ Some(trait_ref.def_id()) == self.tcx.lang_items().unsize_trait() }; |
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.
Are the braces needed? Have you ran x.py fmt
?
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.
Not strictly necessary, but I ran ./x.py fmt
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 can remove if you think that's better?
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.
Na, if it's fine with fmt it's fine with me.
@bors r+ rollup |
📌 Commit f6aa161 has been approved by |
…tebank Don't ICE on missing `Unsize` impl Previously code of the form ```rust #![feature(unsize, dispatch_from_dyn)] use std::marker::Unsize; use std::ops::DispatchFromDyn; pub struct Foo<'a, T: ?Sized> { _inner: &'a &'a T, } impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Foo<'a, U>> for Foo<'a, T> {} ``` would generate an ICE due to the missing `Unsize` impl being run through the `suggest_change_mut` suggestion. This PR adds an early exit and a pointer to the appropriate docs regarding `Unsize` instead: ``` error[E0277]: the trait bound `&'a T: std::marker::Unsize<&'a U>` is not satisfied --> src/test/ui/issues/issue-71036.rs:11:1 | 11 | impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Foo<'a, U>> for Foo<'a, T> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Unsize<&'a U>` is not implemented for `&'a T` | = note: all implementations of `Unsize` are provided automatically by the compiler, see <https://doc.rust-lang.org/stable/std/marker/trait.Unsize.html> for more information = note: required because of the requirements on the impl of `std::ops::DispatchFromDyn<&'a &'a U>` for `&'a &'a T` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. ``` r? @estebank Resolves rust-lang#71036
Rollup of 8 pull requests Successful merges: - rust-lang#71910 (Fix unused_parens false positive when using binary operations) - rust-lang#72087 (Fix hang in lexical_region_resolve) - rust-lang#72126 (Change `WorkProduct::saved_files` to an `Option`.) - rust-lang#72127 (add long error explanation for E0228) - rust-lang#72141 (Warn against thread::sleep in async fn) - rust-lang#72170 (use `require_lang_item` over `unwrap`.) - rust-lang#72191 (Clean up E0589 explanation) - rust-lang#72194 (Don't ICE on missing `Unsize` impl) Failed merges: r? @ghost
Previously code of the form
would generate an ICE due to the missing
Unsize
impl being run through thesuggest_change_mut
suggestion. This PR adds an early exit and a pointer to the appropriate docs regardingUnsize
instead:r? @estebank
Resolves #71036