Skip to content

Commit 2b2986d

Browse files
committed
Gate more precise generator auto traits behind feature
1 parent bea0a42 commit 2b2986d

File tree

7 files changed

+25
-0
lines changed

7 files changed

+25
-0
lines changed

src/librustc/query/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,10 @@ rustc_queries! {
931931
query all_traits(_: CrateNum) -> &'tcx [DefId] {
932932
desc { "fetching all foreign and local traits" }
933933
}
934+
935+
query uses_generator_mir_traits(_: CrateNum) -> bool {
936+
desc { "determining whether crate uses generator MIR traits" }
937+
}
934938
}
935939

936940
Linking {

src/librustc/traits/select.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,6 +2753,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
27532753
}
27542754

27552755
ty::GeneratorWitness(did, types) => {
2756+
let use_mir = if did.is_local() {
2757+
self.tcx().features().generator_mir_traits
2758+
} else {
2759+
self.tcx().uses_generator_mir_traits(did.krate)
2760+
};
2761+
2762+
if !use_mir {
2763+
// This is sound because no regions in the witness can refer to
2764+
// the binder outside the witness. So we'll effectivly reuse
2765+
// the implicit binder around the witness.
2766+
return types.skip_binder().to_vec()
2767+
}
27562768
// Note that we need to use optimized_mir here,
27572769
// in order to have the `StateTransform` pass run
27582770
/*let gen_mir = self.tcx().optimized_mir(did);

src/librustc_feature/active.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,8 @@ declare_features! (
526526
/// Allows using `&mut` in constant functions.
527527
(active, const_mut_refs, "1.41.0", Some(57349), None),
528528

529+
(active, generator_mir_traits, "1.41.0", None, None),
530+
529531
// -------------------------------------------------------------------------
530532
// feature-group-end: actual feature gates
531533
// -------------------------------------------------------------------------

src/librustc_metadata/rmeta/decoder/cstore_impl.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ provide! { <'tcx> tcx, def_id, other, cdata,
240240

241241
Arc::new(syms)
242242
}
243+
244+
uses_generator_mir_traits => {
245+
cdata.root.generator_mir_traits
246+
}
243247
}
244248

245249
pub fn provide(providers: &mut Providers<'_>) {

src/librustc_metadata/rmeta/encoder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ impl<'tcx> EncodeContext<'tcx> {
544544
exported_symbols,
545545
interpret_alloc_index,
546546
per_def,
547+
generator_mir_traits: tcx.features().generator_mir_traits
547548
});
548549

549550
let total_bytes = self.position();

src/librustc_metadata/rmeta/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ crate struct CrateRoot<'tcx> {
214214
profiler_runtime: bool,
215215
sanitizer_runtime: bool,
216216
symbol_mangling_version: SymbolManglingVersion,
217+
generator_mir_traits: bool
217218
}
218219

219220
#[derive(RustcEncodable, RustcDecodable)]

src/libsyntax_pos/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ symbols! {
334334
FxHashSet,
335335
FxHashMap,
336336
gen_future,
337+
generator_mir_traits,
337338
generators,
338339
generic_associated_types,
339340
generic_param_attrs,

0 commit comments

Comments
 (0)