-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Double check that hidden types match the expected hidden type #113661
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
44e2150
Double check that hidden types match the expected hidden type
oli-obk 10d0ff9
Explain what the heck is going on with this lifetime remapping business
oli-obk 5b4549d
Some documentation nits
oli-obk 30f7878
Explain RPITs in the way they actually work
oli-obk df4bfd9
Try explaining where `Inner` is in the signature better
oli-obk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Double check that hidden types match the expected hidden type
- Loading branch information
commit 44e21503a8f2e789bbd90b5dd52590879ba2fab6
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//! This test checks that we don't lose hidden types | ||
//! for *other* opaque types that we register and use | ||
//! to prove bounds while checking that a hidden type | ||
//! satisfies its opaque type's bounds. | ||
|
||
#![feature(trivial_bounds, type_alias_impl_trait)] | ||
#![allow(trivial_bounds)] | ||
|
||
mod sus { | ||
use super::*; | ||
pub type Sep = impl Sized + std::fmt::Display; | ||
//~^ ERROR: concrete type differs from previous defining opaque type use | ||
pub fn mk_sep() -> Sep { | ||
String::from("hello") | ||
} | ||
|
||
pub trait Proj { | ||
type Assoc; | ||
} | ||
impl Proj for () { | ||
type Assoc = sus::Sep; | ||
} | ||
|
||
pub struct Bar<T: Proj> { | ||
pub inner: <T as Proj>::Assoc, | ||
pub _marker: T, | ||
} | ||
impl<T: Proj> Clone for Bar<T> { | ||
fn clone(&self) -> Self { | ||
todo!() | ||
} | ||
} | ||
impl<T: Proj<Assoc = i32> + Copy> Copy for Bar<T> {} | ||
// This allows producing `Tait`s via `From`, even though | ||
// `define_tait` is not actually callable, and thus assumed | ||
// `Bar<()>: Copy` even though it isn't. | ||
pub type Tait = impl Copy + From<Bar<()>> + Into<Bar<()>>; | ||
pub fn define_tait() -> Tait | ||
where | ||
// this proves `Bar<()>: Copy`, but `define_tait` is | ||
// now uncallable | ||
(): Proj<Assoc = i32>, | ||
{ | ||
Bar { inner: 1i32, _marker: () } | ||
} | ||
} | ||
|
||
fn copy_tait(x: sus::Tait) -> (sus::Tait, sus::Tait) { | ||
(x, x) | ||
} | ||
|
||
fn main() { | ||
let bar = sus::Bar { inner: sus::mk_sep(), _marker: () }; | ||
let (y, z) = copy_tait(bar.into()); // copy a string | ||
drop(y.into()); // drop one instance | ||
println!("{}", z.into().inner); // print the other | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/ui/type-alias-impl-trait/hidden_type_mismatch.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error: concrete type differs from previous defining opaque type use | ||
--> $DIR/hidden_type_mismatch.rs:11:20 | ||
| | ||
LL | pub type Sep = impl Sized + std::fmt::Display; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, got `String` | ||
| | ||
note: previous use here | ||
--> $DIR/hidden_type_mismatch.rs:37:21 | ||
| | ||
LL | pub type Tait = impl Copy + From<Bar<()>> + Into<Bar<()>>; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
4 changes: 2 additions & 2 deletions
4
tests/ui/issues/issue-83190.rs → ...-impl-trait/nested-rpit-with-lifetimes.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 feel like we should hit this bug? 🤔 or do we avoid it because we have
OpaqueCast
everywhere we would assign to/from opaques?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 was surprised, too, but I didn't debug it.
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.
do we run the validator before optimizations by default 😅 iirc we only do it with
-Zvalidate-mir
🤔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.
#114121 :D