From 447ae7612aacb356dd3f1dd018aaa350c0493a2e Mon Sep 17 00:00:00 2001 From: David Wood Date: Thu, 22 Mar 2018 22:48:39 +0000 Subject: [PATCH] Added flag to disable user type assertion. --- src/librustc/session/config.rs | 2 ++ src/librustc_mir/build/matches/mod.rs | 2 ++ src/test/run-pass/generator/yield-subtype.rs | 1 + 3 files changed, 5 insertions(+) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 0d91074e946b..c47a351e9d39 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1251,6 +1251,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "choose which RELRO level to use"), nll: bool = (false, parse_bool, [UNTRACKED], "run the non-lexical lifetimes MIR pass"), + disable_nll_user_type_assert: bool = (false, parse_bool, [UNTRACKED], + "disable user provided type assertion in NLL"), trans_time_graph: bool = (false, parse_bool, [UNTRACKED], "generate a graphical HTML report of time spent in trans and LLVM"), thinlto: Option = (None, parse_opt_bool, [TRACKED], diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index b9a6616fd076..7eb52a3cdee9 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -147,6 +147,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { pub fn user_assert_ty(&mut self, block: BasicBlock, hir_id: hir::HirId, var: NodeId, span: Span) { + if self.hir.tcx().sess.opts.debugging_opts.disable_nll_user_type_assert { return; } + let local_id = self.var_indices[&var]; let source_info = self.source_info(span); diff --git a/src/test/run-pass/generator/yield-subtype.rs b/src/test/run-pass/generator/yield-subtype.rs index 7e8a0d1e2b92..c41341690441 100644 --- a/src/test/run-pass/generator/yield-subtype.rs +++ b/src/test/run-pass/generator/yield-subtype.rs @@ -9,6 +9,7 @@ // except according to those terms. // revisions:lexical nll +//[nll]compile-flags: -Z disable-nll-user-type-assert #![cfg_attr(nll, feature(nll))] #![feature(generators)]