From f6ae4a4f068a2b320d2c857dac6a984ffc213b37 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Sat, 7 Sep 2019 19:46:30 +0200 Subject: [PATCH 1/2] Always validate HIR ID for TypeckTables ...and not only with `debug_assertions` compiled in --- src/librustc/ty/context.rs | 4 ++-- src/tools/clippy | 2 +- src/tools/miri | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 17c9e520bcea2..5f7af12651376 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -207,7 +207,7 @@ pub struct LocalTableInContext<'a, V> { fn validate_hir_id_for_typeck_tables(local_id_root: Option, hir_id: hir::HirId, mut_access: bool) { - if cfg!(debug_assertions) { + // if cfg!(debug_assertions) { if let Some(local_id_root) = local_id_root { if hir_id.owner != local_id_root.index { ty::tls::with(|tcx| { @@ -228,7 +228,7 @@ fn validate_hir_id_for_typeck_tables(local_id_root: Option, bug!("access to invalid TypeckTables") } } - } + // } } impl<'a, V> LocalTableInContext<'a, V> { diff --git a/src/tools/clippy b/src/tools/clippy index 5f28fda13efeb..aeadf1562c024 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit 5f28fda13efeb85097fe082af4b4827a58b0ecf6 +Subproject commit aeadf1562c024d3c5421e61dc6b8d48c2d7902f5 diff --git a/src/tools/miri b/src/tools/miri index e479ab26406ed..69268fb75fdb4 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit e479ab26406ed8a473987e5f4a1f3be3e978e5d2 +Subproject commit 69268fb75fdb452296caa9bc4aaeff1674279de2 From 9bc434c6ee0e4452e61fc3aa98dc9b364207bf37 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Thu, 5 Sep 2019 20:51:22 +0200 Subject: [PATCH 2/2] save-analysis: Nest typeck tables when processing functions/methods Fixes an issue where we did not nest tables correctly when resolving associated types in formal argument/return type positions --- src/librustc_save_analysis/dump_visitor.rs | 80 ++++++++++------------ 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 12c5ce12a0e8b..135f13499436c 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -283,36 +283,32 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { ) { debug!("process_method: {}:{}", id, ident); - if let Some(mut method_data) = self.save_ctxt.get_method_data(id, ident, span) { - let sig_str = crate::make_signature(&sig.decl, &generics); - if body.is_some() { - self.nest_tables( - id, - |v| v.process_formals(&sig.decl.inputs, &method_data.qualname), - ); - } + let hir_id = self.tcx.hir().node_to_hir_id(id); + self.nest_tables(id, |v| { + if let Some(mut method_data) = v.save_ctxt.get_method_data(id, ident, span) { + v.process_formals(&sig.decl.inputs, &method_data.qualname); + v.process_generic_params(&generics, &method_data.qualname, id); - self.process_generic_params(&generics, &method_data.qualname, id); + method_data.value = crate::make_signature(&sig.decl, &generics); + method_data.sig = sig::method_signature(id, ident, generics, sig, &v.save_ctxt); - method_data.value = sig_str; - method_data.sig = sig::method_signature(id, ident, generics, sig, &self.save_ctxt); - let hir_id = self.tcx.hir().node_to_hir_id(id); - self.dumper.dump_def(&access_from_vis!(self.save_ctxt, vis, hir_id), method_data); - } + v.dumper.dump_def(&access_from_vis!(v.save_ctxt, vis, hir_id), method_data); + } - // walk arg and return types - for arg in &sig.decl.inputs { - self.visit_ty(&arg.ty); - } + // walk arg and return types + for arg in &sig.decl.inputs { + v.visit_ty(&arg.ty); + } - if let ast::FunctionRetTy::Ty(ref ret_ty) = sig.decl.output { - self.visit_ty(ret_ty); - } + if let ast::FunctionRetTy::Ty(ref ret_ty) = sig.decl.output { + v.visit_ty(ret_ty); + } - // walk the fn body - if let Some(body) = body { - self.nest_tables(id, |v| v.visit_block(body)); - } + // walk the fn body + if let Some(body) = body { + v.visit_block(body); + } + }); } fn process_struct_field_def(&mut self, field: &ast::StructField, parent_id: NodeId) { @@ -377,26 +373,26 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { ty_params: &'l ast::Generics, body: &'l ast::Block, ) { - if let Some(fn_data) = self.save_ctxt.get_item_data(item) { - down_cast_data!(fn_data, DefData, item.span); - self.nest_tables( - item.id, - |v| v.process_formals(&decl.inputs, &fn_data.qualname), - ); - self.process_generic_params(ty_params, &fn_data.qualname, item.id); - let hir_id = self.tcx.hir().node_to_hir_id(item.id); - self.dumper.dump_def(&access_from!(self.save_ctxt, item, hir_id), fn_data); - } + let hir_id = self.tcx.hir().node_to_hir_id(item.id); + self.nest_tables(item.id, |v| { + if let Some(fn_data) = v.save_ctxt.get_item_data(item) { + down_cast_data!(fn_data, DefData, item.span); + v.process_formals(&decl.inputs, &fn_data.qualname); + v.process_generic_params(ty_params, &fn_data.qualname, item.id); - for arg in &decl.inputs { - self.visit_ty(&arg.ty); - } + v.dumper.dump_def(&access_from!(v.save_ctxt, item, hir_id), fn_data); + } - if let ast::FunctionRetTy::Ty(ref ret_ty) = decl.output { - self.visit_ty(&ret_ty); - } + for arg in &decl.inputs { + v.visit_ty(&arg.ty) + } - self.nest_tables(item.id, |v| v.visit_block(&body)); + if let ast::FunctionRetTy::Ty(ref ret_ty) = decl.output { + v.visit_ty(&ret_ty); + } + + v.visit_block(&body); + }); } fn process_static_or_const_item(