Encode optimized MIR of generators when emitting metadata
This commit is contained in:
parent
c7b0ddbffe
commit
ea4cbff264
@ -1507,7 +1507,10 @@ fn encode_info_for_closure(&mut self, def_id: LocalDefId) {
|
||||
record!(self.tables.fn_sig[def_id] <- substs.as_closure().sig());
|
||||
}
|
||||
self.encode_generics(def_id.to_def_id());
|
||||
let opt_mir = self.tcx.sess.opts.debugging_opts.always_encode_mir || self.emit_codegen_mir;
|
||||
let opt_mir = // FIXME: Optimized MIR is necessary to determine the layout of generators.
|
||||
matches!(ty.kind(), ty::Generator(..))
|
||||
|| self.tcx.sess.opts.debugging_opts.always_encode_mir
|
||||
|| self.emit_codegen_mir;
|
||||
if opt_mir {
|
||||
self.encode_optimized_mir(def_id);
|
||||
self.encode_promoted_mir(def_id);
|
||||
|
@ -0,0 +1,11 @@
|
||||
// compile-flags: --emit metadata
|
||||
#![feature(generators, generator_trait)]
|
||||
|
||||
use std::marker::Unpin;
|
||||
use std::ops::Generator;
|
||||
|
||||
pub fn g() -> impl Generator<(), Yield = (), Return = ()> {
|
||||
|| {
|
||||
yield;
|
||||
}
|
||||
}
|
23
src/test/ui/generator/metadata-sufficient-for-layout.rs
Normal file
23
src/test/ui/generator/metadata-sufficient-for-layout.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// Check that the layout of a generator is available when auxiliary crate
|
||||
// is compiled with --emit metadata.
|
||||
//
|
||||
// Regression test for #80998.
|
||||
//
|
||||
// aux-build:metadata-sufficient-for-layout.rs
|
||||
// check-pass
|
||||
|
||||
#![feature(type_alias_impl_trait)]
|
||||
#![feature(generator_trait)]
|
||||
|
||||
extern crate metadata_sufficient_for_layout;
|
||||
|
||||
use std::ops::Generator;
|
||||
|
||||
type F = impl Generator<(), Yield = (), Return = ()>;
|
||||
|
||||
// Static queries the layout of the generator.
|
||||
static A: Option<F> = None;
|
||||
|
||||
fn f() -> F { metadata_sufficient_for_layout::g() }
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user