8000 Rollup of 9 pull requests by RalfJung · Pull Request #72203 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 9 pull requests #72203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cb27039
Use min_specialization in liballoc
matthewjasper Apr 19, 2020
e5a1be8
Use `LocalDefId` in `DumpVisitor::nest_tables`
marmeladema May 2, 2020
3471bc8
Fix unused_parens false positive when using binary operations
mibac138 May 4, 2020
717a7a8
Update src/test/ui/lint/issue-71290-unused-paren-binop.rs
mibac138 May 5, 2020
4b7a928
Fix unused_parens nested binary op false positive
mibac138 May 5, 2020
1fce203
expand "incomplete feature" message to include unsoundness and link t…
RalfJung May 9, 2020
6a8cf4a
adjust tests
RalfJung Apr 22, 2020
c400f75
Miri interning: replace ICEs by proper errors, make intern_shallow ty…
RalfJung Apr 29, 2020
8e48a30
remove some dead code, and assert we do not swallow allocating errors
RalfJung Apr 29, 2020
ff39457
avoid raising interpreter errors from interning
RalfJung Apr 29, 2020
d3b2e1f
fmt
RalfJung Apr 29, 2020
a06740c
Typo
RalfJung Apr 29, 2020
e73ee41
rebase fallout
RalfJung May 4, 2020
5e35493
cargo update -p serde_derive
Xanewok May 5, 2020
403a9d0 8000
cargo update -p failure_derive
Xanewok May 5, 2020
8c6e568
cargo update -p pest_generator
Xanewok May 5, 2020
3bdaced
cargo update -p derive-new
Xanewok May 5, 2020
e26f35d
rustbook: Bump mdbook dependency
Xanewok May 5, 2020
9111d8b
Fix the new capacity measurement in arenas.
nnethercote May 4, 2020
40d4868
Be less aggressive with `DroplessArena`/`TypedArena` growth.
nnethercote May 4, 2020
31fbf33
Clean up E0589 explanation
GuillaumeGomez May 14, 2020
f6aa161
Don't ICE on missing `Unsize` impl
cofibrant May 14, 2020
73c227c
Rollup merge of #71321 - matthewjasper:alloc-min-spec, r=sfackler
RalfJung May 14, 2020
47960fe
Rollup merge of #71665 - RalfJung:miri-intern-no-ice, r=oli-obk
RalfJung May 14, 2020
ef55dc0
Rollup merge of #71809 - marmeladema:fix-issue-71104, r=eddyb
RalfJung May 14, 2020
8bd2319
Rollup merge of #71872 - nnethercote:less-aggressive-arena-growth, r=…
RalfJung May 14, 2020
91cd222
Rollup merge of #71910 - mibac138:necessary-paren, r=cuviper
RalfJung May 14, 2020
30811cf
Rollup merge of #71919 - Xanewok:bump-syn-1, r=Mark-Simulacrum
RalfJung May 14, 2020
c038ea1
Rollup merge of #72045 - RalfJung:incomplete-unsound, r=petrochenkov
RalfJung May 14, 2020
8cc6147
Rollup merge of #72191 - GuillaumeGomez:cleanup-e0589, r=Dylan-DPC
RalfJung May 14, 2020
2b03aa2
Rollup merge of #72194 - doctorn:dispatch-from-dyn-ice, r=estebank
RalfJung May 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 41 additions & 29 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use rustc_ast::walk_list;
use rustc_ast_pretty::pprust::{bounds_to_string, generic_params_to_string, ty_to_string};
use rustc_data_structures::fx::FxHashSet;
use rustc_hir::def::{DefKind as HirDefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::span_bug;
use rustc_middle::ty::{self, DefIdTree, TyCtxt};
use rustc_session::config::Input;
Expand Down Expand Up @@ -104,12 +104,10 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
self.dumper.analysis()
}

fn nest_tables<F>(&mut self, item_id: NodeId, f: F)
fn nest_tables<F>(&mut self, item_def_id: LocalDefId, f: F)
where
F: FnOnce(&mut Self),
{
let item_def_id = self.tcx.hir().local_def_id_from_node_id(item_id);

let tables = if self.tcx.has_typeck_tables(item_def_id) {
self.tcx.typeck_tables_of(item_def_id)
} else {
Expand Down Expand Up @@ -272,8 +270,9 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
) {
debug!("process_method: {}:{}", id, ident);

let hir_id = self.tcx.hir().node_id_to_hir_id(id);
self.nest_tables(id, |v| {
let map = &self.tcx.hir();
let hir_id = map.node_id_to_hir_id(id);
self.nest_tables(map.local_def_id(hir_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);
Expand All @@ -296,7 +295,8 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
// start walking from the newly-created definition.
match sig.header.asyncness {
ast::Async::Yes { return_impl_trait_id, .. } => {
v.nest_tables(return_impl_trait_id, |v| v.visit_ty(ret_ty))
let hir_id = map.node_id_to_hir_id(return_impl_trait_id);
v.nest_tables(map.local_def_id(hir_id), |v| v.visit_ty(ret_ty))
}
_ => v.visit_ty(ret_ty),
}
Expand Down Expand Up @@ -364,8 +364,9 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
ty_params: &'l ast::Generics,
body: Option<&'l ast::Block>,
) {
let hir_id = self.tcx.hir().node_id_to_hir_id(item.id);
self.nest_tables(item.id, |v| {
let map = &self.tcx.hir();
let hir_id = map.node_id_to_hir_id(item.id);
self.nest_tables(map.local_def_id(hir_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);
Expand All @@ -389,7 +390,8 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
// start walking from the newly-created definition.
match header.asyncness {
ast::Async::Yes { return_impl_trait_id, .. } => {
v.nest_tables(return_impl_trait_id, |v| v.visit_ty(ret_ty))
let hir_id = map.node_id_to_hir_id(return_impl_trait_id);
v.nest_tables(map.local_def_id(hir_id), |v| v.visit_ty(ret_ty))
}
_ => v.visit_ty(ret_ty),
}
Expand All @@ -407,7 +409,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
expr: Option<&'l ast::Expr>,
) {
let hir_id = self.tcx.hir().node_id_to_hir_id(item.id);
self.nest_tables(item.id, |v| {
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
if let Some(var_data) = v.save_ctxt.get_item_data(item) {
down_cast_data!(var_data, DefData, item.span);
v.dumper.dump_def(&access_from!(v.save_ctxt, item, hir_id), var_data);
Expand All @@ -427,15 +429,13 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
vis: ast::Visibility,
attrs: &'l [Attribute],
) {
let qualname = format!(
"::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(id).to_def_id())
);
let hir_id = self.tcx.hir().node_id_to_hir_id(id);
let qualname =
format!("::{}", self.tcx.def_path_str(self.tcx.hir().local_def_id(hir_id).to_def_id()));

if !self.span.filter_generated(ident.span) {
let sig = sig::assoc_const_signature(id, ident.name, typ, expr, &self.save_ctxt);
let span = self.span_from_span(ident.span);
let hir_id = self.tcx.hir().node_id_to_hir_id(id);

self.dumper.dump_def(
&access_from_vis!(self.save_ctxt, vis, hir_id),
Expand All @@ -457,7 +457,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
}

// walk type and init value
self.nest_tables(id, |v| {
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
v.visit_ty(typ);
if let Some(expr) = expr {
v.visit_expr(expr);
Expand All @@ -474,10 +474,9 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
) {
debug!("process_struct {:?} {:?}", item, item.span);
let name = item.ident.to_string();
let qualname = format!(
"::{}",
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id).to_def_id())
);
let hir_id = self.tcx.hir().node_id_to_hir_id(item.id);
let qualname =
format!("::{}", self.tcx.def_path_str(self.tcx.hir().local_def_id(hir_id).to_def_id()));

let kind = match item.kind {
ast::ItemKind::Struct(_, _) => DefKind::Struct,
Expand Down Expand Up @@ -509,7 +508,6 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {

if !self.span.filter_generated(item.ident.span) {
let span = self.span_from_span(item.ident.span);
let hir_id = self.tcx.hir().node_id_to_hir_id(item.id);
self.dumper.dump_def(
&access_from!(self.save_ctxt, item, hir_id),
Def {
Expand All @@ -529,7 +527,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
);
}

self.nest_tables(item.id, |v| {
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
for field in def.fields() {
v.process_struct_field_def(field, item.id);
v.visit_ty(&field.ty);
Expand Down Expand Up @@ -669,14 +667,15 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
}

let map = &self.tcx.hir();
self.nest_tables(item.id, |v| {
let hir_id = map.node_id_to_hir_id(item.id);
self.nest_tables(map.local_def_id(hir_id), |v| {
v.visit_ty(&typ);
if let &Some(ref trait_ref) = trait_ref {
v.process_path(trait_ref.ref_id, &trait_ref.path);
}
v.process_generic_params(generics, "", item.id);
for impl_item in impl_items {
v.process_impl_item(impl_item, map.local_def_id_from_node_id(item.id).to_def_id());
v.process_impl_item(impl_item, map.local_def_id(hir_id).to_def_id());
}
});
}
Expand Down Expand Up @@ -1411,7 +1410,10 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
}
ast::TyKind::Array(ref element, ref length) => {
self.visit_ty(element);
self.nest_tables(length.id, |v| v.visit_expr(&length.value));
let hir_id = self.tcx.hir().node_id_to_hir_id(length.id);
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
v.visit_expr(&length.value)
});
}
ast::TyKind::ImplTrait(id, ref bounds) => {
// FIXME: As of writing, the opaque type lowering introduces
Expand All @@ -1423,7 +1425,13 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
// bounds...
// This will panic if called on return type `impl Trait`, which
// we guard against in `process_fn`.
self.nest_tables(id, |v| v.process_bounds(bounds));
// FIXME(#71104) Should really be using just `node_id_to_hir_id` but
// some `NodeId` do not seem to have a corresponding HirId.
if let Some(hir_id) = self.tcx.hir().opt_node_id_to_hir_id(id) {
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
v.process_bounds(bounds)
});
}
}
_ => visit::walk_ty(self, t),
}
Expand Down Expand Up @@ -1471,7 +1479,8 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
}

// walk the body
self.nest_tables(ex.id, |v| {
let hir_id = self.tcx.hir().node_id_to_hir_id(ex.id);
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
v.process_formals(&decl.inputs, &id);
v.visit_expr(body)
});
Expand All @@ -1488,7 +1497,10 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
}
ast::ExprKind::Repeat(ref element, ref count) => {
self.visit_expr(element);
self.nest_tables(count.id, |v| v.visit_expr(&count.value));
let hir_id = self.tcx.hir().node_id_to_hir_id(count.id);
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
v.visit_expr(&count.value)
});
}
// In particular, we take this branch for call and path expressions,
// where we'll index the idents involved just by continuing to walk.
Expand Down
7 changes: 0 additions & 7 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,13 +831,6 @@ fn primary_body_of(
}

fn has_typeck_tables(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
// FIXME(#71104) some `LocalDefId` do not seem to have a corresponding `HirId`.
if let Some(def_id) = def_id.as_local() {
if tcx.hir().opt_local_def_id_to_hir_id(def_id).is_none() {
return false;
}
}

// Closures' tables come from their outermost function,
// as they are part of the same "inference environment".
let outer_def_id = tcx.closure_base_def_id(def_id);
Expand Down
0