Skip to content

Conversation

dlrobertson
Copy link
Contributor

The layout of a extern_type static is unsized, but may pass the
Well-Formed check in typeck (See #55257). As a result, we
cannot assume that a static is sized when generating the Place
for an r-value.

Fixes: #57876

r? @oli-obk

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 5, 2019
llextra: None,
layout: layout,
align: layout.align.abi
}
Copy link
Contributor Author

@dlrobertson dlrobertson Feb 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does feel a bit reckless to me. Would it be better to instead make the change here so that this is only allowed in the case of a r-value that is a reference to a static?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the right thing to do is to create a new constructor method (new_thin_place maybe?) that uses !type_has_metadata instead of is_sized in the assertion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is definitely a good check to add. At the very least it seems like a good idea to add it inline here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oli-obk Added PlaceRef::new_thin_place. It is only used in place.rs currently, so I didn't make the function pub.

The layout of a extern_type static is unsized, but may pass the
Well-Formed check in typeck. As a result, we cannot assume that
a static is sized when generating the `Place` for an r-value.
@oli-obk
Copy link
Contributor

oli-obk commented Feb 6, 2019

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Feb 6, 2019

📌 Commit 80c052b has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 6, 2019
kennytm added a commit to kennytm/rust that referenced this pull request Feb 7, 2019
Do not ICE in codegen when using a extern_type static

The layout of a extern_type static is unsized, but may pass the
Well-Formed check in typeck (See rust-lang#55257).  As a result, we
cannot assume that a static is sized when generating the `Place`
for an r-value.

Fixes: rust-lang#57876

r? @oli-obk
bors added a commit that referenced this pull request Feb 7, 2019
Rollup of 23 pull requests

Successful merges:

 - #58118 (Transition libtest to 2018 edition)
 - #58119 (libproc_macro => 2018)
 - #58123 (Avoid some bounds checks in binary_heap::{PeekMut,Hole})
 - #58124 (libsyntax_pos => 2018)
 - #58133 (libsyntax_ext => 2018)
 - #58136 (Improve error message and docs for non-UTF-8 bytes in stdio on Windows)
 - #58156 (update submodule: rust-installer from 27dec6c to ccdc47b)
 - #58192 (Do not ICE in codegen when using a extern_type static)
 - #58193 (Move librustc to 2018)
 - #58210 (Make an assert debug-only in `find_constraint_paths_between_regions`.)
 - #58217 (librustc_tsan => 2018)
 - #58218 (librustc_msan => 2018)
 - #58219 (librustc_asan => 2018)
 - #58220 (libprofiler_builtins => 2018)
 - #58223 (librustc_lsan => 2018)
 - #58225 (librustc_fs_util => 2018)
 - #58228 (librustc_plugin => 2018)
 - #58236 (librustc_resolve => 2018)
 - #58237 (Fix broken grammar in iter::from_fn() docs)
 - #58239 (librustc_apfloat => 2018)
 - #58240 (librustc_errors => 2018)
 - #58241 (librustc_llvm => 2018)
 - #58242 (Document the one TyKind that isn't documented)

Failed merges:

 - #58185 (Remove images' url to make it work even without internet connection)

r? @ghost
@bors bors merged commit 80c052b into rust-lang:master Feb 7, 2019
@dlrobertson dlrobertson deleted the fix_57876 branch February 7, 2019 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants