From 76bef34575d67e7d9e9ed34949e7763a8cc546b0 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 20 Feb 2018 10:26:48 -0500 Subject: [PATCH 1/5] add outlives annotations to `BTreeMap` nll requires these annotations, I believe because of https://github.com/rust-lang/rust/issues/29149 --- src/liballoc/btree/map.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/liballoc/btree/map.rs b/src/liballoc/btree/map.rs index ed9c8c18f0d6d..31af101978fd4 100644 --- a/src/liballoc/btree/map.rs +++ b/src/liballoc/btree/map.rs @@ -149,12 +149,11 @@ unsafe impl<#[may_dangle] K, #[may_dangle] V> Drop for BTreeMap { #[stable(feature = "rust1", since = "1.0.0")] impl Clone for BTreeMap { fn clone(&self) -> BTreeMap { - fn clone_subtree(node: node::NodeRef) - -> BTreeMap { - + fn clone_subtree<'a, K: Clone, V: Clone>( + node: node::NodeRef, K, V, marker::LeafOrInternal> + ) -> BTreeMap + where K: 'a, V: 'a, + { match node.force() { Leaf(leaf) => { let mut out_tree = BTreeMap { @@ -1040,7 +1039,11 @@ impl BTreeMap { /// Calculates the number of elements if it is incorrect. fn recalc_length(&mut self) { - fn dfs(node: NodeRef) -> usize { + fn dfs<'a, K, V>( + node: NodeRef, K, V, marker::LeafOrInternal> + ) -> usize + where K: 'a, V: 'a + { let mut res = node.len(); if let Internal(node) = node.force() { From 9b3d104d258f9615e2653f09aa46e84a30a696e0 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 20 Feb 2018 10:27:23 -0500 Subject: [PATCH 2/5] work around rust-lang/rust#48070 for now --- src/librustc/lint/levels.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index 8a899a35ecb54..47d4f9f8dae5e 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -305,15 +305,16 @@ impl<'a> LintLevelsBuilder<'a> { forbidden_lint_name); diag_builder.span_label(lint_attr_span, "overruled by previous forbid"); match forbid_src { - LintSource::Default => &mut diag_builder, + LintSource::Default => { } LintSource::Node(_, forbid_source_span) => { diag_builder.span_label(forbid_source_span, - "`forbid` level set here") + "`forbid` level set here"); }, LintSource::CommandLine(_) => { - diag_builder.note("`forbid` lint level was set on command line") + diag_builder.note("`forbid` lint level was set on command line"); } - }.emit(); + } + diag_builder.emit(); // don't set a separate error for every lint in the group break } From fe44e5d71257dc52738383edf16a2bb1aadd7c01 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 20 Feb 2018 10:27:56 -0500 Subject: [PATCH 3/5] bump getopts for NLL --- src/bootstrap/Cargo.toml | 2 +- src/libtest/Cargo.toml | 2 +- src/tools/compiletest/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index 2d47834131784..08732b2a25dc5 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -33,7 +33,7 @@ build_helper = { path = "../build_helper" } cmake = "0.1.23" filetime = "0.1" num_cpus = "1.0" -getopts = "0.2" +getopts = "0.2.17" cc = "1.0.1" libc = "0.2" serde = "1.0.8" diff --git a/src/libtest/Cargo.toml b/src/libtest/Cargo.toml index ec77f95338081..c206576aff90b 100644 --- a/src/libtest/Cargo.toml +++ b/src/libtest/Cargo.toml @@ -9,5 +9,5 @@ path = "lib.rs" crate-type = ["dylib", "rlib"] [dependencies] -getopts = "0.2" +getopts = "0.2.17" term = { path = "../libterm" } diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index 7d02f0b746d95..8026aaeb46388 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -7,7 +7,7 @@ version = "0.0.0" diff = "0.1.10" env_logger = { version = "0.5", default-features = false } filetime = "0.1" -getopts = "0.2" +getopts = "0.2.17" log = "0.4" regex = "0.2" serde = "1.0" From 29f076020de7570863d20e452c01ea84370d6ef3 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 27 Feb 2018 16:28:35 -0500 Subject: [PATCH 4/5] work around #33684, which affects NLL more than the old typeck --- src/libsyntax/ext/quote.rs | 64 +++++++++---------- src/libsyntax/ext/source_util.rs | 32 +++++----- src/libsyntax_ext/cfg.rs | 4 +- src/libsyntax_ext/concat.rs | 9 +-- src/libsyntax_ext/trace_macros.rs | 9 +-- .../auxiliary/issue-16723.rs | 4 +- .../auxiliary/macro_crate_test.rs | 4 +- .../auxiliary/procedural_mbe_matching.rs | 4 +- .../syntax_extension_with_dll_deps_2.rs | 4 +- 9 files changed, 68 insertions(+), 66 deletions(-) diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 6844532e7b375..ac1fffbdc0a96 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -480,68 +480,68 @@ pub fn expand_quote_pat<'cx>(cx: &'cx mut ExtCtxt, base::MacEager::expr(expanded) } -pub fn expand_quote_arm(cx: &mut ExtCtxt, - sp: Span, - tts: &[TokenTree]) - -> Box { +pub fn expand_quote_arm<'cx>(cx: &'cx mut ExtCtxt, + sp: Span, + tts: &[TokenTree]) + -> Box { let expanded = expand_parse_call(cx, sp, "parse_arm_panic", vec![], tts); base::MacEager::expr(expanded) } -pub fn expand_quote_ty(cx: &mut ExtCtxt, - sp: Span, - tts: &[TokenTree]) - -> Box { +pub fn expand_quote_ty<'cx>(cx: &'cx mut ExtCtxt, + sp: Span, + tts: &[TokenTree]) + -> Box { let expanded = expand_parse_call(cx, sp, "parse_ty_panic", vec![], tts); base::MacEager::expr(expanded) } -pub fn expand_quote_stmt(cx: &mut ExtCtxt, - sp: Span, - tts: &[TokenTree]) - -> Box { +pub fn expand_quote_stmt<'cx>(cx: &'cx mut ExtCtxt, + sp: Span, + tts: &[TokenTree]) + -> Box { let expanded = expand_parse_call(cx, sp, "parse_stmt_panic", vec![], tts); base::MacEager::expr(expanded) } -pub fn expand_quote_attr(cx: &mut ExtCtxt, - sp: Span, - tts: &[TokenTree]) - -> Box { +pub fn expand_quote_attr<'cx>(cx: &'cx mut ExtCtxt, + sp: Span, + tts: &[TokenTree]) + -> Box { let expanded = expand_parse_call(cx, sp, "parse_attribute_panic", vec![cx.expr_bool(sp, true)], tts); base::MacEager::expr(expanded) } -pub fn expand_quote_arg(cx: &mut ExtCtxt, - sp: Span, - tts: &[TokenTree]) - -> Box { +pub fn expand_quote_arg<'cx>(cx: &'cx mut ExtCtxt, + sp: Span, + tts: &[TokenTree]) + -> Box { let expanded = expand_parse_call(cx, sp, "parse_arg_panic", vec![], tts); base::MacEager::expr(expanded) } -pub fn expand_quote_block(cx: &mut ExtCtxt, - sp: Span, - tts: &[TokenTree]) - -> Box { +pub fn expand_quote_block<'cx>(cx: &'cx mut ExtCtxt, + sp: Span, + tts: &[TokenTree]) + -> Box { let expanded = expand_parse_call(cx, sp, "parse_block_panic", vec![], tts); base::MacEager::expr(expanded) } -pub fn expand_quote_meta_item(cx: &mut ExtCtxt, - sp: Span, - tts: &[TokenTree]) - -> Box { +pub fn expand_quote_meta_item<'cx>(cx: &'cx mut ExtCtxt, + sp: Span, + tts: &[TokenTree]) + -> Box { let expanded = expand_parse_call(cx, sp, "parse_meta_item_panic", vec![], tts); base::MacEager::expr(expanded) } -pub fn expand_quote_path(cx: &mut ExtCtxt, - sp: Span, - tts: &[TokenTree]) - -> Box { +pub fn expand_quote_path<'cx>(cx: &'cx mut ExtCtxt, + sp: Span, + tts: &[TokenTree]) + -> Box { let mode = mk_parser_path(cx, sp, &["PathStyle", "Type"]); let expanded = expand_parse_call(cx, sp, "parse_path_panic", vec![mode], tts); base::MacEager::expr(expanded) diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index d6dce63ea5e4b..3850c446caeaa 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -31,8 +31,8 @@ use rustc_data_structures::sync::Lrc; // a given file into the current one. /// line!(): expands to the current line number -pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { +pub fn expand_line<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) + -> Box { base::check_zero_tts(cx, sp, tts, "line!"); let topmost = cx.expansion_cause().unwrap_or(sp); @@ -42,8 +42,8 @@ pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) } /* column!(): expands to the current column number */ -pub fn expand_column(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { +pub fn expand_column<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) + -> Box { base::check_zero_tts(cx, sp, tts, "column!"); let topmost = cx.expansion_cause().unwrap_or(sp); @@ -53,8 +53,8 @@ pub fn expand_column(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) } /* __rust_unstable_column!(): expands to the current column number */ -pub fn expand_column_gated(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { +pub fn expand_column_gated<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) + -> Box { if sp.allows_unstable() { expand_column(cx, sp, tts) } else { @@ -65,8 +65,8 @@ pub fn expand_column_gated(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::Token /// file!(): expands to the current filename */ /// The filemap (`loc.file`) contains a bunch more information we could spit /// out if we wanted. -pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { +pub fn expand_file<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) + -> Box { base::check_zero_tts(cx, sp, tts, "file!"); let topmost = cx.expansion_cause().unwrap_or(sp); @@ -74,14 +74,14 @@ pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) base::MacEager::expr(cx.expr_str(topmost, Symbol::intern(&loc.file.name.to_string()))) } -pub fn expand_stringify(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { +pub fn expand_stringify<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) + -> Box { let s = pprust::tts_to_string(tts); base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&s))) } -pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { +pub fn expand_mod<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) + -> Box { base::check_zero_tts(cx, sp, tts, "module_path!"); let mod_path = &cx.current_expansion.module.mod_path; let string = mod_path.iter().map(|x| x.to_string()).collect::>().join("::"); @@ -130,8 +130,8 @@ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::T } // include_str! : read the given file, insert it as a literal string expr -pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { +pub fn expand_include_str<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) + -> Box { let file = match get_single_str_from_tts(cx, sp, tts, "include_str!") { Some(f) => f, None => return DummyResult::expr(sp) @@ -165,8 +165,8 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenT } } -pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { +pub fn expand_include_bytes<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) + -> Box { let file = match get_single_str_from_tts(cx, sp, tts, "include_bytes!") { Some(f) => f, None => return DummyResult::expr(sp) diff --git a/src/libsyntax_ext/cfg.rs b/src/libsyntax_ext/cfg.rs index 1eeba9b30b8e2..0602a78ae9678 100644 --- a/src/libsyntax_ext/cfg.rs +++ b/src/libsyntax_ext/cfg.rs @@ -20,10 +20,10 @@ use syntax::tokenstream; use syntax::parse::token; use syntax_pos::Span; -pub fn expand_cfg<'cx>(cx: &mut ExtCtxt, +pub fn expand_cfg<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) - -> Box { + -> Box { let sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark)); let mut p = cx.new_parser_from_tts(tts); let cfg = panictry!(p.parse_meta_item()); diff --git a/src/libsyntax_ext/concat.rs b/src/libsyntax_ext/concat.rs index c79e7867c5f5e..eea66a48eec4b 100644 --- a/src/libsyntax_ext/concat.rs +++ b/src/libsyntax_ext/concat.rs @@ -17,10 +17,11 @@ use syntax::tokenstream; use std::string::String; -pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, - sp: syntax_pos::Span, - tts: &[tokenstream::TokenTree]) - -> Box { +pub fn expand_syntax_ext<'cx>( + cx: &'cx mut base::ExtCtxt, + sp: syntax_pos::Span, + tts: &[tokenstream::TokenTree] +) -> Box { let es = match base::get_exprs_from_tts(cx, sp, tts) { Some(e) => e, None => return base::DummyResult::expr(sp), diff --git a/src/libsyntax_ext/trace_macros.rs b/src/libsyntax_ext/trace_macros.rs index 48be8e0c53c2e..3b70e46014025 100644 --- a/src/libsyntax_ext/trace_macros.rs +++ b/src/libsyntax_ext/trace_macros.rs @@ -15,10 +15,11 @@ use syntax::symbol::keywords; use syntax_pos::Span; use syntax::tokenstream::TokenTree; -pub fn expand_trace_macros(cx: &mut ExtCtxt, - sp: Span, - tt: &[TokenTree]) - -> Box { +pub fn expand_trace_macros<'cx>( + cx: &'cx mut ExtCtxt, + sp: Span, + tt: &[TokenTree] +) -> Box { if !cx.ecfg.enable_trace_macros() { feature_gate::emit_feature_err(&cx.parse_sess, "trace_macros", diff --git a/src/test/run-pass-fulldeps/auxiliary/issue-16723.rs b/src/test/run-pass-fulldeps/auxiliary/issue-16723.rs index 7f8a741465b30..f5977bde23b49 100644 --- a/src/test/run-pass-fulldeps/auxiliary/issue-16723.rs +++ b/src/test/run-pass-fulldeps/auxiliary/issue-16723.rs @@ -29,8 +29,8 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_macro("multiple_items", expand) } -fn expand(cx: &mut ExtCtxt, _: syntax_pos::Span, _: &[tokenstream::TokenTree]) - -> Box { +fn expand<'cx>(cx: &'cx mut ExtCtxt, _: syntax_pos::Span, _: &[tokenstream::TokenTree]) + -> Box { MacEager::items(SmallVector::many(vec![ quote_item!(cx, struct Struct1;).unwrap(), quote_item!(cx, struct Struct2;).unwrap() diff --git a/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs b/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs index aa2f1626a6a86..e8ffc825a4f92 100644 --- a/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs +++ b/src/test/run-pass-fulldeps/auxiliary/macro_crate_test.rs @@ -47,7 +47,7 @@ pub fn plugin_registrar(reg: &mut Registry) { MultiDecorator(Box::new(expand_caller))); } -fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box { +fn expand_make_a_1<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box { if !tts.is_empty() { cx.span_fatal(sp, "make_a_1 takes no arguments"); } @@ -55,7 +55,7 @@ fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box Box { +fn expand_identity<'cx>(cx: &'cx mut ExtCtxt, _span: Span, tts: &[TokenTree]) -> Box { // Parse an expression and emit it unchanged. let mut parser = parse::new_parser_from_tts(cx.parse_sess(), tts.to_vec()); let expr = parser.parse_expr().unwrap(); diff --git a/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs b/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs index fd8f7b9e384f3..17939ab512c0f 100644 --- a/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs +++ b/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs @@ -34,8 +34,8 @@ use rustc_plugin::Registry; use std::cell::RefCell; -fn expand_mbe_matches(cx: &mut ExtCtxt, _: Span, args: &[TokenTree]) - -> Box { +fn expand_mbe_matches<'cx>(cx: &'cx mut ExtCtxt, _: Span, args: &[TokenTree]) + -> Box { let mbe_matcher = quote_tokens!(cx, $$matched:expr, $$($$pat:pat)|+); let mbe_matcher = quoted::parse(mbe_matcher.into_iter().collect(), diff --git a/src/test/run-pass-fulldeps/auxiliary/syntax_extension_with_dll_deps_2.rs b/src/test/run-pass-fulldeps/auxiliary/syntax_extension_with_dll_deps_2.rs index 72d2628535556..e8118815a44bd 100644 --- a/src/test/run-pass-fulldeps/auxiliary/syntax_extension_with_dll_deps_2.rs +++ b/src/test/run-pass-fulldeps/auxiliary/syntax_extension_with_dll_deps_2.rs @@ -30,8 +30,8 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_macro("foo", expand_foo); } -fn expand_foo(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) - -> Box { +fn expand_foo(cx: &'cx mut ExtCtxt, sp: Span, tts: &[TokenTree]) + -> Box { let answer = other::the_answer(); MacEager::expr(quote_expr!(cx, $answer)) } From 0fb1c95577335b24993ab6d2d27403fd70a2e94c Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 28 Feb 2018 04:08:48 -0500 Subject: [PATCH 5/5] work around #48598 --- src/librustc_passes/rvalue_promotion.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_passes/rvalue_promotion.rs b/src/librustc_passes/rvalue_promotion.rs index 356ad9ec11bb7..6d560fa261f0e 100644 --- a/src/librustc_passes/rvalue_promotion.rs +++ b/src/librustc_passes/rvalue_promotion.rs @@ -166,7 +166,8 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckCrateVisitor<'a, 'tcx> { let tcx = self.tcx; let param_env = self.param_env; let region_scope_tree = self.tcx.region_scope_tree(item_def_id); - euv::ExprUseVisitor::new(self, tcx, param_env, ®ion_scope_tree, self.tables, None) + let tables = self.tables; // FIXME(#48598) + euv::ExprUseVisitor::new(self, tcx, param_env, ®ion_scope_tree, tables, None) .consume_body(body); self.visit_body(body);