From 9c33ab8589507f90390461208399ba6bac88be6f Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Tue, 8 Dec 2020 21:39:53 -0800 Subject: [PATCH 01/10] Fixes #78136 --- library/core/src/macros/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 0699c9eab1871..e4f893117e51e 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -647,8 +647,8 @@ macro_rules! unimplemented { #[macro_export] #[stable(feature = "todo_macro", since = "1.40.0")] macro_rules! todo { - () => ($crate::panic!("not yet implemented")); - ($($arg:tt)+) => ($crate::panic!("not yet implemented: {}", $crate::format_args!($($arg)+))); + () => (#![allow(unused_variables)] $crate::panic!("not yet implemented")); + ($($arg:tt)+) => (#![allow(unused_variables)] $crate::panic!("not yet implemented: {}", $crate::format_args!($($arg)+))); } /// Definitions of built-in macros. From f17b775fe4bc1d2c6eb0e8d6b01b425c5e0f5079 Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Wed, 9 Dec 2020 18:31:40 -0800 Subject: [PATCH 02/10] Reverted changes to todo! macro. Instead, added compiler logic to detect the panic emitted by todo and skip checking for unused variables. --- compiler/rustc_passes/src/liveness.rs | 47 ++++++++++++++++++++++++--- library/core/src/macros/mod.rs | 4 +-- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index ad059c05a7634..ecd4bc38e359e 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -84,14 +84,14 @@ use self::LiveNodeKind::*; use self::VarKind::*; -use rustc_ast::InlineAsmOptions; +use rustc_ast::{InlineAsmOptions, LitKind, StrStyle}; use rustc_data_structures::fx::FxIndexMap; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::def::*; use rustc_hir::def_id::LocalDefId; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; -use rustc_hir::{Expr, HirId, HirIdMap, HirIdSet}; +use rustc_hir::{Expr, ExprKind, QPath, HirId, HirIdMap, HirIdSet}; use rustc_index::vec::IndexVec; use rustc_middle::hir::map::Map; use rustc_middle::ty::query::Providers; @@ -328,7 +328,44 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { } } } - + + // Allow todo! macro + /* + Skips checking for unused variables when the trailing expression + of the body is core::panicking::panic("not yet implemented"), ie + as emitted by todo!(). + + # Example + + fn foo(x: i32) { + // arbitrary code + todo!() + } + */ + if let ExprKind::Block(block, _) = &body.value.kind { + if let Some(expr) = block.expr { + if let ExprKind::Call(call, [arg]) = expr.kind { + if let ExprKind::Path(QPath::Resolved(_, path)) = call.kind { + if matches!(&path.res, Res::Def(DefKind::Fn, _)) { + // FIXME: Better way of extracting literal + let debug = format!("{:?}", &path.res); + if (debug.contains("std[") || debug.contains("core[")) + && debug.contains("]::panicking::panic)") { + if let ExprKind::Lit(spanned) = &arg.kind { + if let LitKind::Str(symbol, StrStyle::Cooked) = spanned.node { + // FIXME: Better way of matching symbol + if &*symbol.as_str() == "not yet implemented" { + return; + } + } + } + } + } + } + } + } + } + if let Some(captures) = maps.tcx.typeck(local_def_id).closure_captures.get(&def_id) { for &var_hir_id in captures.keys() { let var_name = maps.tcx.hir().name(var_hir_id); @@ -1665,7 +1702,7 @@ impl<'tcx> Liveness<'_, 'tcx> { hir_ids_and_spans.iter().map(|(_, sp)| *sp).collect::>(), |lint| { let mut err = lint.build(&format!("unused variable: `{}`", name)); - + let (shorthands, non_shorthands): (Vec<_>, Vec<_>) = hir_ids_and_spans.into_iter().partition(|(hir_id, span)| { let var = self.variable(*hir_id, *span); @@ -1703,7 +1740,7 @@ impl<'tcx> Liveness<'_, 'tcx> { Applicability::MachineApplicable, ); } - + err.emit() }, ); diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index e4f893117e51e..0699c9eab1871 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -647,8 +647,8 @@ macro_rules! unimplemented { #[macro_export] #[stable(feature = "todo_macro", since = "1.40.0")] macro_rules! todo { - () => (#![allow(unused_variables)] $crate::panic!("not yet implemented")); - ($($arg:tt)+) => (#![allow(unused_variables)] $crate::panic!("not yet implemented: {}", $crate::format_args!($($arg)+))); + () => ($crate::panic!("not yet implemented")); + ($($arg:tt)+) => ($crate::panic!("not yet implemented: {}", $crate::format_args!($($arg)+))); } /// Definitions of built-in macros. From 5047cb4bae0583be2d41eae278a34fedd0429304 Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Wed, 9 Dec 2020 18:55:03 -0800 Subject: [PATCH 03/10] rustfmt --- compiler/rustc_passes/src/liveness.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index ecd4bc38e359e..1560c0471756a 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -91,7 +91,7 @@ use rustc_hir as hir; use rustc_hir::def::*; use rustc_hir::def_id::LocalDefId; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; -use rustc_hir::{Expr, ExprKind, QPath, HirId, HirIdMap, HirIdSet}; +use rustc_hir::{Expr, ExprKind, HirId, HirIdMap, HirIdSet, QPath}; use rustc_index::vec::IndexVec; use rustc_middle::hir::map::Map; use rustc_middle::ty::query::Providers; @@ -328,15 +328,15 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { } } } - + // Allow todo! macro - /* + /* Skips checking for unused variables when the trailing expression of the body is core::panicking::panic("not yet implemented"), ie as emitted by todo!(). - - # Example - + + # Example + fn foo(x: i32) { // arbitrary code todo!() @@ -350,7 +350,8 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { // FIXME: Better way of extracting literal let debug = format!("{:?}", &path.res); if (debug.contains("std[") || debug.contains("core[")) - && debug.contains("]::panicking::panic)") { + && debug.contains("]::panicking::panic)") + { if let ExprKind::Lit(spanned) = &arg.kind { if let LitKind::Str(symbol, StrStyle::Cooked) = spanned.node { // FIXME: Better way of matching symbol @@ -359,13 +360,13 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { } } } - } + } } } } } - } - + } + if let Some(captures) = maps.tcx.typeck(local_def_id).closure_captures.get(&def_id) { for &var_hir_id in captures.keys() { let var_name = maps.tcx.hir().name(var_hir_id); @@ -1702,7 +1703,7 @@ impl<'tcx> Liveness<'_, 'tcx> { hir_ids_and_spans.iter().map(|(_, sp)| *sp).collect::>(), |lint| { let mut err = lint.build(&format!("unused variable: `{}`", name)); - + let (shorthands, non_shorthands): (Vec<_>, Vec<_>) = hir_ids_and_spans.into_iter().partition(|(hir_id, span)| { let var = self.variable(*hir_id, *span); @@ -1740,7 +1741,7 @@ impl<'tcx> Liveness<'_, 'tcx> { Applicability::MachineApplicable, ); } - + err.emit() }, ); From ece724b20eec832241fe5990c1e26bf2255c6022 Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Fri, 11 Dec 2020 12:22:13 -0800 Subject: [PATCH 04/10] Added ui test --- .../ui/unused/allow-unused-variables-with-todo.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/test/ui/unused/allow-unused-variables-with-todo.rs diff --git a/src/test/ui/unused/allow-unused-variables-with-todo.rs b/src/test/ui/unused/allow-unused-variables-with-todo.rs new file mode 100644 index 0000000000000..7917094647d91 --- /dev/null +++ b/src/test/ui/unused/allow-unused-variables-with-todo.rs @@ -0,0 +1,11 @@ +// check-pass + +#[deny(unused_variables)] +fn foo(x: i32, y: i32) -> i32 { + let z = x + y; + todo!() +} + +fn main() { + foo(0, 1); +} From efbd426c4a75ab15e757fa1f03a94f501e0a764a Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Thu, 14 Jan 2021 23:03:11 -0800 Subject: [PATCH 05/10] Update compiler/rustc_passes/src/liveness.rs Co-authored-by: Camelid --- compiler/rustc_passes/src/liveness.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index 1560c0471756a..2ce9a7b93428d 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -346,12 +346,10 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { if let Some(expr) = block.expr { if let ExprKind::Call(call, [arg]) = expr.kind { if let ExprKind::Path(QPath::Resolved(_, path)) = call.kind { - if matches!(&path.res, Res::Def(DefKind::Fn, _)) { - // FIXME: Better way of extracting literal - let debug = format!("{:?}", &path.res); - if (debug.contains("std[") || debug.contains("core[")) - && debug.contains("]::panicking::panic)") - { + if matches!(&path.res, Res::Def(DefKind::Fn, path_def_id)) { + let begin_panic_def_id = self.tcx.lang_items().begin_panic_fn(); + if begin_panic_def_id == Some(path_def_id) { + // FIXME: Better way of extracting literal if let ExprKind::Lit(spanned) = &arg.kind { if let LitKind::Str(symbol, StrStyle::Cooked) = spanned.node { // FIXME: Better way of matching symbol From fa1c16601723074510d9ce1ee8e72efa0a0a6f98 Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Fri, 15 Jan 2021 01:10:46 -0800 Subject: [PATCH 06/10] Added support for message with todo! --- compiler/rustc_passes/src/liveness.rs | 8 +++----- src/test/ui/unused/allow-unused-variables-with-todo.rs | 6 ++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index 2ce9a7b93428d..1b440ab8f4881 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -346,14 +346,12 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { if let Some(expr) = block.expr { if let ExprKind::Call(call, [arg]) = expr.kind { if let ExprKind::Path(QPath::Resolved(_, path)) = call.kind { - if matches!(&path.res, Res::Def(DefKind::Fn, path_def_id)) { + if let Res::Def(DefKind::Fn, path_def_id) = &path.res { let begin_panic_def_id = self.tcx.lang_items().begin_panic_fn(); - if begin_panic_def_id == Some(path_def_id) { - // FIXME: Better way of extracting literal + if begin_panic_def_id == Some(*path_def_id) { if let ExprKind::Lit(spanned) = &arg.kind { if let LitKind::Str(symbol, StrStyle::Cooked) = spanned.node { - // FIXME: Better way of matching symbol - if &*symbol.as_str() == "not yet implemented" { + if symbol.as_str().starts_with("not yet implemented") { return; } } diff --git a/src/test/ui/unused/allow-unused-variables-with-todo.rs b/src/test/ui/unused/allow-unused-variables-with-todo.rs index 7917094647d91..0c826ae454637 100644 --- a/src/test/ui/unused/allow-unused-variables-with-todo.rs +++ b/src/test/ui/unused/allow-unused-variables-with-todo.rs @@ -6,6 +6,12 @@ fn foo(x: i32, y: i32) -> i32 { todo!() } +#[deny(unused_variables)] +fn bar(x: i32, y: i32) -> i32 { + todo!("Some message") +} + fn main() { foo(0, 1); + bar(0, 1); } From 0d99f8314c7a92fd70649f65a5d24e8c3ea70c21 Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Sun, 17 Jan 2021 14:11:00 -0800 Subject: [PATCH 07/10] Confirmed support for todo with panic messages. Added additional ui tests. --- compiler/rustc_passes/src/liveness.rs | 16 +++++++++---- .../allow-unused-variables-with-todo.rs | 23 +++++++++++++++---- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index 1b440ab8f4881..c44079fea6957 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -332,8 +332,7 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { // Allow todo! macro /* Skips checking for unused variables when the trailing expression - of the body is core::panicking::panic("not yet implemented"), ie - as emitted by todo!(). + of the body is a panic with a message that contains "not yet implemented". # Example @@ -347,14 +346,23 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { if let ExprKind::Call(call, [arg]) = expr.kind { if let ExprKind::Path(QPath::Resolved(_, path)) = call.kind { if let Res::Def(DefKind::Fn, path_def_id) = &path.res { - let begin_panic_def_id = self.tcx.lang_items().begin_panic_fn(); - if begin_panic_def_id == Some(*path_def_id) { + let panic_fn = self.tcx.lang_items().panic_fn(); + // Note: there is no function for panic_fmt, so we have to extract it from the debug output :( + // builder doesn't like this being called without panic `self.tcx.def_path_str(*path_def_id);` + let path_str = format!("{:?}", path_def_id); + if Some(*path_def_id) == panic_fn + || ((path_str.contains("std[") || path_str.contains("core[")) + && path_str.contains("panicking::panic")) + { if let ExprKind::Lit(spanned) = &arg.kind { if let LitKind::Str(symbol, StrStyle::Cooked) = spanned.node { if symbol.as_str().starts_with("not yet implemented") { return; } } + } else if format!("{:?}", &arg.kind).contains("not yet implemented") + { + return; } } } diff --git a/src/test/ui/unused/allow-unused-variables-with-todo.rs b/src/test/ui/unused/allow-unused-variables-with-todo.rs index 0c826ae454637..6891292f5494c 100644 --- a/src/test/ui/unused/allow-unused-variables-with-todo.rs +++ b/src/test/ui/unused/allow-unused-variables-with-todo.rs @@ -1,17 +1,30 @@ // check-pass #[deny(unused_variables)] -fn foo(x: i32, y: i32) -> i32 { +fn plain(x: i32, y: i32) -> i32 { + todo!() +} + +#[deny(unused_variables)] +fn message(x: i32, y: i32) -> i32 { + todo!("message") +} + +#[deny(unused_variables)] +fn statement(x: i32, y: i32) -> i32 { let z = x + y; todo!() } #[deny(unused_variables)] -fn bar(x: i32, y: i32) -> i32 { - todo!("Some message") +fn statement_message(x: i32, y: i32) -> i32 { + let z = x + y; + todo!("message") } fn main() { - foo(0, 1); - bar(0, 1); + plain(0, 1); + message(0, 1); + statement(0, 1); + statement_message(0, 1); } From d827888cb9745e5958c2e6103fd1f82899faa962 Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Sun, 4 Apr 2021 12:55:20 -0700 Subject: [PATCH 08/10] Merge of master. --- library/backtrace | 2 +- library/stdarch | 2 +- src/doc/book | 2 +- src/doc/edition-guide | 2 +- src/doc/embedded-book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- src/doc/rustc-dev-guide | 2 +- src/llvm-project | 2 +- src/tools/cargo | 2 +- src/tools/miri | 2 +- src/tools/rls | 2 +- src/tools/rust-analyzer | 2 +- src/tools/rust-installer | 2 +- src/tools/rustfmt | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/library/backtrace b/library/backtrace index af078ecc0b069..710fc18ddcb6c 160000 --- a/library/backtrace +++ b/library/backtrace @@ -1 +1 @@ -Subproject commit af078ecc0b069ec594982f92d4c6c58af99efbb5 +Subproject commit 710fc18ddcb6c7677b3c96359abb35da37f2a488 diff --git a/library/stdarch b/library/stdarch index 777efaf564470..9c732a56f67f5 160000 --- a/library/stdarch +++ b/library/stdarch @@ -1 +1 @@ -Subproject commit 777efaf5644706b36706a7a5c51edb63835e05ca +Subproject commit 9c732a56f67f54d12a0b4fd99993154906c95ea6 diff --git a/src/doc/book b/src/doc/book index a190438d77d28..b54090a99ec7c 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit a190438d77d28041f24da4f6592e287fab073a61 +Subproject commit b54090a99ec7c4b46a5203a9c927fdbc311bb1f5 diff --git a/src/doc/edition-guide b/src/doc/edition-guide index b91a9a881ee00..1da3c411f17ad 160000 --- a/src/doc/edition-guide +++ b/src/doc/edition-guide @@ -1 +1 @@ -Subproject commit b91a9a881ee007c12e74e844460ec407cf07a50f +Subproject commit 1da3c411f17adb1ba5de1683bb6acee83362b54a diff --git a/src/doc/embedded-book b/src/doc/embedded-book index ba34b8a968f95..d3f2ace94d516 160000 --- a/src/doc/embedded-book +++ b/src/doc/embedded-book @@ -1 +1 @@ -Subproject commit ba34b8a968f9531d38c4dc4411d5568b7c076bfe +Subproject commit d3f2ace94d51610cf3e3c265705bb8416d37f8e4 diff --git a/src/doc/nomicon b/src/doc/nomicon index d8383b65f7948..6fe476943afd5 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit d8383b65f7948c2ca19191b3b4bd709b403aaf45 +Subproject commit 6fe476943afd53a9a6e91f38a6ea7bb48811d8ff diff --git a/src/doc/reference b/src/doc/reference index a8afdca5d0715..fd97729e2d82f 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit a8afdca5d0715b2257b6f8b9a032fd4dd7dae855 +Subproject commit fd97729e2d82f8b08d68a31c9bfdf0c37a7fd542 diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index 236c734a2cb32..29d91f591c90d 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit 236c734a2cb323541b3394f98682cb981b9ec086 +Subproject commit 29d91f591c90dd18fdca6d23f1a9caf9c139d0d7 diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide index 7adfab42bab04..0687daac28939 160000 --- a/src/doc/rustc-dev-guide +++ b/src/doc/rustc-dev-guide @@ -1 +1 @@ -Subproject commit 7adfab42bab045a848126895c2f1e09927c1331a +Subproject commit 0687daac28939c476df51778f5a1d1aff1a3fddf diff --git a/src/llvm-project b/src/llvm-project index 7ade8dc4b8414..0abbcc04d8375 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 7ade8dc4b84142abd3e6d1fb8a0f4111b0bbd571 +Subproject commit 0abbcc04d8375661a0637896b9ae5dc37a99dc70 diff --git a/src/tools/cargo b/src/tools/cargo index d274fcf862b89..3c44c3c4b7900 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit d274fcf862b89264fa2c6b917b15230705257317 +Subproject commit 3c44c3c4b7900b8b13c85ead25ccaa8abb7d8989 diff --git a/src/tools/miri b/src/tools/miri index e54c5db4f0edb..2cdd1744b896e 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit e54c5db4f0edbe51db42d2c3e63e9821537ed4f4 +Subproject commit 2cdd1744b896e8129322229f253f95fd7ad491f1 diff --git a/src/tools/rls b/src/tools/rls index 2cf84baa5e3c5..fd1df1554a22a 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 2cf84baa5e3c55ac02f42919e67440acb5417125 +Subproject commit fd1df1554a22accde727e8c4bdeb2a065627d10c diff --git a/src/tools/rust-analyzer b/src/tools/rust-analyzer index 0d03fe6ef57d3..bb1d925dab363 160000 --- a/src/tools/rust-analyzer +++ b/src/tools/rust-analyzer @@ -1 +1 @@ -Subproject commit 0d03fe6ef57d3956e92382e0e1f1a916015191cb +Subproject commit bb1d925dab36372c6bd1fb5671bb68ce938ff009 diff --git a/src/tools/rust-installer b/src/tools/rust-installer index d66f476b4d5e7..5254dbfd25d52 160000 --- a/src/tools/rust-installer +++ b/src/tools/rust-installer @@ -1 +1 @@ -Subproject commit d66f476b4d5e7fdf1ec215c9ac16c923dc292324 +Subproject commit 5254dbfd25d5284728ab624dca1969d61427a0db diff --git a/src/tools/rustfmt b/src/tools/rustfmt index 70ce18255f429..7de6968ee2269 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit 70ce18255f429caf0d75ecfed8c1464535ee779b +Subproject commit 7de6968ee22696b7feb6b477a05656de89275291 From 2398721e8310bc10ad6e10487fd5c99d6414ff29 Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Sun, 4 Apr 2021 13:44:14 -0700 Subject: [PATCH 09/10] Fix merge. --- compiler/rustc_passes/src/liveness.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index 0ef933524abf2..89009233dc6fb 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -332,7 +332,6 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { } } -<<<<<<< HEAD // Allow todo! macro /* Skips checking for unused variables when the trailing expression @@ -376,9 +375,6 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { } if let Some(captures) = maps.tcx.typeck(local_def_id).closure_captures.get(&def_id) { -======= - if let Some(captures) = maps.tcx.typeck(local_def_id).closure_min_captures.get(&def_id) { ->>>>>>> master for &var_hir_id in captures.keys() { let var_name = maps.tcx.hir().name(var_hir_id); maps.add_variable(Upvar(var_hir_id, var_name)); From 28588957c29f50bf5fd395d70c24b9474d75c0c0 Mon Sep 17 00:00:00 2001 From: charles-r-earp Date: Sun, 4 Apr 2021 13:51:59 -0700 Subject: [PATCH 10/10] Fixed unrelated "closure_min_captures" after todo! changes. --- compiler/rustc_passes/src/liveness.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index 89009233dc6fb..cd29caf304429 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -374,7 +374,7 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { } } - if let Some(captures) = maps.tcx.typeck(local_def_id).closure_captures.get(&def_id) { + if let Some(captures) = maps.tcx.typeck(local_def_id).closure_min_captures.get(&def_id) { for &var_hir_id in captures.keys() { let var_name = maps.tcx.hir().name(var_hir_id); maps.add_variable(Upvar(var_hir_id, var_name));