rust/compiler
Yuki Okushi 91faabb424
Rollup merge of #86174 - lqd:const-ub-align, r=RalfJung
Detect incorrect vtable alignment during const eval

This PR fixes #86132 by detecting invalid alignment values for trait objects in the interpreter, and emitting an error about this conversion failure, to avoid the ICE.

I've noticed that the error emitted at a50d72158e/compiler/rustc_mir/src/interpret/traits.rs (L163-L166) doesn't seem to be present in the const-ub tests, so I've tried adding a test that triggers both of these cases: one for the invalid size, and another for the invalid alignment that #86132 tracks (I have found different magic values triggering different `Align::from_bytes` errors than the "power of 2" one, if need be).

However, when doing that, I *cannot* for the life of me figure out the correct incantation to make these 2 errors trigger with the "it is undefined behavior to use this value" message rather than the "any use of this value will cause an error" lint.

I've tried Oli's suggestions of different values, tuples and arrays, using the transparent wrapper trick from the other tests and I was only able to trigger the regular const-ub errors about the size of the vtable, or that the drop pointer was invalid. Maybe these "type validation failed" errors happen before this part of the interpreter is reached and there just needs some magic incorrect values to bypass them, I don't know.

Since this fixes an ICE, and if the constants are indeed used, these 2 tests will turn into a hard error, I thought I'd open the PR anyways. And if ```@RalfJung``` you know of a way I could manage that (if you think that these tests are worth checking that the `throw_ub_format!` does indeed create const-ub errors as we expect) I'd be grateful.

For that reason, r? ```@RalfJung``` and cc ```@oli-obk.```
2021-06-12 01:16:00 +09:00
..
rustc use jemallocator in rustc/rustdoc 2021-04-04 14:10:26 -07:00
rustc_apfloat remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_arena Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
rustc_ast Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_ast_lowering Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_ast_passes Rollup merge of #85800 - BoxyUwU:const-param-default-diagnostics, r=oli-obk 2021-06-12 01:15:56 +09:00
rustc_ast_pretty Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_attr remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_builtin_macros Auto merge of #84863 - ABouttefeux:libtest, r=m-ou-se 2021-06-06 09:13:59 +00:00
rustc_codegen_cranelift Auto merge of #85910 - cjgillot:no-meta-version, r=Aaron1011 2021-06-10 00:39:25 +00:00
rustc_codegen_llvm Auto merge of #86020 - nagisa:nagisa/outliner, r=pnkfelix 2021-06-10 15:11:01 +00:00
rustc_codegen_ssa Auto merge of #86204 - alexcrichton:wasm-simd-stable, r=Amanieu 2021-06-11 05:02:41 +00:00
rustc_data_structures add VecMap docs 2021-06-08 17:17:48 -03:00
rustc_driver Rustfmt 2021-06-04 13:20:05 +02:00
rustc_error_codes Add E0316.md 2021-06-07 14:20:39 +02:00
rustc_errors Auto merge of #85903 - bjorn3:rustc_serialize_cleanup, r=varkor 2021-06-07 14:40:26 +00:00
rustc_expand Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_feature Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_fs_util Optimize away a fs::metadata call. 2021-01-06 08:33:15 -08:00
rustc_graphviz Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
rustc_hir Do not require the DefPathTable to construct the on-disk cache. 2021-06-08 22:23:03 +02:00
rustc_hir_pretty remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_incremental Do not require the DefPathTable to construct the on-disk cache. 2021-06-08 22:23:03 +02:00
rustc_index Remove unused feature gates 2021-05-31 13:55:43 +02:00
rustc_infer Suggest a trailing comma if a 1-tuple is expected 2021-06-07 23:16:03 +02:00
rustc_interface Do not require the DefPathTable to construct the on-disk cache. 2021-06-08 22:23:03 +02:00
rustc_lexer Fix outdated crate names in compiler docs 2021-04-08 11:12:14 -05:00
rustc_lint Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_lint_defs Fix deny(invalid_doc_attributes) 2021-06-04 15:20:26 -04:00
rustc_llvm Auto merge of #84171 - ricobbe:raw-dylib-via-llvm, r=petrochenkov 2021-06-06 03:59:17 +00:00
rustc_macros Remove unused functions and arguments from rustc_serialize 2021-06-01 19:29:11 +02:00
rustc_metadata Auto merge of #85910 - cjgillot:no-meta-version, r=Aaron1011 2021-06-10 00:39:25 +00:00
rustc_middle Rollup merge of #85800 - BoxyUwU:const-param-default-diagnostics, r=oli-obk 2021-06-12 01:15:56 +09:00
rustc_mir Rollup merge of #86174 - lqd:const-ub-align, r=RalfJung 2021-06-12 01:16:00 +09:00
rustc_mir_build Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_parse Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_parse_format remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
rustc_passes Rollup merge of #86047 - jyn514:doc-attrs, r=petrochenkov 2021-06-06 19:11:24 +09:00
rustc_plugin_impl Use () for plugin_registrar_fn. 2021-05-12 13:58:43 +02:00
rustc_privacy Revert "Reduce the amount of untracked state in TyCtxt" 2021-06-01 09:05:22 +02:00
rustc_query_impl Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514 2021-06-04 13:42:54 +09:00
rustc_query_system Auto merge of #85903 - bjorn3:rustc_serialize_cleanup, r=varkor 2021-06-07 14:40:26 +00:00
rustc_resolve Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
rustc_save_analysis Revert "Merge CrateDisambiguator into StableCrateId" 2021-06-07 10:37:45 +02:00
rustc_serialize Auto merge of #85903 - bjorn3:rustc_serialize_cleanup, r=varkor 2021-06-07 14:40:26 +00:00
rustc_session gcc-lld mvp 2021-06-10 17:10:40 +10:00
rustc_span Rollup merge of #86153 - tmiasko:dummy-span, r=estebank 2021-06-12 01:15:59 +09:00
rustc_symbol_mangling Revert "Merge CrateDisambiguator into StableCrateId" 2021-06-07 10:37:45 +02:00
rustc_target Use try_into instead of asserting manually 2021-06-07 01:27:40 +02:00
rustc_trait_selection Differentiate different defining uses of taits when they reference distinct generic parameters 2021-06-07 19:10:12 -03:00
rustc_traits Auto merge of #83207 - oli-obk:valtree2, r=lcnr 2021-04-02 10:28:12 +00:00
rustc_ty_utils Revert "Merge CrateDisambiguator into StableCrateId" 2021-06-07 10:37:45 +02:00
rustc_type_ir Remove unused feature gates 2021-05-31 13:55:43 +02:00
rustc_typeck Auto merge of #86118 - spastorino:tait-soundness-bug, r=nikomatsakis 2021-06-09 09:00:16 +00:00