-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 static_ptr_ty for foreign statics #78101
Conversation
Even in the PR that introduced this comment, it does not seem like these locals are actually ignored -- just their `source_info` is adjusted: https://github.com/rust-lang/rust/pull/44700/files#diff-ae2f3c7e2f9744f7ef43e96072b10e98d4e3fe74a3a399a3ad8a810fbe56c520R139
However, the test suite currently fails with an ICE:
Looks like something somewhere is not using |
Or maybe it is the other way around -- |
I think I found where the wrong type was coming from. |
ed54d95
to
153e843
Compare
let static_ty = tcx.type_of(did); | ||
if tcx.is_mutable_static(did) { | ||
tcx.mk_mut_ptr(tcx.type_of(did)) | ||
tcx.mk_mut_ptr(static_ty) | ||
} else if tcx.is_foreign_item(did) { | ||
tcx.mk_imm_ptr(static_ty) | ||
} else { | ||
tcx.mk_imm_ref(tcx.lifetimes.re_static, tcx.type_of(did)) | ||
// FIXME: These things don't *really* have 'static lifetime. | ||
tcx.mk_imm_ref(tcx.lifetimes.re_static, static_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.
This could be deduplicated with the other site by putting it in a function. I see no danger in eagerly normalizing static items' types (so doing it here, too).
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 did that at first, but the lifetime differs. That lead to ICEs.
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.
uff, right
@bors r+ |
📌 Commit 153e843 has been approved by |
fix static_ptr_ty for foreign statics Cc rust-lang#74840 This does not fix that issue but fixes a problem in `static_ptr_ty` that we noticed while discussing that issue. I also added and updated a few comments. The one about `internal` locals being ignored does not seem to have been true [even in the commit that introduced it](https://github.com/rust-lang/rust/pull/44700/files#diff-ae2f3c7e2f9744f7ef43e96072b10e98d4e3fe74a3a399a3ad8a810fbe56c520R139). r? @oli-obk
Rollup of 7 pull requests Successful merges: - rust-lang#77726 (Add Pin::static_ref, static_mut.) - rust-lang#78002 (Tweak "object unsafe" errors) - rust-lang#78056 (BTreeMap: split off most code of remove and split_off) - rust-lang#78063 (Improve wording of "cannot multiply" type error) - rust-lang#78094 (rustdoc: Show the correct source filename in page titles, without `.html`) - rust-lang#78101 (fix static_ptr_ty for foreign statics) - rust-lang#78118 (Inline const followups) Failed merges: r? `@ghost`
Cc #74840
This does not fix that issue but fixes a problem in
static_ptr_ty
that we noticed while discussing that issue. I also added and updated a few comments. The one aboutinternal
locals being ignored does not seem to have been true even in the commit that introduced it.r? @oli-obk