-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix: Fix layout for hir_ty::Ty
and friends
#14802
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1962,6 +1962,36 @@ fn const_generic_subst_fn() { | |
); | ||
} | ||
|
||
#[test] | ||
fn layout_of_type_with_associated_type_field_defined_inside_body() { | ||
check_number( | ||
r#" | ||
trait Tr { | ||
type Ty; | ||
} | ||
|
||
struct St<T: Tr>(T::Ty); | ||
|
||
const GOAL: i64 = { | ||
// if we move `St2` out of body, the test will fail, as we don't see the impl anymore. That | ||
// case will probably be rejected by rustc in some later edition, but we should support this | ||
// case. | ||
struct St2; | ||
|
||
impl Tr for St2 { | ||
type Ty = i64; | ||
} | ||
|
||
struct Goal(St<St2>); | ||
|
||
let x = Goal(St(5)); | ||
Comment on lines
+1979
to
+1987
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is strange for me that we support this. We don't pass a trait env with block anywhere in the layout code, but we can find the layout of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The layout code receives the substitutions though, which would come from the type inference code which does account for blocks. |
||
x.0.0 | ||
}; | ||
"#, | ||
5, | ||
); | ||
} | ||
|
||
#[test] | ||
fn const_generic_subst_assoc_const_impl() { | ||
check_number( | ||
|
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 you mean only moving out the
St2
struct definition (leaving the impl forSt2
in the block)? That's surprising that that does not work. I'm pretty sure it should ...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 I mean keeping the impl inside of the block. You can reproduce that by hovering on goal. I guess the problem is that we don't pass the block of the goal, only the crate, so it can't normalize the associated type. But with this logic, this one shouldn't work either...