Skip to content
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

Rollup of 5 pull requests #70451

Merged
merged 28 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ff65bff
Fix cycle error when emitting suggestion for mismatched `fn` type
Aaron1011 Mar 11, 2020
ef2957d
allowing getting &mut OsStr from OsString
TyPR124 Mar 16, 2020
21975a1
add comments about safety
TyPR124 Mar 16, 2020
cce8ee8
remove #[inline] for consistency in windows/os_str
TyPR124 Mar 16, 2020
16712ed
corrections on safety comments
TyPR124 Mar 16, 2020
e4a65e8
make safety comments more explicit
TyPR124 Mar 16, 2020
45416cd
add comment about maintaining OsStr encoding
TyPR124 Mar 20, 2020
f07802c
decouple rustc_hir::print from crate
Centril Mar 23, 2020
b60d732
rustc_hir: nix rustc_errors dep
Centril Mar 23, 2020
b3866a5
move rustc_hir::print -> rustc_hir_pretty
Centril Mar 23, 2020
92885e3
rustc_typeck: remove rustc_hir_pretty usage
Centril Mar 23, 2020
f1701dd
rustc: remove rustc_hir_pretty dependency.
Centril Mar 24, 2020
b514c42
trait_bound_spans -> sized_trait_bound_spans
Centril Mar 26, 2020
b2f7a95
rustc_hir_pretty: bump recursion_limit
Centril Mar 26, 2020
40a0fdc
Add regression test for #66706
Alexendoo Mar 26, 2020
15346ed
Remove `BitDenotation` framework
ecstatic-morse Feb 29, 2020
9978afb
Move `MoveDataParamEnv` to beginning of module
ecstatic-morse Feb 29, 2020
bae1114
Rename `dataflow::generic` to `dataflow::framework`
ecstatic-morse Feb 29, 2020
93ce5ff
Update use statements in `dataflow/mod.rs`
ecstatic-morse Feb 29, 2020
a8cc89f
Update imports from `dataflow::generic` to `dataflow`
ecstatic-morse Feb 29, 2020
7108cea
Move `BottomValue` into `framework/mod.rs`
ecstatic-morse Mar 2, 2020
fe0e7c3
Update `framework` module docs
ecstatic-morse Mar 2, 2020
89d6009
Make `framework` a private module
ecstatic-morse Mar 2, 2020
0f6144a
Rollup merge of #69644 - ecstatic-morse:unified-dataflow-cleanup, r=e…
Dylan-DPC Mar 27, 2020
f635c37
Rollup merge of #69936 - Aaron1011:fix/suggestion-cycle, r=varkor
Dylan-DPC Mar 27, 2020
c0369c4
Rollup merge of #70048 - TyPR124:mutable_osstr, r=dtolnay
Dylan-DPC Mar 27, 2020
7041efc
Rollup merge of #70344 - Centril:hir-pretty, r=eddyb
Dylan-DPC Mar 27, 2020
fa15774
Rollup merge of #70435 - Alexendoo:test-66706, r=Centril
Dylan-DPC Mar 27, 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
17 changes: 15 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3668,6 +3668,7 @@ dependencies = [
"rustc_errors",
"rustc_feature",
"rustc_hir",
"rustc_hir_pretty",
"rustc_interface",
"rustc_lint",
"rustc_metadata",
Expand Down Expand Up @@ -3742,9 +3743,7 @@ dependencies = [
"lazy_static 1.4.0",
"log",
"rustc_ast",
"rustc_ast_pretty",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
"rustc_macros",
"rustc_span",
Expand All @@ -3753,6 +3752,18 @@ dependencies = [
"smallvec 1.0.0",
]

[[package]]
name = "rustc_hir_pretty"
version = "0.0.0"
dependencies = [
"rustc_ast",
"rustc_ast_pretty",
"rustc_data_structures",
"rustc_hir",
"rustc_span",
"rustc_target",
]

[[package]]
name = "rustc_incremental"
version = "0.0.0"
Expand Down Expand Up @@ -3903,6 +3914,7 @@ dependencies = [
"rustc_errors",
"rustc_expand",
"rustc_hir",
"rustc_hir_pretty",
"rustc_index",
"rustc_session",
"rustc_span",
Expand Down Expand Up @@ -4087,6 +4099,7 @@ dependencies = [
"rustc_ast_pretty",
"rustc_data_structures",
"rustc_hir",
"rustc_hir_pretty",
"rustc_parse",
"rustc_session",
"rustc_span",
Expand Down
65 changes: 24 additions & 41 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
use rustc_hir::definitions::{DefKey, DefPath, Definitions};
use rustc_hir::intravisit;
use rustc_hir::itemlikevisit::ItemLikeVisitor;
use rustc_hir::print::Nested;
use rustc_hir::*;
use rustc_index::vec::IndexVec;
use rustc_span::hygiene::MacroKind;
Expand Down Expand Up @@ -890,20 +889,18 @@ impl<'hir> Map<'hir> {
}
}

/// Get a representation of this `id` for debugging purposes.
/// NOTE: Do NOT use this in diagnostics!
pub fn node_to_string(&self, id: HirId) -> String {
hir_id_to_string(self, id, true)
}

pub fn hir_to_user_string(&self, id: HirId) -> String {
hir_id_to_string(self, id, false)
}

pub fn hir_to_pretty_string(&self, id: HirId) -> String {
print::to_string(self, |s| s.print_node(self.get(id)))
hir_id_to_string(self, id)
}
}

impl<'hir> intravisit::Map<'hir> for Map<'hir> {
fn find(&self, hir_id: HirId) -> Option<Node<'hir>> {
self.find(hir_id)
}

fn body(&self, id: BodyId) -> &'hir Body<'hir> {
self.body(id)
}
Expand Down Expand Up @@ -982,23 +979,8 @@ pub(super) fn index_hir<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> &'tcx Indexe
tcx.arena.alloc(IndexedHir { crate_hash, map })
}

/// Identical to the `PpAnn` implementation for `hir::Crate`,
/// except it avoids creating a dependency on the whole crate.
impl<'hir> print::PpAnn for Map<'hir> {
fn nested(&self, state: &mut print::State<'_>, nested: print::Nested) {
match nested {
Nested::Item(id) => state.print_item(self.expect_item(id.id)),
Nested::TraitItem(id) => state.print_trait_item(self.trait_item(id)),
Nested::ImplItem(id) => state.print_impl_item(self.impl_item(id)),
Nested::Body(id) => state.print_expr(&self.body(id).value),
Nested::BodyParamPat(id, i) => state.print_pat(&self.body(id).params[i].pat),
}
}
}

fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
fn hir_id_to_string(map: &Map<'_>, id: HirId) -> String {
let id_str = format!(" (hir_id={})", id);
let id_str = if include_id { &id_str[..] } else { "" };

let path_str = || {
// This functionality is used for debugging, try to use `TyCtxt` to get
Expand All @@ -1019,6 +1001,9 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
})
};

let span_str = || map.tcx.sess.source_map().span_to_snippet(map.span(id)).unwrap_or_default();
let node_str = |prefix| format!("{} {}{}", prefix, span_str(), id_str);

match map.find(id) {
Some(Node::Item(item)) => {
let item_str = match item.kind {
Expand Down Expand Up @@ -1069,22 +1054,20 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
Some(Node::Field(ref field)) => {
format!("field {} in {}{}", field.ident, path_str(), id_str)
}
Some(Node::AnonConst(_)) => format!("const {}{}", map.hir_to_pretty_string(id), id_str),
Some(Node::Expr(_)) => format!("expr {}{}", map.hir_to_pretty_string(id), id_str),
Some(Node::Stmt(_)) => format!("stmt {}{}", map.hir_to_pretty_string(id), id_str),
Some(Node::PathSegment(_)) => {
format!("path segment {}{}", map.hir_to_pretty_string(id), id_str)
}
Some(Node::Ty(_)) => format!("type {}{}", map.hir_to_pretty_string(id), id_str),
Some(Node::TraitRef(_)) => format!("trait_ref {}{}", map.hir_to_pretty_string(id), id_str),
Some(Node::Binding(_)) => format!("local {}{}", map.hir_to_pretty_string(id), id_str),
Some(Node::Pat(_)) => format!("pat {}{}", map.hir_to_pretty_string(id), id_str),
Some(Node::Param(_)) => format!("param {}{}", map.hir_to_pretty_string(id), id_str),
Some(Node::Arm(_)) => format!("arm {}{}", map.hir_to_pretty_string(id), id_str),
Some(Node::Block(_)) => format!("block {}{}", map.hir_to_pretty_string(id), id_str),
Some(Node::Local(_)) => format!("local {}{}", map.hir_to_pretty_string(id), id_str),
Some(Node::AnonConst(_)) => node_str("const"),
Some(Node::Expr(_)) => node_str("expr"),
Some(Node::Stmt(_)) => node_str("stmt"),
Some(Node::PathSegment(_)) => node_str("path segment"),
Some(Node::Ty(_)) => node_str("type"),
Some(Node::TraitRef(_)) => node_str("trait ref"),
Some(Node::Binding(_)) => node_str("local"),
Some(Node::Pat(_)) => node_str("pat"),
Some(Node::Param(_)) => node_str("param"),
Some(Node::Arm(_)) => node_str("arm"),
Some(Node::Block(_)) => node_str("block"),
Some(Node::Local(_)) => node_str("local"),
Some(Node::Ctor(..)) => format!("ctor {}{}", path_str(), id_str),
Some(Node::Lifetime(_)) => format!("lifetime {}{}", map.hir_to_pretty_string(id), id_str),
Some(Node::Lifetime(_)) => node_str("lifetime"),
Some(Node::GenericParam(ref param)) => format!("generic_param {:?}{}", param, id_str),
Some(Node::Visibility(ref vis)) => format!("visibility {:?}{}", vis, id_str),
Some(Node::MacroDef(_)) => format!("macro {}{}", path_str(), id_str),
Expand Down
1 change: 1 addition & 0 deletions src/librustc_driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }
rustc_feature = { path = "../librustc_feature" }
rustc_hir = { path = "../librustc_hir" }
rustc_hir_pretty = { path = "../librustc_hir_pretty" }
rustc_metadata = { path = "../librustc_metadata" }
rustc_mir = { path = "../librustc_mir" }
rustc_parse = { path = "../librustc_parse" }
Expand Down
9 changes: 5 additions & 4 deletions src/librustc_driver/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_ast::ast;
use rustc_ast_pretty::pprust;
use rustc_hir as hir;
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_hir::print as pprust_hir;
use rustc_hir_pretty as pprust_hir;
use rustc_mir::util::{write_mir_graphviz, write_mir_pretty};
use rustc_session::config::{Input, PpMode, PpSourceMode};
use rustc_session::Session;
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<'hir> pprust::PpAnn for NoAnn<'hir> {}
impl<'hir> pprust_hir::PpAnn for NoAnn<'hir> {
fn nested(&self, state: &mut pprust_hir::State<'_>, nested: pprust_hir::Nested) {
if let Some(tcx) = self.tcx {
pprust_hir::PpAnn::nested(&tcx.hir(), state, nested)
pprust_hir::PpAnn::nested(&(&tcx.hir() as &dyn hir::intravisit::Map<'_>), state, nested)
}
}
}
Expand Down Expand Up @@ -228,7 +228,7 @@ impl<'hir> HirPrinterSupport<'hir> for IdentifiedAnnotation<'hir> {
impl<'hir> pprust_hir::PpAnn for IdentifiedAnnotation<'hir> {
fn nested(&self, state: &mut pprust_hir::State<'_>, nested: pprust_hir::Nested) {
if let Some(ref tcx) = self.tcx {
pprust_hir::PpAnn::nested(&tcx.hir(), state, nested)
pprust_hir::PpAnn::nested(&(&tcx.hir() as &dyn hir::intravisit::Map<'_>), state, nested)
}
}
fn pre(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) {
Expand Down Expand Up @@ -334,7 +334,8 @@ impl<'a, 'tcx> pprust_hir::PpAnn for TypedAnnotation<'a, 'tcx> {
if let pprust_hir::Nested::Body(id) = nested {
self.tables.set(self.tcx.body_tables(id));
}
pprust_hir::PpAnn::nested(&self.tcx.hir(), state, nested);
let pp_ann = &(&self.tcx.hir() as &dyn hir::intravisit::Map<'_>);
pprust_hir::PpAnn::nested(pp_ann, state, nested);
self.tables.set(old_tables);
}
fn pre(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) {
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_hir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ path = "lib.rs"
doctest = false

[dependencies]
rustc_ast_pretty = { path = "../librustc_ast_pretty" }
rustc_target = { path = "../librustc_target" }
rustc_macros = { path = "../librustc_macros" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_index = { path = "../librustc_index" }
rustc_span = { path = "../librustc_span" }
rustc_errors = { path = "../librustc_errors" }
rustc_serialize = { path = "../libserialize", package = "serialize" }
rustc_ast = { path = "../librustc_ast" }
lazy_static = "1"
Expand Down
Loading