summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-03-27 01:23:53 +0100
committerGitHub <noreply@github.com>2020-03-27 01:23:53 +0100
commit7041efcfc3f771f5fe72aede1af69180683df286 (patch)
treeba8326824b275236cda90185b84b4463f7b9e1be
parentRollup merge of #70048 - TyPR124:mutable_osstr, r=dtolnay (diff)
parentrustc_hir_pretty: bump recursion_limit (diff)
downloadrust-7041efcfc3f771f5fe72aede1af69180683df286.tar.gz
rust-7041efcfc3f771f5fe72aede1af69180683df286.tar.bz2
rust-7041efcfc3f771f5fe72aede1af69180683df286.tar.xz
Rollup merge of #70344 - Centril:hir-pretty, r=eddyb
Decouple `rustc_hir::print` into `rustc_hir_pretty` High level summary: - The HIR pretty printer, `rustc_hir::print` is moved into a new crate `rustc_hir_pretty`. - `rustc_ast_pretty` and `rustc_errors` are dropped as `rustc_hir` dependencies. - The dependence on HIR pretty is generally reduced, leaving `rustc_save_analysis`, `rustdoc`, `rustc_metadata`, and `rustc_driver` as the remaining clients. The main goal here is to reduce `rustc_hir`'s dependencies and its size such that it can start and finish earlier, thereby working towards https://github.com/rust-lang/rust/issues/65031. r? @Zoxc
-rw-r--r--Cargo.lock17
-rw-r--r--src/librustc/hir/map/mod.rs65
-rw-r--r--src/librustc_driver/Cargo.toml1
-rw-r--r--src/librustc_driver/pretty.rs9
-rw-r--r--src/librustc_hir/Cargo.toml2
-rw-r--r--src/librustc_hir/hir.rs98
-rw-r--r--src/librustc_hir/intravisit.rs5
-rw-r--r--src/librustc_hir/lib.rs2
-rw-r--r--src/librustc_hir_pretty/Cargo.toml18
-rw-r--r--src/librustc_hir_pretty/lib.rs (renamed from src/librustc_hir/print.rs)56
-rw-r--r--src/librustc_metadata/Cargo.toml1
-rw-r--r--src/librustc_metadata/rmeta/encoder.rs13
-rw-r--r--src/librustc_passes/liveness.rs18
-rw-r--r--src/librustc_privacy/lib.rs16
-rw-r--r--src/librustc_save_analysis/Cargo.toml5
-rw-r--r--src/librustc_save_analysis/lib.rs7
-rw-r--r--src/librustc_trait_selection/traits/error_reporting/mod.rs3
-rw-r--r--src/librustc_trait_selection/traits/object_safety.rs45
-rw-r--r--src/librustc_typeck/astconv.rs15
-rw-r--r--src/librustc_typeck/check/_match.rs9
-rw-r--r--src/librustc_typeck/check/callee.rs22
-rw-r--r--src/librustc_typeck/check/coercion.rs9
-rw-r--r--src/librustc_typeck/check/demand.rs19
-rw-r--r--src/librustc_typeck/check/expr.rs51
-rw-r--r--src/librustc_typeck/check/method/suggest.rs2
-rw-r--r--src/librustc_typeck/check/mod.rs6
-rw-r--r--src/librustc_typeck/check/pat.rs37
-rw-r--r--src/librustc_typeck/check_unused.rs14
-rw-r--r--src/librustc_typeck/collect.rs9
-rw-r--r--src/librustdoc/clean/inline.rs4
-rw-r--r--src/librustdoc/clean/utils.rs2
-rw-r--r--src/librustdoc/lib.rs1
-rw-r--r--src/librustdoc/test.rs2
-rw-r--r--src/test/ui/methods/method-path-in-pattern.stderr6
-rw-r--r--src/test/ui/privacy/associated-item-privacy-trait.rs6
-rw-r--r--src/test/ui/privacy/associated-item-privacy-trait.stderr4
-rw-r--r--src/test/ui/qualified/qualified-path-params.stderr2
37 files changed, 288 insertions, 313 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 8bf6198..f1fa913 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3668,6 +3668,7 @@ dependencies = [
3668 "rustc_errors", 3668 "rustc_errors",
3669 "rustc_feature", 3669 "rustc_feature",
3670 "rustc_hir", 3670 "rustc_hir",
3671 "rustc_hir_pretty",
3671 "rustc_interface", 3672 "rustc_interface",
3672 "rustc_lint", 3673 "rustc_lint",
3673 "rustc_metadata", 3674 "rustc_metadata",
@@ -3742,9 +3743,7 @@ dependencies = [
3742 "lazy_static 1.4.0", 3743 "lazy_static 1.4.0",
3743 "log", 3744 "log",
3744 "rustc_ast", 3745 "rustc_ast",
3745 "rustc_ast_pretty",
3746 "rustc_data_structures", 3746 "rustc_data_structures",
3747 "rustc_errors",
3748 "rustc_index", 3747 "rustc_index",
3749 "rustc_macros", 3748 "rustc_macros",
3750 "rustc_span", 3749 "rustc_span",
@@ -3754,6 +3753,18 @@ dependencies = [
3754] 3753]
3755 3754
3756[[package]] 3755[[package]]
3756name = "rustc_hir_pretty"
3757version = "0.0.0"
3758dependencies = [
3759 "rustc_ast",
3760 "rustc_ast_pretty",
3761 "rustc_data_structures",
3762 "rustc_hir",
3763 "rustc_span",
3764 "rustc_target",
3765]
3766
3767[[package]]
3757name = "rustc_incremental" 3768name = "rustc_incremental"
3758version = "0.0.0" 3769version = "0.0.0"
3759dependencies = [ 3770dependencies = [
@@ -3903,6 +3914,7 @@ dependencies = [
3903 "rustc_errors", 3914 "rustc_errors",
3904 "rustc_expand", 3915 "rustc_expand",
3905 "rustc_hir", 3916 "rustc_hir",
3917 "rustc_hir_pretty",
3906 "rustc_index", 3918 "rustc_index",
3907 "rustc_session", 3919 "rustc_session",
3908 "rustc_span", 3920 "rustc_span",
@@ -4087,6 +4099,7 @@ dependencies = [
4087 "rustc_ast_pretty", 4099 "rustc_ast_pretty",
4088 "rustc_data_structures", 4100 "rustc_data_structures",
4089 "rustc_hir", 4101 "rustc_hir",
4102 "rustc_hir_pretty",
4090 "rustc_parse", 4103 "rustc_parse",
4091 "rustc_session", 4104 "rustc_session",
4092 "rustc_span", 4105 "rustc_span",
diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs
index 6290f5b..bc42ac1 100644
--- a/src/librustc/hir/map/mod.rs
+++ b/src/librustc/hir/map/mod.rs
@@ -10,7 +10,6 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
10use rustc_hir::definitions::{DefKey, DefPath, Definitions}; 10use rustc_hir::definitions::{DefKey, DefPath, Definitions};
11use rustc_hir::intravisit; 11use rustc_hir::intravisit;
12use rustc_hir::itemlikevisit::ItemLikeVisitor; 12use rustc_hir::itemlikevisit::ItemLikeVisitor;
13use rustc_hir::print::Nested;
14use rustc_hir::*; 13use rustc_hir::*;
15use rustc_index::vec::IndexVec; 14use rustc_index::vec::IndexVec;
16use rustc_span::hygiene::MacroKind; 15use rustc_span::hygiene::MacroKind;
@@ -890,20 +889,18 @@ impl<'hir> Map<'hir> {
890 } 889 }
891 } 890 }
892 891
892 /// Get a representation of this `id` for debugging purposes.
893 /// NOTE: Do NOT use this in diagnostics!
893 pub fn node_to_string(&self, id: HirId) -> String { 894 pub fn node_to_string(&self, id: HirId) -> String {
894 hir_id_to_string(self, id, true) 895 hir_id_to_string(self, id)
895 }
896
897 pub fn hir_to_user_string(&self, id: HirId) -> String {
898 hir_id_to_string(self, id, false)
899 }
900
901 pub fn hir_to_pretty_string(&self, id: HirId) -> String {
902 print::to_string(self, |s| s.print_node(self.get(id)))
903 } 896 }
904} 897}
905 898
906impl<'hir> intravisit::Map<'hir> for Map<'hir> { 899impl<'hir> intravisit::Map<'hir> for Map<'hir> {
900 fn find(&self, hir_id: HirId) -> Option<Node<'hir>> {
901 self.find(hir_id)
902 }
903
907 fn body(&self, id: BodyId) -> &'hir Body<'hir> { 904 fn body(&self, id: BodyId) -> &'hir Body<'hir> {
908 self.body(id) 905 self.body(id)
909 } 906 }
@@ -982,23 +979,8 @@ pub(super) fn index_hir<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> &'tcx Indexe
982 tcx.arena.alloc(IndexedHir { crate_hash, map }) 979 tcx.arena.alloc(IndexedHir { crate_hash, map })
983} 980}
984 981
985/// Identical to the `PpAnn` implementation for `hir::Crate`, 982fn hir_id_to_string(map: &Map<'_>, id: HirId) -> String {
986/// except it avoids creating a dependency on the whole crate.
987impl<'hir> print::PpAnn for Map<'hir> {
988 fn nested(&self, state: &mut print::State<'_>, nested: print::Nested) {
989 match nested {
990 Nested::Item(id) => state.print_item(self.expect_item(id.id)),
991 Nested::TraitItem(id) => state.print_trait_item(self.trait_item(id)),
992 Nested::ImplItem(id) => state.print_impl_item(self.impl_item(id)),
993 Nested::Body(id) => state.print_expr(&self.body(id).value),
994 Nested::BodyParamPat(id, i) => state.print_pat(&self.body(id).params[i].pat),
995 }
996 }
997}
998
999fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
1000 let id_str = format!(" (hir_id={})", id); 983 let id_str = format!(" (hir_id={})", id);
1001 let id_str = if include_id { &id_str[..] } else { "" };
1002 984
1003 let path_str = || { 985 let path_str = || {
1004 // This functionality is used for debugging, try to use `TyCtxt` to get 986 // This functionality is used for debugging, try to use `TyCtxt` to get
@@ -1019,6 +1001,9 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
1019 }) 1001 })
1020 }; 1002 };
1021 1003
1004 let span_str = || map.tcx.sess.source_map().span_to_snippet(map.span(id)).unwrap_or_default();
1005 let node_str = |prefix| format!("{} {}{}", prefix, span_str(), id_str);
1006
1022 match map.find(id) { 1007 match map.find(id) {
1023 Some(Node::Item(item)) => { 1008 Some(Node::Item(item)) => {
1024 let item_str = match item.kind { 1009 let item_str = match item.kind {
@@ -1069,22 +1054,20 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
1069 Some(Node::Field(ref field)) => { 1054 Some(Node::Field(ref field)) => {
1070 format!("field {} in {}{}", field.ident, path_str(), id_str) 1055 format!("field {} in {}{}", field.ident, path_str(), id_str)
1071 } 1056 }
1072 Some(Node::AnonConst(_)) => format!("const {}{}", map.hir_to_pretty_string(id), id_str), 1057 Some(Node::AnonConst(_)) => node_str("const"),
1073 Some(Node::Expr(_)) => format!("expr {}{}", map.hir_to_pretty_string(id), id_str), 1058 Some(Node::Expr(_)) => node_str("expr"),
1074 Some(Node::Stmt(_)) => format!("stmt {}{}", map.hir_to_pretty_string(id), id_str), 1059 Some(Node::Stmt(_)) => node_str("stmt"),
1075 Some(Node::PathSegment(_)) => { 1060 Some(Node::PathSegment(_)) => node_str("path segment"),
1076 format!("path segment {}{}", map.hir_to_pretty_string(id), id_str) 1061 Some(Node::Ty(_)) => node_str("type"),
1077 } 1062 Some(Node::TraitRef(_)) => node_str("trait ref"),
1078 Some(Node::Ty(_)) => format!("type {}{}", map.hir_to_pretty_string(id), id_str), 1063 Some(Node::Binding(_)) => node_str("local"),
1079 Some(Node::TraitRef(_)) => format!("trait_ref {}{}", map.hir_to_pretty_string(id), id_str), 1064 Some(Node::Pat(_)) => node_str("pat"),
1080 Some(Node::Binding(_)) => format!("local {}{}", map.hir_to_pretty_string(id), id_str), 1065 Some(Node::Param(_)) => node_str("param"),
1081 Some(Node::Pat(_)) => format!("pat {}{}", map.hir_to_pretty_string(id), id_str), 1066 Some(Node::Arm(_)) => node_str("arm"),
1082 Some(Node::Param(_)) => format!("param {}{}", map.hir_to_pretty_string(id), id_str), 1067 Some(Node::Block(_)) => node_str("block"),
1083 Some(Node::Arm(_)) => format!("arm {}{}", map.hir_to_pretty_string(id), id_str), 1068 Some(Node::Local(_)) => node_str("local"),
1084 Some(Node::Block(_)) => format!("block {}{}", map.hir_to_pretty_string(id), id_str),
1085 Some(Node::Local(_)) => format!("local {}{}", map.hir_to_pretty_string(id), id_str),
1086 Some(Node::Ctor(..)) => format!("ctor {}{}", path_str(), id_str), 1069 Some(Node::Ctor(..)) => format!("ctor {}{}", path_str(), id_str),
1087 Some(Node::Lifetime(_)) => format!("lifetime {}{}", map.hir_to_pretty_string(id), id_str), 1070 Some(Node::Lifetime(_)) => node_str("lifetime"),
1088 Some(Node::GenericParam(ref param)) => format!("generic_param {:?}{}", param, id_str), 1071 Some(Node::GenericParam(ref param)) => format!("generic_param {:?}{}", param, id_str),
1089 Some(Node::Visibility(ref vis)) => format!("visibility {:?}{}", vis, id_str), 1072 Some(Node::Visibility(ref vis)) => format!("visibility {:?}{}", vis, id_str),
1090 Some(Node::MacroDef(_)) => format!("macro {}{}", path_str(), id_str), 1073 Some(Node::MacroDef(_)) => format!("macro {}{}", path_str(), id_str),
diff --git a/src/librustc_driver/Cargo.toml b/src/librustc_driver/Cargo.toml
index aec10ee..3ca39b2 100644
--- a/src/librustc_driver/Cargo.toml
+++ b/src/librustc_driver/Cargo.toml
@@ -21,6 +21,7 @@ rustc_data_structures = { path = "../librustc_data_structures" }
21rustc_errors = { path = "../librustc_errors" } 21rustc_errors = { path = "../librustc_errors" }
22rustc_feature = { path = "../librustc_feature" } 22rustc_feature = { path = "../librustc_feature" }
23rustc_hir = { path = "../librustc_hir" } 23rustc_hir = { path = "../librustc_hir" }
24rustc_hir_pretty = { path = "../librustc_hir_pretty" }
24rustc_metadata = { path = "../librustc_metadata" } 25rustc_metadata = { path = "../librustc_metadata" }
25rustc_mir = { path = "../librustc_mir" } 26rustc_mir = { path = "../librustc_mir" }
26rustc_parse = { path = "../librustc_parse" } 27rustc_parse = { path = "../librustc_parse" }
diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs
index 1e5cc55..a57a70e 100644
--- a/src/librustc_driver/pretty.rs
+++ b/src/librustc_driver/pretty.rs
@@ -7,7 +7,7 @@ use rustc_ast::ast;
7use rustc_ast_pretty::pprust; 7use rustc_ast_pretty::pprust;
8use rustc_hir as hir; 8use rustc_hir as hir;
9use rustc_hir::def_id::LOCAL_CRATE; 9use rustc_hir::def_id::LOCAL_CRATE;
10use rustc_hir::print as pprust_hir; 10use rustc_hir_pretty as pprust_hir;
11use rustc_mir::util::{write_mir_graphviz, write_mir_pretty}; 11use rustc_mir::util::{write_mir_graphviz, write_mir_pretty};
12use rustc_session::config::{Input, PpMode, PpSourceMode}; 12use rustc_session::config::{Input, PpMode, PpSourceMode};
13use rustc_session::Session; 13use rustc_session::Session;
@@ -155,7 +155,7 @@ impl<'hir> pprust::PpAnn for NoAnn<'hir> {}
155impl<'hir> pprust_hir::PpAnn for NoAnn<'hir> { 155impl<'hir> pprust_hir::PpAnn for NoAnn<'hir> {
156 fn nested(&self, state: &mut pprust_hir::State<'_>, nested: pprust_hir::Nested) { 156 fn nested(&self, state: &mut pprust_hir::State<'_>, nested: pprust_hir::Nested) {
157 if let Some(tcx) = self.tcx { 157 if let Some(tcx) = self.tcx {
158 pprust_hir::PpAnn::nested(&tcx.hir(), state, nested) 158 pprust_hir::PpAnn::nested(&(&tcx.hir() as &dyn hir::intravisit::Map<'_>), state, nested)
159 } 159 }
160 } 160 }
161} 161}
@@ -228,7 +228,7 @@ impl<'hir> HirPrinterSupport<'hir> for IdentifiedAnnotation<'hir> {
228impl<'hir> pprust_hir::PpAnn for IdentifiedAnnotation<'hir> { 228impl<'hir> pprust_hir::PpAnn for IdentifiedAnnotation<'hir> {
229 fn nested(&self, state: &mut pprust_hir::State<'_>, nested: pprust_hir::Nested) { 229 fn nested(&self, state: &mut pprust_hir::State<'_>, nested: pprust_hir::Nested) {
230 if let Some(ref tcx) = self.tcx { 230 if let Some(ref tcx) = self.tcx {
231 pprust_hir::PpAnn::nested(&tcx.hir(), state, nested) 231 pprust_hir::PpAnn::nested(&(&tcx.hir() as &dyn hir::intravisit::Map<'_>), state, nested)
232 } 232 }
233 } 233 }
234 fn pre(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) { 234 fn pre(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) {
@@ -334,7 +334,8 @@ impl<'a, 'tcx> pprust_hir::PpAnn for TypedAnnotation<'a, 'tcx> {
334 if let pprust_hir::Nested::Body(id) = nested { 334 if let pprust_hir::Nested::Body(id) = nested {
335 self.tables.set(self.tcx.body_tables(id)); 335 self.tables.set(self.tcx.body_tables(id));
336 } 336 }
337 pprust_hir::PpAnn::nested(&self.tcx.hir(), state, nested); 337 let pp_ann = &(&self.tcx.hir() as &dyn hir::intravisit::Map<'_>);
338 pprust_hir::PpAnn::nested(pp_ann, state, nested);
338 self.tables.set(old_tables); 339 self.tables.set(old_tables);
339 } 340 }
340 fn pre(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) { 341 fn pre(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) {
diff --git a/src/librustc_hir/Cargo.toml b/src/librustc_hir/Cargo.toml
index b3682ea..811440f 100644
--- a/src/librustc_hir/Cargo.toml
+++ b/src/librustc_hir/Cargo.toml
@@ -10,13 +10,11 @@ path = "lib.rs"
10doctest = false 10doctest = false
11 11
12[dependencies] 12[dependencies]
13rustc_ast_pretty = { path = "../librustc_ast_pretty" }
14rustc_target = { path = "../librustc_target" } 13rustc_target = { path = "../librustc_target" }
15rustc_macros = { path = "../librustc_macros" } 14rustc_macros = { path = "../librustc_macros" }
16rustc_data_structures = { path = "../librustc_data_structures" } 15rustc_data_structures = { path = "../librustc_data_structures" }
17rustc_index = { path = "../librustc_index" } 16rustc_index = { path = "../librustc_index" }
18rustc_span = { path = "../librustc_span" } 17rustc_span = { path = "../librustc_span" }
19rustc_errors = { path = "../librustc_errors" }
20rustc_serialize = { path = "../libserialize", package = "serialize" } 18rustc_serialize = { path = "../libserialize", package = "serialize" }
21rustc_ast = { path = "../librustc_ast" } 19rustc_ast = { path = "../librustc_ast" }
22lazy_static = "1" 20lazy_static = "1"
diff --git a/src/librustc_hir/hir.rs b/src/librustc_hir/hir.rs
index bb864ed..2054759 100644
--- a/src/librustc_hir/hir.rs
+++ b/src/librustc_hir/hir.rs
@@ -2,11 +2,6 @@ use crate::def::{DefKind, Namespace, Res};
2use crate::def_id::DefId; 2use crate::def_id::DefId;
3crate use crate::hir_id::HirId; 3crate use crate::hir_id::HirId;
4use crate::itemlikevisit; 4use crate::itemlikevisit;
5use crate::print;
6
7crate use BlockCheckMode::*;
8crate use FnRetTy::*;
9crate use UnsafeSource::*;
10 5
11use rustc_ast::ast::{self, AsmDialect, CrateSugar, Ident, Name}; 6use rustc_ast::ast::{self, AsmDialect, CrateSugar, Ident, Name};
12use rustc_ast::ast::{AttrVec, Attribute, FloatTy, IntTy, Label, LitKind, StrStyle, UintTy}; 7use rustc_ast::ast::{AttrVec, Attribute, FloatTy, IntTy, Label, LitKind, StrStyle, UintTy};
@@ -16,7 +11,6 @@ use rustc_ast::node_id::NodeMap;
16use rustc_ast::util::parser::ExprPrecedence; 11use rustc_ast::util::parser::ExprPrecedence;
17use rustc_data_structures::fx::FxHashSet; 12use rustc_data_structures::fx::FxHashSet;
18use rustc_data_structures::sync::{par_for_each_in, Send, Sync}; 13use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
19use rustc_errors::FatalError;
20use rustc_macros::HashStable_Generic; 14use rustc_macros::HashStable_Generic;
21use rustc_span::source_map::{SourceMap, Spanned}; 15use rustc_span::source_map::{SourceMap, Spanned};
22use rustc_span::symbol::{kw, sym, Symbol}; 16use rustc_span::symbol::{kw, sym, Symbol};
@@ -169,12 +163,7 @@ impl fmt::Display for Lifetime {
169 163
170impl fmt::Debug for Lifetime { 164impl fmt::Debug for Lifetime {
171 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 165 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
172 write!( 166 write!(f, "lifetime({}: {})", self.hir_id, self.name.ident())
173 f,
174 "lifetime({}: {})",
175 self.hir_id,
176 print::to_string(print::NO_ANN, |s| s.print_lifetime(self))
177 )
178 } 167 }
179} 168}
180 169
@@ -191,7 +180,7 @@ impl Lifetime {
191/// A `Path` is essentially Rust's notion of a name; for instance, 180/// A `Path` is essentially Rust's notion of a name; for instance,
192/// `std::cmp::PartialEq`. It's represented as a sequence of identifiers, 181/// `std::cmp::PartialEq`. It's represented as a sequence of identifiers,
193/// along with a bunch of supporting information. 182/// along with a bunch of supporting information.
194#[derive(RustcEncodable, RustcDecodable, HashStable_Generic)] 183#[derive(RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
195pub struct Path<'hir> { 184pub struct Path<'hir> {
196 pub span: Span, 185 pub span: Span,
197 /// The resolution for the path. 186 /// The resolution for the path.
@@ -206,18 +195,6 @@ impl Path<'_> {
206 } 195 }
207} 196}
208 197
209impl fmt::Debug for Path<'_> {
210 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
211 write!(f, "path({})", self)
212 }
213}
214
215impl fmt::Display for Path<'_> {
216 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
217 write!(f, "{}", print::to_string(print::NO_ANN, |s| s.print_path(self, false)))
218 }
219}
220
221/// A segment of a path: an identifier, an optional lifetime, and a set of 198/// A segment of a path: an identifier, an optional lifetime, and a set of
222/// types. 199/// types.
223#[derive(RustcEncodable, RustcDecodable, Debug, HashStable_Generic)] 200#[derive(RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
@@ -388,9 +365,9 @@ pub enum GenericBound<'hir> {
388} 365}
389 366
390impl GenericBound<'_> { 367impl GenericBound<'_> {
391 pub fn trait_def_id(&self) -> Option<DefId> { 368 pub fn trait_ref(&self) -> Option<&TraitRef<'_>> {
392 match self { 369 match self {
393 GenericBound::Trait(data, _) => Some(data.trait_ref.trait_def_id()), 370 GenericBound::Trait(data, _) => Some(&data.trait_ref),
394 _ => None, 371 _ => None,
395 } 372 }
396 } 373 }
@@ -758,7 +735,7 @@ pub struct Block<'hir> {
758 pub targeted_by_break: bool, 735 pub targeted_by_break: bool,
759} 736}
760 737
761#[derive(RustcEncodable, RustcDecodable, HashStable_Generic)] 738#[derive(Debug, RustcEncodable, RustcDecodable, HashStable_Generic)]
762pub struct Pat<'hir> { 739pub struct Pat<'hir> {
763 #[stable_hasher(ignore)] 740 #[stable_hasher(ignore)]
764 pub hir_id: HirId, 741 pub hir_id: HirId,
@@ -766,17 +743,6 @@ pub struct Pat<'hir> {
766 pub span: Span, 743 pub span: Span,
767} 744}
768 745
769impl fmt::Debug for Pat<'_> {
770 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
771 write!(
772 f,
773 "pat({}: {})",
774 self.hir_id,
775 print::to_string(print::NO_ANN, |s| s.print_pat(self))
776 )
777 }
778}
779
780impl Pat<'_> { 746impl Pat<'_> {
781 // FIXME(#19596) this is a workaround, but there should be a better way 747 // FIXME(#19596) this is a workaround, but there should be a better way
782 fn walk_short_(&self, it: &mut impl FnMut(&Pat<'_>) -> bool) -> bool { 748 fn walk_short_(&self, it: &mut impl FnMut(&Pat<'_>) -> bool) -> bool {
@@ -1118,26 +1084,15 @@ impl UnOp {
1118} 1084}
1119 1085
1120/// A statement. 1086/// A statement.
1121#[derive(RustcEncodable, RustcDecodable, HashStable_Generic)] 1087#[derive(RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
1122pub struct Stmt<'hir> { 1088pub struct Stmt<'hir> {
1123 pub hir_id: HirId, 1089 pub hir_id: HirId,
1124 pub kind: StmtKind<'hir>, 1090 pub kind: StmtKind<'hir>,
1125 pub span: Span, 1091 pub span: Span,
1126} 1092}
1127 1093
1128impl fmt::Debug for Stmt<'_> {
1129 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1130 write!(
1131 f,
1132 "stmt({}: {})",
1133 self.hir_id,
1134 print::to_string(print::NO_ANN, |s| s.print_stmt(self))
1135 )
1136 }
1137}
1138
1139/// The contents of a statement. 1094/// The contents of a statement.
1140#[derive(RustcEncodable, RustcDecodable, HashStable_Generic)] 1095#[derive(RustcEncodable, RustcDecodable, Debug, HashStable_Generic)]
1141pub enum StmtKind<'hir> { 1096pub enum StmtKind<'hir> {
1142 /// A local (`let`) binding. 1097 /// A local (`let`) binding.
1143 Local(&'hir Local<'hir>), 1098 Local(&'hir Local<'hir>),
@@ -1351,7 +1306,7 @@ pub struct AnonConst {
1351} 1306}
1352 1307
1353/// An expression. 1308/// An expression.
1354#[derive(RustcEncodable, RustcDecodable)] 1309#[derive(Debug, RustcEncodable, RustcDecodable)]
1355pub struct Expr<'hir> { 1310pub struct Expr<'hir> {
1356 pub hir_id: HirId, 1311 pub hir_id: HirId,
1357 pub kind: ExprKind<'hir>, 1312 pub kind: ExprKind<'hir>,
@@ -1472,17 +1427,6 @@ impl Expr<'_> {
1472 } 1427 }
1473} 1428}
1474 1429
1475impl fmt::Debug for Expr<'_> {
1476 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1477 write!(
1478 f,
1479 "expr({}: {})",
1480 self.hir_id,
1481 print::to_string(print::NO_ANN, |s| s.print_expr(self))
1482 )
1483 }
1484}
1485
1486/// Checks if the specified expression is a built-in range literal. 1430/// Checks if the specified expression is a built-in range literal.
1487/// (See: `LoweringContext::lower_expr()`). 1431/// (See: `LoweringContext::lower_expr()`).
1488/// 1432///
@@ -1965,19 +1909,13 @@ impl TypeBinding<'_> {
1965 } 1909 }
1966} 1910}
1967 1911
1968#[derive(RustcEncodable, RustcDecodable)] 1912#[derive(Debug, RustcEncodable, RustcDecodable)]
1969pub struct Ty<'hir> { 1913pub struct Ty<'hir> {
1970 pub hir_id: HirId, 1914 pub hir_id: HirId,
1971 pub kind: TyKind<'hir>, 1915 pub kind: TyKind<'hir>,
1972 pub span: Span, 1916 pub span: Span,
1973} 1917}
1974 1918
1975impl fmt::Debug for Ty<'_> {
1976 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1977 write!(f, "type({})", print::to_string(print::NO_ANN, |s| s.print_type(self)))
1978 }
1979}
1980
1981/// Not represented directly in the AST; referred to by name through a `ty_path`. 1919/// Not represented directly in the AST; referred to by name through a `ty_path`.
1982#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] 1920#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1983#[derive(HashStable_Generic)] 1921#[derive(HashStable_Generic)]
@@ -2182,15 +2120,6 @@ pub enum FnRetTy<'hir> {
2182 Return(&'hir Ty<'hir>), 2120 Return(&'hir Ty<'hir>),
2183} 2121}
2184 2122
2185impl fmt::Display for FnRetTy<'_> {
2186 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2187 match self {
2188 Self::Return(ref ty) => print::to_string(print::NO_ANN, |s| s.print_type(ty)).fmt(f),
2189 Self::DefaultReturn(_) => "()".fmt(f),
2190 }
2191 }
2192}
2193
2194impl FnRetTy<'_> { 2123impl FnRetTy<'_> {
2195 pub fn span(&self) -> Span { 2124 pub fn span(&self) -> Span {
2196 match *self { 2125 match *self {
@@ -2274,13 +2203,10 @@ pub struct TraitRef<'hir> {
2274 2203
2275impl TraitRef<'_> { 2204impl TraitRef<'_> {
2276 /// Gets the `DefId` of the referenced trait. It _must_ actually be a trait or trait alias. 2205 /// Gets the `DefId` of the referenced trait. It _must_ actually be a trait or trait alias.
2277 pub fn trait_def_id(&self) -> DefId { 2206 pub fn trait_def_id(&self) -> Option<DefId> {
2278 match self.path.res { 2207 match self.path.res {
2279 Res::Def(DefKind::Trait, did) => did, 2208 Res::Def(DefKind::Trait | DefKind::TraitAlias, did) => Some(did),
2280 Res::Def(DefKind::TraitAlias, did) => did, 2209 Res::Err => None,
2281 Res::Err => {
2282 FatalError.raise();
2283 }
2284 _ => unreachable!(), 2210 _ => unreachable!(),
2285 } 2211 }
2286 } 2212 }
diff --git a/src/librustc_hir/intravisit.rs b/src/librustc_hir/intravisit.rs
index 11749cf..08b4ef1 100644
--- a/src/librustc_hir/intravisit.rs
+++ b/src/librustc_hir/intravisit.rs
@@ -121,6 +121,8 @@ impl<'a> FnKind<'a> {
121 121
122/// An abstract representation of the HIR `rustc::hir::map::Map`. 122/// An abstract representation of the HIR `rustc::hir::map::Map`.
123pub trait Map<'hir> { 123pub trait Map<'hir> {
124 /// Retrieves the `Node` corresponding to `id`, returning `None` if cannot be found.
125 fn find(&self, hir_id: HirId) -> Option<Node<'hir>>;
124 fn body(&self, id: BodyId) -> &'hir Body<'hir>; 126 fn body(&self, id: BodyId) -> &'hir Body<'hir>;
125 fn item(&self, id: HirId) -> &'hir Item<'hir>; 127 fn item(&self, id: HirId) -> &'hir Item<'hir>;
126 fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir>; 128 fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir>;
@@ -132,6 +134,9 @@ pub trait Map<'hir> {
132pub struct ErasedMap<'hir>(&'hir dyn Map<'hir>); 134pub struct ErasedMap<'hir>(&'hir dyn Map<'hir>);
133 135
134impl<'hir> Map<'hir> for ErasedMap<'hir> { 136impl<'hir> Map<'hir> for ErasedMap<'hir> {
137 fn find(&self, _: HirId) -> Option<Node<'hir>> {
138 None
139 }
135 fn body(&self, id: BodyId) -> &'hir Body<'hir> { 140 fn body(&self, id: BodyId) -> &'hir Body<'hir> {
136 self.0.body(id) 141 self.0.body(id)
137 } 142 }
diff --git a/src/librustc_hir/lib.rs b/src/librustc_hir/lib.rs
index fbb3d6b..49692c7 100644
--- a/src/librustc_hir/lib.rs
+++ b/src/librustc_hir/lib.rs
@@ -7,6 +7,7 @@
7#![feature(const_fn)] // For the unsizing cast on `&[]` 7#![feature(const_fn)] // For the unsizing cast on `&[]`
8#![feature(const_panic)] 8#![feature(const_panic)]
9#![feature(in_band_lifetimes)] 9#![feature(in_band_lifetimes)]
10#![feature(or_patterns)]
10#![feature(specialization)] 11#![feature(specialization)]
11#![recursion_limit = "256"] 12#![recursion_limit = "256"]
12 13
@@ -23,7 +24,6 @@ pub mod intravisit;
23pub mod itemlikevisit; 24pub mod itemlikevisit;
24pub mod lang_items; 25pub mod lang_items;
25pub mod pat_util; 26pub mod pat_util;
26pub mod print;
27mod stable_hash_impls; 27mod stable_hash_impls;
28mod target; 28mod target;
29pub mod weak_lang_items; 29pub mod weak_lang_items;
diff --git a/src/librustc_hir_pretty/Cargo.toml b/src/librustc_hir_pretty/Cargo.toml
new file mode 100644
index 0000000..6a9339b
--- /dev/null
+++ b/src/librustc_hir_pretty/Cargo.toml
@@ -0,0 +1,18 @@
1[package]
2authors = ["The Rust Project Developers"]
3name = "rustc_hir_pretty"
4version = "0.0.0"
5edition = "2018"
6
7[lib]
8name = "rustc_hir_pretty"
9path = "lib.rs"
10doctest = false
11
12[dependencies]
13rustc_ast_pretty = { path = "../librustc_ast_pretty" }
14rustc_hir = { path = "../librustc_hir" }
15rustc_target = { path = "../librustc_target" }
16rustc_data_structures = { path = "../librustc_data_structures" }
17rustc_span = { path = "../librustc_span" }
18rustc_ast = { path = "../librustc_ast" }
diff --git a/src/librustc_hir/print.rs b/src/librustc_hir_pretty/lib.rs
index cd16e45..88b1288 100644
--- a/src/librustc_hir/print.rs
+++ b/src/librustc_hir_pretty/lib.rs
@@ -1,21 +1,26 @@
1#![recursion_limit = "256"]
2
1use rustc_ast::ast; 3use rustc_ast::ast;
2use rustc_ast::util::parser::{self, AssocOp, Fixity}; 4use rustc_ast::util::parser::{self, AssocOp, Fixity};
3use rustc_ast_pretty::pp::Breaks::{Consistent, Inconsistent}; 5use rustc_ast_pretty::pp::Breaks::{Consistent, Inconsistent};
4use rustc_ast_pretty::pp::{self, Breaks}; 6use rustc_ast_pretty::pp::{self, Breaks};
5use rustc_ast_pretty::pprust::{Comments, PrintState}; 7use rustc_ast_pretty::pprust::{Comments, PrintState};
8use rustc_hir as hir;
9use rustc_hir::{GenericArg, GenericParam, GenericParamKind, Node};
10use rustc_hir::{GenericBound, PatKind, RangeEnd, TraitBoundModifier};
6use rustc_span::source_map::{SourceMap, Spanned}; 11use rustc_span::source_map::{SourceMap, Spanned};
7use rustc_span::symbol::{kw, IdentPrinter}; 12use rustc_span::symbol::{kw, IdentPrinter};
8use rustc_span::{self, BytePos, FileName}; 13use rustc_span::{self, BytePos, FileName};
9use rustc_target::spec::abi::Abi; 14use rustc_target::spec::abi::Abi;
10 15
11use crate::hir;
12use crate::hir::{GenericArg, GenericParam, GenericParamKind, Node};
13use crate::hir::{GenericBound, PatKind, RangeEnd, TraitBoundModifier};
14
15use std::borrow::Cow; 16use std::borrow::Cow;
16use std::cell::Cell; 17use std::cell::Cell;
17use std::vec; 18use std::vec;
18 19
20pub fn id_to_string(map: &dyn rustc_hir::intravisit::Map<'_>, hir_id: hir::HirId) -> String {
21 to_string(&map, |s| s.print_node(map.find(hir_id).unwrap()))
22}
23
19pub enum AnnNode<'a> { 24pub enum AnnNode<'a> {
20 Name(&'a ast::Name), 25 Name(&'a ast::Name),
21 Block(&'a hir::Block<'a>), 26 Block(&'a hir::Block<'a>),
@@ -47,7 +52,7 @@ pub struct NoAnn;
47impl PpAnn for NoAnn {} 52impl PpAnn for NoAnn {}
48pub const NO_ANN: &dyn PpAnn = &NoAnn; 53pub const NO_ANN: &dyn PpAnn = &NoAnn;
49 54
50impl PpAnn for hir::Crate<'a> { 55impl PpAnn for hir::Crate<'_> {
51 fn try_fetch_item(&self, item: hir::HirId) -> Option<&hir::Item<'_>> { 56 fn try_fetch_item(&self, item: hir::HirId) -> Option<&hir::Item<'_>> {
52 Some(self.item(item)) 57 Some(self.item(item))
53 } 58 }
@@ -62,6 +67,20 @@ impl PpAnn for hir::Crate<'a> {
62 } 67 }
63} 68}
64 69
70/// Identical to the `PpAnn` implementation for `hir::Crate`,
71/// except it avoids creating a dependency on the whole crate.
72impl PpAnn for &dyn rustc_hir::intravisit::Map<'_> {
73 fn nested(&self, state: &mut State<'_>, nested: Nested) {
74 match nested {
75 Nested::Item(id) => state.print_item(self.item(id.id)),
76 Nested::TraitItem(id) => state.print_trait_item(self.trait_item(id)),
77 Nested::ImplItem(id) => state.print_impl_item(self.impl_item(id)),
78 Nested::Body(id) => state.print_expr(&self.body(id).value),
79 Nested::BodyParamPat(id, i) => state.print_pat(&self.body(id).params[i].pat),
80 }
81 }
82}
83
65pub struct State<'a> { 84pub struct State<'a> {
66 pub s: pp::Printer, 85 pub s: pp::Printer,
67 comments: Option<Comments<'a>>, 86 comments: Option<Comments<'a>>,
@@ -1006,10 +1025,10 @@ impl<'a> State<'a> {
1006 close_box: bool, 1025 close_box: bool,
1007 ) { 1026 ) {
1008 match blk.rules { 1027 match blk.rules {
1009 hir::UnsafeBlock(..) => self.word_space("unsafe"), 1028 hir::BlockCheckMode::UnsafeBlock(..) => self.word_space("unsafe"),
1010 hir::PushUnsafeBlock(..) => self.word_space("push_unsafe"), 1029 hir::BlockCheckMode::PushUnsafeBlock(..) => self.word_space("push_unsafe"),
1011 hir::PopUnsafeBlock(..) => self.word_space("pop_unsafe"), 1030 hir::BlockCheckMode::PopUnsafeBlock(..) => self.word_space("pop_unsafe"),
1012 hir::DefaultBlock => (), 1031 hir::BlockCheckMode::DefaultBlock => (),
1013 } 1032 }
1014 self.maybe_print_comment(blk.span.lo()); 1033 self.maybe_print_comment(blk.span.lo());
1015 self.ann.pre(self, AnnNode::Block(blk)); 1034 self.ann.pre(self, AnnNode::Block(blk));
@@ -1092,7 +1111,7 @@ impl<'a> State<'a> {
1092 &mut self, 1111 &mut self,
1093 qpath: &hir::QPath<'_>, 1112 qpath: &hir::QPath<'_>,
1094 fields: &[hir::Field<'_>], 1113 fields: &[hir::Field<'_>],
1095 wth: &Option<&'hir hir::Expr<'_>>, 1114 wth: &Option<&hir::Expr<'_>>,
1096 ) { 1115 ) {
1097 self.print_qpath(qpath, true); 1116 self.print_qpath(qpath, true);
1098 self.s.word("{"); 1117 self.s.word("{");
@@ -1848,7 +1867,8 @@ impl<'a> State<'a> {
1848 self.print_block_unclosed(&blk); 1867 self.print_block_unclosed(&blk);
1849 1868
1850 // If it is a user-provided unsafe block, print a comma after it 1869 // If it is a user-provided unsafe block, print a comma after it
1851 if let hir::UnsafeBlock(hir::UserProvided) = blk.rules { 1870 if let hir::BlockCheckMode::UnsafeBlock(hir::UnsafeSource::UserProvided) = blk.rules
1871 {
1852 self.s.word(","); 1872 self.s.word(",");
1853 } 1873 }
1854 } 1874 }
@@ -1928,18 +1948,18 @@ impl<'a> State<'a> {
1928 }); 1948 });
1929 self.s.word("|"); 1949 self.s.word("|");
1930 1950
1931 if let hir::DefaultReturn(..) = decl.output { 1951 if let hir::FnRetTy::DefaultReturn(..) = decl.output {
1932 return; 1952 return;
1933 } 1953 }
1934 1954
1935 self.space_if_not_bol(); 1955 self.space_if_not_bol();
1936 self.word_space("->"); 1956 self.word_space("->");
1937 match decl.output { 1957 match decl.output {
1938 hir::Return(ref ty) => { 1958 hir::FnRetTy::Return(ref ty) => {
1939 self.print_type(&ty); 1959 self.print_type(&ty);
1940 self.maybe_print_comment(ty.span.lo()) 1960 self.maybe_print_comment(ty.span.lo())
1941 } 1961 }
1942 hir::DefaultReturn(..) => unreachable!(), 1962 hir::FnRetTy::DefaultReturn(..) => unreachable!(),
1943 } 1963 }
1944 } 1964 }
1945 1965
@@ -2112,7 +2132,7 @@ impl<'a> State<'a> {
2112 } 2132 }
2113 2133
2114 pub fn print_fn_output(&mut self, decl: &hir::FnDecl<'_>) { 2134 pub fn print_fn_output(&mut self, decl: &hir::FnDecl<'_>) {
2115 if let hir::DefaultReturn(..) = decl.output { 2135 if let hir::FnRetTy::DefaultReturn(..) = decl.output {
2116 return; 2136 return;
2117 } 2137 }
2118 2138
@@ -2120,13 +2140,13 @@ impl<'a> State<'a> {
2120 self.ibox(INDENT_UNIT); 2140 self.ibox(INDENT_UNIT);
2121 self.word_space("->"); 2141 self.word_space("->");
2122 match decl.output { 2142 match decl.output {
2123 hir::DefaultReturn(..) => unreachable!(), 2143 hir::FnRetTy::DefaultReturn(..) => unreachable!(),
2124 hir::Return(ref ty) => self.print_type(&ty), 2144 hir::FnRetTy::Return(ref ty) => self.print_type(&ty),
2125 } 2145 }
2126 self.end(); 2146 self.end();
2127 2147
2128 match decl.output { 2148 match decl.output {
2129 hir::Return(ref output) => self.maybe_print_comment(output.span.lo()), 2149 hir::FnRetTy::Return(ref output) => self.maybe_print_comment(output.span.lo()),
2130 _ => {} 2150 _ => {}
2131 } 2151 }
2132 } 2152 }
diff --git a/src/librustc_metadata/Cargo.toml b/src/librustc_metadata/Cargo.toml
index 088cba8..ea439b1 100644
--- a/src/librustc_metadata/Cargo.toml
+++ b/src/librustc_metadata/Cargo.toml
@@ -19,6 +19,7 @@ rustc_attr = { path = "../librustc_attr" }
19rustc_data_structures = { path = "../librustc_data_structures" } 19rustc_data_structures = { path = "../librustc_data_structures" }
20rustc_errors = { path = "../librustc_errors" } 20rustc_errors = { path = "../librustc_errors" }
21rustc_hir = { path = "../librustc_hir" } 21rustc_hir = { path = "../librustc_hir" }
22rustc_hir_pretty = { path = "../librustc_hir_pretty" }
22rustc_target = { path = "../librustc_target" } 23rustc_target = { path = "../librustc_target" }
23rustc_index = { path = "../librustc_index" } 24rustc_index = { path = "../librustc_index" }
24rustc_serialize = { path = "../libserialize", package = "serialize" } 25rustc_serialize = { path = "../libserialize", package = "serialize" }
diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs
index 9718d19..3686b2f 100644
--- a/src/librustc_metadata/rmeta/encoder.rs
+++ b/src/librustc_metadata/rmeta/encoder.rs
@@ -824,8 +824,10 @@ impl EncodeContext<'tcx> {
824 824
825 record!(self.per_def.kind[def_id] <- match trait_item.kind { 825 record!(self.per_def.kind[def_id] <- match trait_item.kind {
826 ty::AssocKind::Const => { 826 ty::AssocKind::Const => {
827 let rendered = 827 let rendered = rustc_hir_pretty::to_string(
828 hir::print::to_string(&self.tcx.hir(), |s| s.print_trait_item(ast_item)); 828 &(&self.tcx.hir() as &dyn intravisit::Map<'_>),
829 |s| s.print_trait_item(ast_item)
830 );
829 let rendered_const = self.lazy(RenderedConst(rendered)); 831 let rendered_const = self.lazy(RenderedConst(rendered));
830 832
831 EntryKind::AssocConst( 833 EntryKind::AssocConst(
@@ -1044,8 +1046,11 @@ impl EncodeContext<'tcx> {
1044 } 1046 }
1045 1047
1046 fn encode_rendered_const_for_body(&mut self, body_id: hir::BodyId) -> Lazy<RenderedConst> { 1048 fn encode_rendered_const_for_body(&mut self, body_id: hir::BodyId) -> Lazy<RenderedConst> {
1047 let body = self.tcx.hir().body(body_id); 1049 let hir = self.tcx.hir();
1048 let rendered = hir::print::to_string(&self.tcx.hir(), |s| s.print_expr(&body.value)); 1050 let body = hir.body(body_id);
1051 let rendered = rustc_hir_pretty::to_string(&(&hir as &dyn intravisit::Map<'_>), |s| {
1052 s.print_expr(&body.value)
1053 });
1049 let rendered_const = &RenderedConst(rendered); 1054 let rendered_const = &RenderedConst(rendered);
1050 self.lazy(rendered_const) 1055 self.lazy(rendered_const)
1051 } 1056 }
diff --git a/src/librustc_passes/liveness.rs b/src/librustc_passes/liveness.rs
index 97f6457..e729c2d 100644
--- a/src/librustc_passes/liveness.rs
+++ b/src/librustc_passes/liveness.rs
@@ -903,10 +903,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
903 } 903 }
904 904
905 fn compute(&mut self, body: &hir::Expr<'_>) -> LiveNode { 905 fn compute(&mut self, body: &hir::Expr<'_>) -> LiveNode {
906 debug!( 906 debug!("compute: using id for body, {:?}", body);
907 "compute: using id for body, {}",
908 self.ir.tcx.hir().hir_to_pretty_string(body.hir_id)
909 );
910 907
911 // the fallthrough exit is only for those cases where we do not 908 // the fallthrough exit is only for those cases where we do not
912 // explicitly return: 909 // explicitly return:
@@ -979,7 +976,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
979 } 976 }
980 977
981 fn propagate_through_expr(&mut self, expr: &Expr<'_>, succ: LiveNode) -> LiveNode { 978 fn propagate_through_expr(&mut self, expr: &Expr<'_>, succ: LiveNode) -> LiveNode {
982 debug!("propagate_through_expr: {}", self.ir.tcx.hir().hir_to_pretty_string(expr.hir_id)); 979 debug!("propagate_through_expr: {:?}", expr);
983 980
984 match expr.kind { 981 match expr.kind {
985 // Interesting cases with control flow or which gen/kill 982 // Interesting cases with control flow or which gen/kill
@@ -990,10 +987,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
990 hir::ExprKind::Field(ref e, _) => self.propagate_through_expr(&e, succ), 987 hir::ExprKind::Field(ref e, _) => self.propagate_through_expr(&e, succ),
991 988
992 hir::ExprKind::Closure(..) => { 989 hir::ExprKind::Closure(..) => {
993 debug!( 990 debug!("{:?} is an ExprKind::Closure", expr);
994 "{} is an ExprKind::Closure",
995 self.ir.tcx.hir().hir_to_pretty_string(expr.hir_id)
996 );
997 991
998 // the construction of a closure itself is not important, 992 // the construction of a closure itself is not important,
999 // but we have to consider the closed over variables. 993 // but we have to consider the closed over variables.
@@ -1344,11 +1338,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
1344 let mut first_merge = true; 1338 let mut first_merge = true;
1345 let ln = self.live_node(expr.hir_id, expr.span); 1339 let ln = self.live_node(expr.hir_id, expr.span);
1346 self.init_empty(ln, succ); 1340 self.init_empty(ln, succ);
1347 debug!( 1341 debug!("propagate_through_loop: using id for loop body {} {:?}", expr.hir_id, body);
1348 "propagate_through_loop: using id for loop body {} {}",
1349 expr.hir_id,
1350 self.ir.tcx.hir().hir_to_pretty_string(body.hir_id)
1351 );
1352 1342
1353 self.break_ln.insert(expr.hir_id, succ); 1343 self.break_ln.insert(expr.hir_id, succ);
1354 1344
diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs
index 8734cee..0df1d08 100644
--- a/src/librustc_privacy/lib.rs
+++ b/src/librustc_privacy/lib.rs
@@ -1320,14 +1320,18 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
1320 let is_local_static = 1320 let is_local_static =
1321 if let DefKind::Static = kind { def_id.is_local() } else { false }; 1321 if let DefKind::Static = kind { def_id.is_local() } else { false };
1322 if !self.item_is_accessible(def_id) && !is_local_static { 1322 if !self.item_is_accessible(def_id) && !is_local_static {
1323 let name = match *qpath { 1323 let sess = self.tcx.sess;
1324 hir::QPath::Resolved(_, ref path) => path.to_string(), 1324 let sm = sess.source_map();
1325 hir::QPath::TypeRelative(_, ref segment) => segment.ident.to_string(), 1325 let name = match qpath {
1326 hir::QPath::Resolved(_, path) => sm.span_to_snippet(path.span).ok(),
1327 hir::QPath::TypeRelative(_, segment) => Some(segment.ident.to_string()),
1326 }; 1328 };
1327 let kind = kind.descr(def_id); 1329 let kind = kind.descr(def_id);
1328 self.tcx 1330 let msg = match name {
1329 .sess 1331 Some(name) => format!("{} `{}` is private", kind, name),
1330 .struct_span_err(span, &format!("{} `{}` is private", kind, name)) 1332 None => format!("{} is private", kind),
1333 };
1334 sess.struct_span_err(span, &msg)
1331 .span_label(span, &format!("private {}", kind)) 1335 .span_label(span, &format!("private {}", kind))
1332 .emit(); 1336 .emit();
1333 return; 1337 return;
diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml
index de851d9..623da1d 100644
--- a/src/librustc_save_analysis/Cargo.toml
+++ b/src/librustc_save_analysis/Cargo.toml
@@ -11,13 +11,14 @@ path = "lib.rs"
11[dependencies] 11[dependencies]
12log = "0.4" 12log = "0.4"
13rustc = { path = "../librustc" } 13rustc = { path = "../librustc" }
14rustc_ast = { path = "../librustc_ast" }
14rustc_ast_pretty = { path = "../librustc_ast_pretty" } 15rustc_ast_pretty = { path = "../librustc_ast_pretty" }
15rustc_data_structures = { path = "../librustc_data_structures" } 16rustc_data_structures = { path = "../librustc_data_structures" }
16rustc_session = { path = "../librustc_session" }
17rustc_hir = { path = "../librustc_hir" } 17rustc_hir = { path = "../librustc_hir" }
18rustc_hir_pretty = { path = "../librustc_hir_pretty" }
18rustc_parse = { path = "../librustc_parse" } 19rustc_parse = { path = "../librustc_parse" }
19serde_json = "1" 20serde_json = "1"
20rustc_ast = { path = "../librustc_ast" } 21rustc_session = { path = "../librustc_session" }
21rustc_span = { path = "../librustc_span" } 22rustc_span = { path = "../librustc_span" }
22rls-data = "0.19" 23rls-data = "0.19"
23rls-span = "0.5" 24rls-span = "0.5"
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs
index 024633c..21551ee 100644
--- a/src/librustc_save_analysis/lib.rs
+++ b/src/librustc_save_analysis/lib.rs
@@ -404,14 +404,15 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> {
404 Some(impl_id) => match self.tcx.hir().get_if_local(impl_id) { 404 Some(impl_id) => match self.tcx.hir().get_if_local(impl_id) {
405 Some(Node::Item(item)) => match item.kind { 405 Some(Node::Item(item)) => match item.kind {
406 hir::ItemKind::Impl { ref self_ty, .. } => { 406 hir::ItemKind::Impl { ref self_ty, .. } => {
407 let hir = self.tcx.hir();
408
407 let mut qualname = String::from("<"); 409 let mut qualname = String::from("<");
408 qualname.push_str(&self.tcx.hir().hir_to_pretty_string(self_ty.hir_id)); 410 qualname.push_str(&rustc_hir_pretty::id_to_string(&hir, self_ty.hir_id));
409 411
410 let trait_id = self.tcx.trait_id_of_impl(impl_id); 412 let trait_id = self.tcx.trait_id_of_impl(impl_id);
411 let mut docs = String::new(); 413 let mut docs = String::new();
412 let mut attrs = vec![]; 414 let mut attrs = vec![];
413 let hir_id = self.tcx.hir().node_to_hir_id(id); 415 if let Some(Node::ImplItem(item)) = hir.find(hir.node_to_hir_id(id)) {
414 if let Some(Node::ImplItem(item)) = self.tcx.hir().find(hir_id) {
415 docs = self.docs_for_attrs(&item.attrs); 416 docs = self.docs_for_attrs(&item.attrs);
416 attrs = item.attrs.to_vec(); 417 attrs = item.attrs.to_vec();
417 } 418 }
diff --git a/src/librustc_trait_selection/traits/error_reporting/mod.rs b/src/librustc_trait_selection/traits/error_reporting/mod.rs
index 1293951..8cbed43 100644
--- a/src/librustc_trait_selection/traits/error_reporting/mod.rs
+++ b/src/librustc_trait_selection/traits/error_reporting/mod.rs
@@ -1581,7 +1581,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1581 for param in generics.params { 1581 for param in generics.params {
1582 if param.span == *span 1582 if param.span == *span
1583 && !param.bounds.iter().any(|bound| { 1583 && !param.bounds.iter().any(|bound| {
1584 bound.trait_def_id() == self.tcx.lang_items().sized_trait() 1584 bound.trait_ref().and_then(|trait_ref| trait_ref.trait_def_id())
1585 == self.tcx.lang_items().sized_trait()
1585 }) 1586 })
1586 { 1587 {
1587 let (span, separator) = match param.bounds { 1588 let (span, separator) = match param.bounds {
diff --git a/src/librustc_trait_selection/traits/object_safety.rs b/src/librustc_trait_selection/traits/object_safety.rs
index 5cc1da0..7d4ad61 100644
--- a/src/librustc_trait_selection/traits/object_safety.rs
+++ b/src/librustc_trait_selection/traits/object_safety.rs
@@ -15,7 +15,7 @@ use crate::traits::query::evaluate_obligation::InferCtxtExt;
15use crate::traits::{self, Obligation, ObligationCause}; 15use crate::traits::{self, Obligation, ObligationCause};
16use rustc::ty::subst::{InternalSubsts, Subst}; 16use rustc::ty::subst::{InternalSubsts, Subst};
17use rustc::ty::{self, Predicate, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness}; 17use rustc::ty::{self, Predicate, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness};
18use rustc_errors::Applicability; 18use rustc_errors::{Applicability, FatalError};
19use rustc_hir as hir; 19use rustc_hir as hir;
20use rustc_hir::def_id::DefId; 20use rustc_hir::def_id::DefId;
21use rustc_session::lint::builtin::WHERE_CLAUSES_OBJECT_SAFETY; 21use rustc_session::lint::builtin::WHERE_CLAUSES_OBJECT_SAFETY;
@@ -170,6 +170,24 @@ fn object_safety_violations_for_trait(
170 violations 170 violations
171} 171}
172 172
173fn sized_trait_bound_spans<'tcx>(
174 tcx: TyCtxt<'tcx>,
175 bounds: hir::GenericBounds<'tcx>,
176) -> impl 'tcx + Iterator<Item = Span> {
177 bounds.iter().filter_map(move |b| match b {
178 hir::GenericBound::Trait(trait_ref, hir::TraitBoundModifier::None)
179 if trait_has_sized_self(
180 tcx,
181 trait_ref.trait_ref.trait_def_id().unwrap_or_else(|| FatalError.raise()),
182 ) =>
183 {
184 // Fetch spans for supertraits that are `Sized`: `trait T: Super`
185 Some(trait_ref.span)
186 }
187 _ => None,
188 })
189}
190
173fn get_sized_bounds(tcx: TyCtxt<'_>, trait_def_id: DefId) -> SmallVec<[Span; 1]> { 191fn get_sized_bounds(tcx: TyCtxt<'_>, trait_def_id: DefId) -> SmallVec<[Span; 1]> {
174 tcx.hir() 192 tcx.hir()
175 .get_if_local(trait_def_id) 193 .get_if_local(trait_def_id)
@@ -189,33 +207,14 @@ fn get_sized_bounds(tcx: TyCtxt<'_>, trait_def_id: DefId) -> SmallVec<[Span; 1]>
189 { 207 {
190 // Fetch spans for trait bounds that are Sized: 208 // Fetch spans for trait bounds that are Sized:
191 // `trait T where Self: Pred` 209 // `trait T where Self: Pred`
192 Some(pred.bounds.iter().filter_map(|b| match b { 210 Some(sized_trait_bound_spans(tcx, pred.bounds))
193 hir::GenericBound::Trait(
194 trait_ref,
195 hir::TraitBoundModifier::None,
196 ) if trait_has_sized_self(
197 tcx,
198 trait_ref.trait_ref.trait_def_id(),
199 ) =>
200 {
201 Some(trait_ref.span)
202 }
203 _ => None,
204 }))
205 } 211 }
206 _ => None, 212 _ => None,
207 } 213 }
208 }) 214 })
209 .flatten() 215 .flatten()
210 .chain(bounds.iter().filter_map(|b| match b { 216 // Fetch spans for supertraits that are `Sized`: `trait T: Super`.
211 hir::GenericBound::Trait(trait_ref, hir::TraitBoundModifier::None) 217 .chain(sized_trait_bound_spans(tcx, bounds))
212 if trait_has_sized_self(tcx, trait_ref.trait_ref.trait_def_id()) =>
213 {
214 // Fetch spans for supertraits that are `Sized`: `trait T: Super`
215 Some(trait_ref.span)
216 }
217 _ => None,
218 }))
219 .collect::<SmallVec<[Span; 1]>>(), 218 .collect::<SmallVec<[Span; 1]>>(),
220 ), 219 ),
221 _ => None, 220 _ => None,
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index 54c646b..07630d7 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -16,12 +16,11 @@ use rustc::ty::{GenericParamDef, GenericParamDefKind};
16use rustc_ast::ast; 16use rustc_ast::ast;
17use rustc_ast::util::lev_distance::find_best_match_for_name; 17use rustc_ast::util::lev_distance::find_best_match_for_name;
18use rustc_data_structures::fx::{FxHashMap, FxHashSet}; 18use rustc_data_structures::fx::{FxHashMap, FxHashSet};
19use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticId}; 19use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticId, FatalError};
20use rustc_hir as hir; 20use rustc_hir as hir;
21use rustc_hir::def::{CtorOf, DefKind, Namespace, Res}; 21use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
22use rustc_hir::def_id::DefId; 22use rustc_hir::def_id::DefId;
23use rustc_hir::intravisit::{walk_generics, Visitor}; 23use rustc_hir::intravisit::{walk_generics, Visitor as _};
24use rustc_hir::print;
25use rustc_hir::{Constness, GenericArg, GenericArgs}; 24use rustc_hir::{Constness, GenericArg, GenericArgs};
26use rustc_session::lint::builtin::{AMBIGUOUS_ASSOCIATED_ITEMS, LATE_BOUND_LIFETIME_ARGUMENTS}; 25use rustc_session::lint::builtin::{AMBIGUOUS_ASSOCIATED_ITEMS, LATE_BOUND_LIFETIME_ARGUMENTS};
27use rustc_session::parse::feature_err; 26use rustc_session::parse::feature_err;
@@ -991,7 +990,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
991 990
992 self.ast_path_to_mono_trait_ref( 991 self.ast_path_to_mono_trait_ref(
993 trait_ref.path.span, 992 trait_ref.path.span,
994 trait_ref.trait_def_id(), 993 trait_ref.trait_def_id().unwrap_or_else(|| FatalError.raise()),
995 self_ty, 994 self_ty,
996 trait_ref.path.segments.last().unwrap(), 995 trait_ref.path.segments.last().unwrap(),
997 ) 996 )
@@ -1007,7 +1006,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1007 bounds: &mut Bounds<'tcx>, 1006 bounds: &mut Bounds<'tcx>,
1008 speculative: bool, 1007 speculative: bool,
1009 ) -> Result<(), GenericArgCountMismatch> { 1008 ) -> Result<(), GenericArgCountMismatch> {
1010 let trait_def_id = trait_ref.trait_def_id(); 1009 let trait_def_id = trait_ref.trait_def_id().unwrap_or_else(|| FatalError.raise());
1011 1010
1012 debug!("instantiate_poly_trait_ref({:?}, def_id={:?})", trait_ref, trait_def_id); 1011 debug!("instantiate_poly_trait_ref({:?}, def_id={:?})", trait_ref, trait_def_id);
1013 1012
@@ -1118,6 +1117,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1118 if !self.tcx().features().unboxed_closures 1117 if !self.tcx().features().unboxed_closures
1119 && trait_segment.generic_args().parenthesized != trait_def.paren_sugar 1118 && trait_segment.generic_args().parenthesized != trait_def.paren_sugar
1120 { 1119 {
1120 let sess = &self.tcx().sess.parse_sess;
1121 // For now, require that parenthetical notation be used only with `Fn()` etc. 1121 // For now, require that parenthetical notation be used only with `Fn()` etc.
1122 let (msg, sugg) = if trait_def.paren_sugar { 1122 let (msg, sugg) = if trait_def.paren_sugar {
1123 ( 1123 (
@@ -1132,7 +1132,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1132 .and_then(|args| args.args.get(0)) 1132 .and_then(|args| args.args.get(0))
1133 .and_then(|arg| match arg { 1133 .and_then(|arg| match arg {
1134 hir::GenericArg::Type(ty) => { 1134 hir::GenericArg::Type(ty) => {
1135 Some(print::to_string(print::NO_ANN, |s| s.print_type(ty))) 1135 sess.source_map().span_to_snippet(ty.span).ok()
1136 } 1136 }
1137 _ => None, 1137 _ => None,
1138 }) 1138 })
@@ -1143,7 +1143,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1143 .iter() 1143 .iter()
1144 .filter_map(|b| match (b.ident.as_str() == "Output", &b.kind) { 1144 .filter_map(|b| match (b.ident.as_str() == "Output", &b.kind) {
1145 (true, hir::TypeBindingKind::Equality { ty }) => { 1145 (true, hir::TypeBindingKind::Equality { ty }) => {
1146 Some(print::to_string(print::NO_ANN, |s| s.print_type(ty))) 1146 sess.source_map().span_to_snippet(ty.span).ok()
1147 } 1147 }
1148 _ => None, 1148 _ => None,
1149 }) 1149 })
@@ -1154,7 +1154,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1154 } else { 1154 } else {
1155 ("parenthetical notation is only stable when used with `Fn`-family traits", None) 1155 ("parenthetical notation is only stable when used with `Fn`-family traits", None)
1156 }; 1156 };
1157 let sess = &self.tcx().sess.parse_sess;
1158 let mut err = feature_err(sess, sym::unboxed_closures, span, msg); 1157 let mut err = feature_err(sess, sym::unboxed_closures, span, msg);
1159 if let Some(sugg) = sugg { 1158 if let Some(sugg) = sugg {
1160 let msg = "use parenthetical notation instead"; 1159 let msg = "use parenthetical notation instead";
diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs
index a34389b..b44bab2 100644
--- a/src/librustc_typeck/check/_match.rs
+++ b/src/librustc_typeck/check/_match.rs
@@ -245,11 +245,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
245 { 245 {
246 // check that the `if` expr without `else` is the fn body's expr 246 // check that the `if` expr without `else` is the fn body's expr
247 if expr.span == span { 247 if expr.span == span {
248 return self.get_fn_decl(hir_id).map(|(fn_decl, _)| { 248 return self.get_fn_decl(hir_id).and_then(|(fn_decl, _)| {
249 ( 249 let span = fn_decl.output.span();
250 fn_decl.output.span(), 250 let snippet = self.tcx.sess.source_map().span_to_snippet(span).ok()?;
251 format!("expected `{}` because of this return type", fn_decl.output), 251 Some((span, format!("expected `{}` because of this return type", snippet)))
252 )
253 }); 252 });
254 } 253 }
255 } 254 }
diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs
index ec79604..0749516 100644
--- a/src/librustc_typeck/check/callee.rs
+++ b/src/librustc_typeck/check/callee.rs
@@ -265,7 +265,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
265 if let &ty::Adt(adt_def, ..) = t { 265 if let &ty::Adt(adt_def, ..) = t {
266 if adt_def.is_enum() { 266 if adt_def.is_enum() {
267 if let hir::ExprKind::Call(ref expr, _) = call_expr.kind { 267 if let hir::ExprKind::Call(ref expr, _) = call_expr.kind {
268 unit_variant = Some(self.tcx.hir().hir_to_pretty_string(expr.hir_id)) 268 unit_variant =
269 self.tcx.sess.source_map().span_to_snippet(expr.span).ok();
269 } 270 }
270 } 271 }
271 } 272 }
@@ -335,16 +336,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
335 err.span_label(call_expr.span, "call expression requires function"); 336 err.span_label(call_expr.span, "call expression requires function");
336 337
337 if let Some(span) = self.tcx.hir().res_span(def) { 338 if let Some(span) = self.tcx.hir().res_span(def) {
339 let callee_ty = callee_ty.to_string();
338 let label = match (unit_variant, inner_callee_path) { 340 let label = match (unit_variant, inner_callee_path) {
339 (Some(path), _) => format!("`{}` defined here", path), 341 (Some(path), _) => Some(format!("`{}` defined here", path)),
340 (_, Some(hir::QPath::Resolved(_, path))) => format!( 342 (_, Some(hir::QPath::Resolved(_, path))) => {
341 "`{}` defined here returns `{}`", 343 self.tcx.sess.source_map().span_to_snippet(path.span).ok().map(
342 path, 344 |p| format!("`{}` defined here returns `{}`", p, callee_ty),
343 callee_ty.to_string() 345 )
344 ), 346 }
345 _ => format!("`{}` defined here", callee_ty.to_string()), 347 _ => Some(format!("`{}` defined here", callee_ty)),
346 }; 348 };
347 err.span_label(span, label); 349 if let Some(label) = label {
350 err.span_label(span, label);
351 }
348 } 352 }
349 err.emit(); 353 err.emit();
350 } else { 354 } else {
diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs
index 33fc18b..2dc2a48 100644
--- a/src/librustc_typeck/check/coercion.rs
+++ b/src/librustc_typeck/check/coercion.rs
@@ -1402,9 +1402,12 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1402 { 1402 {
1403 // Are of this `impl Trait`'s traits object safe? 1403 // Are of this `impl Trait`'s traits object safe?
1404 is_object_safe = bounds.iter().all(|bound| { 1404 is_object_safe = bounds.iter().all(|bound| {
1405 bound.trait_def_id().map_or(false, |def_id| { 1405 bound
1406 fcx.tcx.object_safety_violations(def_id).is_empty() 1406 .trait_ref()
1407 }) 1407 .and_then(|t| t.trait_def_id())
1408 .map_or(false, |def_id| {
1409 fcx.tcx.object_safety_violations(def_id).is_empty()
1410 })
1408 }) 1411 })
1409 } 1412 }
1410 } 1413 }
diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs
index 0556c80..f7ffb5a 100644
--- a/src/librustc_typeck/check/demand.rs
+++ b/src/librustc_typeck/check/demand.rs
@@ -9,7 +9,7 @@ use rustc::ty::{self, AssocItem, Ty};
9use rustc_ast::util::parser::PREC_POSTFIX; 9use rustc_ast::util::parser::PREC_POSTFIX;
10use rustc_errors::{Applicability, DiagnosticBuilder}; 10use rustc_errors::{Applicability, DiagnosticBuilder};
11use rustc_hir as hir; 11use rustc_hir as hir;
12use rustc_hir::{is_range_literal, print, Node}; 12use rustc_hir::{is_range_literal, Node};
13use rustc_span::symbol::sym; 13use rustc_span::symbol::sym;
14use rustc_span::Span; 14use rustc_span::Span;
15 15
@@ -198,13 +198,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
198 .peekable(); 198 .peekable();
199 199
200 if compatible_variants.peek().is_some() { 200 if compatible_variants.peek().is_some() {
201 let expr_text = 201 if let Ok(expr_text) = self.tcx.sess.source_map().span_to_snippet(expr.span) {
202 self.tcx.sess.source_map().span_to_snippet(expr.span).unwrap_or_else(|_| { 202 let suggestions = compatible_variants.map(|v| format!("{}({})", v, expr_text));
203 print::to_string(print::NO_ANN, |s| s.print_expr(expr)) 203 let msg = "try using a variant of the expected enum";
204 }); 204 err.span_suggestions(
205 let suggestions = compatible_variants.map(|v| format!("{}({})", v, expr_text)); 205 expr.span,
206 let msg = "try using a variant of the expected enum"; 206 msg,
207 err.span_suggestions(expr.span, msg, suggestions, Applicability::MaybeIncorrect); 207 suggestions,
208 Applicability::MaybeIncorrect,
209 );
210 }
208 } 211 }
209 } 212 }
210 } 213 }
diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs
index dffed9a..53a20d9 100644
--- a/src/librustc_typeck/check/expr.rs
+++ b/src/librustc_typeck/check/expr.rs
@@ -475,7 +475,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
475 tcx.types.err 475 tcx.types.err
476 } 476 }
477 Res::Def(DefKind::Ctor(_, CtorKind::Fictive), _) => { 477 Res::Def(DefKind::Ctor(_, CtorKind::Fictive), _) => {
478 report_unexpected_variant_res(tcx, res, expr.span, qpath); 478 report_unexpected_variant_res(tcx, res, expr.span);
479 tcx.types.err 479 tcx.types.err
480 } 480 }
481 _ => self.instantiate_value_path(segs, opt_ty, res, expr.span, expr.hir_id).0, 481 _ => self.instantiate_value_path(segs, opt_ty, res, expr.span, expr.hir_id).0,
@@ -696,10 +696,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
696 self, 696 self,
697 &cause, 697 &cause,
698 &mut |db| { 698 &mut |db| {
699 db.span_label( 699 let span = fn_decl.output.span();
700 fn_decl.output.span(), 700 if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) {
701 format!("expected `{}` because of this return type", fn_decl.output,), 701 db.span_label(
702 ); 702 span,
703 format!("expected `{}` because of this return type", snippet),
704 );
705 }
703 }, 706 },
704 true, 707 true,
705 ); 708 );
@@ -1668,20 +1671,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1668 if let (Some(len), Ok(user_index)) = 1671 if let (Some(len), Ok(user_index)) =
1669 (len.try_eval_usize(self.tcx, self.param_env), field.as_str().parse::<u64>()) 1672 (len.try_eval_usize(self.tcx, self.param_env), field.as_str().parse::<u64>())
1670 { 1673 {
1671 let base = self 1674 if let Ok(base) = self.tcx.sess.source_map().span_to_snippet(base.span) {
1672 .tcx 1675 let help = "instead of using tuple indexing, use array indexing";
1673 .sess 1676 let suggestion = format!("{}[{}]", base, field);
1674 .source_map() 1677 let applicability = if len < user_index {
1675 .span_to_snippet(base.span) 1678 Applicability::MachineApplicable
1676 .unwrap_or_else(|_| self.tcx.hir().hir_to_pretty_string(base.hir_id)); 1679 } else {
1677 let help = "instead of using tuple indexing, use array indexing"; 1680 Applicability::MaybeIncorrect
1678 let suggestion = format!("{}[{}]", base, field); 1681 };
1679 let applicability = if len < user_index { 1682 err.span_suggestion(expr.span, help, suggestion, applicability);
1680 Applicability::MachineApplicable 1683 }
1681 } else {
1682 Applicability::MaybeIncorrect
1683 };
1684 err.span_suggestion(expr.span, help, suggestion, applicability);
1685 } 1684 }
1686 } 1685 }
1687 1686
@@ -1692,15 +1691,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1692 base: &hir::Expr<'_>, 1691 base: &hir::Expr<'_>,
1693 field: ast::Ident, 1692 field: ast::Ident,
1694 ) { 1693 ) {
1695 let base = self 1694 if let Ok(base) = self.tcx.sess.source_map().span_to_snippet(base.span) {
1696 .tcx 1695 let msg = format!("`{}` is a raw pointer; try dereferencing it", base);
1697 .sess 1696 let suggestion = format!("(*{}).{}", base, field);
1698 .source_map() 1697 err.span_suggestion(expr.span, &msg, suggestion, Applicability::MaybeIncorrect);
1699 .span_to_snippet(base.span) 1698 }
1700 .unwrap_or_else(|_| self.tcx.hir().hir_to_pretty_string(base.hir_id));
1701 let msg = format!("`{}` is a raw pointer; try dereferencing it", base);
1702 let suggestion = format!("(*{}).{}", base, field);
1703 err.span_suggestion(expr.span, &msg, suggestion, Applicability::MaybeIncorrect);
1704 } 1699 }
1705 1700
1706 fn no_such_field_err<T: Display>( 1701 fn no_such_field_err<T: Display>(
diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs
index e940ecc..6888200 100644
--- a/src/librustc_typeck/check/method/suggest.rs
+++ b/src/librustc_typeck/check/method/suggest.rs
@@ -1061,7 +1061,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1061 let trait_def_ids: FxHashSet<DefId> = param 1061 let trait_def_ids: FxHashSet<DefId> = param
1062 .bounds 1062 .bounds
1063 .iter() 1063 .iter()
1064 .filter_map(|bound| bound.trait_def_id()) 1064 .filter_map(|bound| Some(bound.trait_ref()?.trait_def_id()?))
1065 .collect(); 1065 .collect();
1066 if !candidates.iter().any(|t| trait_def_ids.contains(&t.def_id)) { 1066 if !candidates.iter().any(|t| trait_def_ids.contains(&t.def_id)) {
1067 err.span_suggestions( 1067 err.span_suggestions(
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 91ab94b..f188ee0 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -2677,14 +2677,14 @@ pub fn check_enum<'tcx>(
2677 check_transparent(tcx, sp, def_id); 2677 check_transparent(tcx, sp, def_id);
2678} 2678}
2679 2679
2680fn report_unexpected_variant_res(tcx: TyCtxt<'_>, res: Res, span: Span, qpath: &QPath<'_>) { 2680fn report_unexpected_variant_res(tcx: TyCtxt<'_>, res: Res, span: Span) {
2681 struct_span_err!( 2681 struct_span_err!(
2682 tcx.sess, 2682 tcx.sess,
2683 span, 2683 span,
2684 E0533, 2684 E0533,
2685 "expected unit struct, unit variant or constant, found {} `{}`", 2685 "expected unit struct, unit variant or constant, found {}{}",
2686 res.descr(), 2686 res.descr(),
2687 hir::print::to_string(&tcx.hir(), |s| s.print_qpath(qpath, false)) 2687 tcx.sess.source_map().span_to_snippet(span).map_or(String::new(), |s| format!(" `{}`", s)),
2688 ) 2688 )
2689 .emit(); 2689 .emit();
2690} 2690}
diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs
index 0c4a05e..ec703d5 100644
--- a/src/librustc_typeck/check/pat.rs
+++ b/src/librustc_typeck/check/pat.rs
@@ -171,9 +171,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
171 PatKind::TupleStruct(ref qpath, subpats, ddpos) => { 171 PatKind::TupleStruct(ref qpath, subpats, ddpos) => {
172 self.check_pat_tuple_struct(pat, qpath, subpats, ddpos, expected, def_bm, ti) 172 self.check_pat_tuple_struct(pat, qpath, subpats, ddpos, expected, def_bm, ti)
173 } 173 }
174 PatKind::Path(ref qpath) => { 174 PatKind::Path(_) => self.check_pat_path(pat, path_res.unwrap(), expected, ti),
175 self.check_pat_path(pat, path_res.unwrap(), qpath, expected, ti)
176 }
177 PatKind::Struct(ref qpath, fields, etc) => { 175 PatKind::Struct(ref qpath, fields, etc) => {
178 self.check_pat_struct(pat, qpath, fields, etc, expected, def_bm, ti) 176 self.check_pat_struct(pat, qpath, fields, etc, expected, def_bm, ti)
179 } 177 }
@@ -694,7 +692,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
694 &self, 692 &self,
695 pat: &Pat<'_>, 693 pat: &Pat<'_>,
696 path_resolution: (Res, Option<Ty<'tcx>>, &'b [hir::PathSegment<'b>]), 694 path_resolution: (Res, Option<Ty<'tcx>>, &'b [hir::PathSegment<'b>]),
697 qpath: &hir::QPath<'_>,
698 expected: Ty<'tcx>, 695 expected: Ty<'tcx>,
699 ti: TopInfo<'tcx>, 696 ti: TopInfo<'tcx>,
700 ) -> Ty<'tcx> { 697 ) -> Ty<'tcx> {
@@ -707,17 +704,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
707 self.set_tainted_by_errors(); 704 self.set_tainted_by_errors();
708 return tcx.types.err; 705 return tcx.types.err;
709 } 706 }
710 Res::Def(DefKind::AssocFn, _) 707 Res::Def(DefKind::AssocFn | DefKind::Ctor(_, CtorKind::Fictive | CtorKind::Fn), _) => {
711 | Res::Def(DefKind::Ctor(_, CtorKind::Fictive), _) 708 report_unexpected_variant_res(tcx, res, pat.span);
712 | Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) => {
713 report_unexpected_variant_res(tcx, res, pat.span, qpath);
714 return tcx.types.err; 709 return tcx.types.err;
715 } 710 }
716 Res::Def(DefKind::Ctor(_, CtorKind::Const), _) 711 Res::SelfCtor(..)
717 | Res::SelfCtor(..) 712 | Res::Def(
718 | Res::Def(DefKind::Const, _) 713 DefKind::Ctor(_, CtorKind::Const)
719 | Res::Def(DefKind::AssocConst, _) 714 | DefKind::Const
720 | Res::Def(DefKind::ConstParam, _) => {} // OK 715 | DefKind::AssocConst
716 | DefKind::ConstParam,
717 _,
718 ) => {} // OK
721 _ => bug!("unexpected pattern resolution: {:?}", res), 719 _ => bug!("unexpected pattern resolution: {:?}", res),
722 } 720 }
723 721
@@ -791,14 +789,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
791 } 789 }
792 }; 790 };
793 let report_unexpected_res = |res: Res| { 791 let report_unexpected_res = |res: Res| {
792 let sm = tcx.sess.source_map();
793 let path_str = sm
794 .span_to_snippet(sm.span_until_char(pat.span, '('))
795 .map_or(String::new(), |s| format!(" `{}`", s.trim_end()));
794 let msg = format!( 796 let msg = format!(
795 "expected tuple struct or tuple variant, found {} `{}`", 797 "expected tuple struct or tuple variant, found {}{}",
796 res.descr(), 798 res.descr(),
797 hir::print::to_string(&tcx.hir(), |s| s.print_qpath(qpath, false)), 799 path_str
798 ); 800 );
801
799 let mut err = struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg); 802 let mut err = struct_span_err!(tcx.sess, pat.span, E0164, "{}", msg);
800 match (res, &pat.kind) { 803 match res {
801 (Res::Def(DefKind::Fn, _), _) | (Res::Def(DefKind::AssocFn, _), _) => { 804 Res::Def(DefKind::Fn | DefKind::AssocFn, _) => {
802 err.span_label(pat.span, "`fn` calls are not allowed in patterns"); 805 err.span_label(pat.span, "`fn` calls are not allowed in patterns");
803 err.help( 806 err.help(
804 "for more information, visit \ 807 "for more information, visit \
diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs
index d0414af5..9d8113e 100644
--- a/src/librustc_typeck/check_unused.rs
+++ b/src/librustc_typeck/check_unused.rs
@@ -5,7 +5,6 @@ use rustc_errors::Applicability;
5use rustc_hir as hir; 5use rustc_hir as hir;
6use rustc_hir::def_id::{DefId, DefIdSet, LOCAL_CRATE}; 6use rustc_hir::def_id::{DefId, DefIdSet, LOCAL_CRATE};
7use rustc_hir::itemlikevisit::ItemLikeVisitor; 7use rustc_hir::itemlikevisit::ItemLikeVisitor;
8use rustc_hir::print::visibility_qualified;
9use rustc_session::lint; 8use rustc_session::lint;
10use rustc_span::Span; 9use rustc_span::Span;
11 10
@@ -176,16 +175,13 @@ fn unused_crates_lint(tcx: TyCtxt<'_>) {
176 Some(orig_name) => format!("use {} as {};", orig_name, item.ident.name), 175 Some(orig_name) => format!("use {} as {};", orig_name, item.ident.name),
177 None => format!("use {};", item.ident.name), 176 None => format!("use {};", item.ident.name),
178 }; 177 };
179 178 let vis = tcx.sess.source_map().span_to_snippet(item.vis.span).unwrap_or_default();
180 let replacement = visibility_qualified(&item.vis, base_replacement); 179 let add_vis = |to| if vis.is_empty() { to } else { format!("{} {}", vis, to) };
181 let msg = "`extern crate` is not idiomatic in the new edition"; 180 lint.build("`extern crate` is not idiomatic in the new edition")
182 let help = format!("convert it to a `{}`", visibility_qualified(&item.vis, "use"));
183
184 lint.build(msg)
185 .span_suggestion_short( 181 .span_suggestion_short(
186 extern_crate.span, 182 extern_crate.span,
187 &help, 183 &format!("convert it to a `{}`", add_vis("use".to_string())),
188 replacement, 184 add_vis(base_replacement),
189 Applicability::MachineApplicable, 185 Applicability::MachineApplicable,
190 ) 186 )
191 .emit(); 187 .emit();
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 42cd724..31123c5 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -2146,13 +2146,18 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
2146 { 2146 {
2147 let check = |ast_ty: &hir::Ty<'_>, ty: Ty<'_>| { 2147 let check = |ast_ty: &hir::Ty<'_>, ty: Ty<'_>| {
2148 if ty.is_simd() { 2148 if ty.is_simd() {
2149 let snip = tcx
2150 .sess
2151 .source_map()
2152 .span_to_snippet(ast_ty.span)
2153 .map_or(String::new(), |s| format!(" `{}`", s));
2149 tcx.sess 2154 tcx.sess
2150 .struct_span_err( 2155 .struct_span_err(
2151 ast_ty.span, 2156 ast_ty.span,
2152 &format!( 2157 &format!(
2153 "use of SIMD type `{}` in FFI is highly experimental and \ 2158 "use of SIMD type{} in FFI is highly experimental and \
2154 may result in invalid code", 2159 may result in invalid code",
2155 tcx.hir().hir_to_pretty_string(ast_ty.hir_id) 2160 snip
2156 ), 2161 ),
2157 ) 2162 )
2158 .help("add `#![feature(simd_ffi)]` to the crate attributes to enable") 2163 .help("add `#![feature(simd_ffi)]` to the crate attributes to enable")
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index 153f7af..510eae8 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -482,8 +482,8 @@ fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet<DefId>)
482} 482}
483 483
484pub fn print_inlined_const(cx: &DocContext<'_>, did: DefId) -> String { 484pub fn print_inlined_const(cx: &DocContext<'_>, did: DefId) -> String {
485 if let Some(node_id) = cx.tcx.hir().as_local_hir_id(did) { 485 if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(did) {
486 cx.tcx.hir().hir_to_pretty_string(node_id) 486 rustc_hir_pretty::id_to_string(&cx.tcx.hir(), hir_id)
487 } else { 487 } else {
488 cx.tcx.rendered_const(did) 488 cx.tcx.rendered_const(did)
489 } 489 }
diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs
index 82e3471..b3bfb55 100644
--- a/src/librustdoc/clean/utils.rs
+++ b/src/librustdoc/clean/utils.rs
@@ -578,7 +578,7 @@ pub fn print_const_expr(cx: &DocContext<'_>, body: hir::BodyId) -> String {
578 None 578 None
579 }; 579 };
580 580
581 snippet.unwrap_or_else(|| cx.tcx.hir().hir_to_pretty_string(body.hir_id)) 581 snippet.unwrap_or_else(|| rustc_hir_pretty::id_to_string(&cx.tcx.hir(), body.hir_id))
582} 582}
583 583
584/// Given a type Path, resolve it to a Type using the TyCtxt 584/// Given a type Path, resolve it to a Type using the TyCtxt
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 33cabad..3c5df02 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -26,6 +26,7 @@ extern crate rustc_errors;
26extern crate rustc_expand; 26extern crate rustc_expand;
27extern crate rustc_feature; 27extern crate rustc_feature;
28extern crate rustc_hir; 28extern crate rustc_hir;
29extern crate rustc_hir_pretty;
29extern crate rustc_index; 30extern crate rustc_index;
30extern crate rustc_infer; 31extern crate rustc_infer;
31extern crate rustc_interface; 32extern crate rustc_interface;
diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs
index c5aa467..93305a1 100644
--- a/src/librustdoc/test.rs
+++ b/src/librustdoc/test.rs
@@ -910,7 +910,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirCollector<'a, 'hir> {
910 910
911 fn visit_item(&mut self, item: &'hir hir::Item) { 911 fn visit_item(&mut self, item: &'hir hir::Item) {
912 let name = if let hir::ItemKind::Impl { ref self_ty, .. } = item.kind { 912 let name = if let hir::ItemKind::Impl { ref self_ty, .. } = item.kind {
913 self.map.hir_to_pretty_string(self_ty.hir_id) 913 rustc_hir_pretty::id_to_string(&self.map, self_ty.hir_id)
914 } else { 914 } else {
915 item.ident.to_string() 915 item.ident.to_string()
916 }; 916 };
diff --git a/src/test/ui/methods/method-path-in-pattern.stderr b/src/test/ui/methods/method-path-in-pattern.stderr
index 1d1bdb6..ed3c022 100644
--- a/src/test/ui/methods/method-path-in-pattern.stderr
+++ b/src/test/ui/methods/method-path-in-pattern.stderr
@@ -4,13 +4,13 @@ error[E0533]: expected unit struct, unit variant or constant, found associated f
4LL | Foo::bar => {} 4LL | Foo::bar => {}
5 | ^^^^^^^^ 5 | ^^^^^^^^
6 6
7error[E0533]: expected unit struct, unit variant or constant, found associated function `Foo::bar` 7error[E0533]: expected unit struct, unit variant or constant, found associated function `<Foo>::bar`
8 --> $DIR/method-path-in-pattern.rs:19:9 8 --> $DIR/method-path-in-pattern.rs:19:9
9 | 9 |
10LL | <Foo>::bar => {} 10LL | <Foo>::bar => {}
11 | ^^^^^^^^^^ 11 | ^^^^^^^^^^
12 12
13error[E0533]: expected unit struct, unit variant or constant, found associated function `Foo::trait_bar` 13error[E0533]: expected unit struct, unit variant or constant, found associated function `<Foo>::trait_bar`
14 --> $DIR/method-path-in-pattern.rs:23:9 14 --> $DIR/method-path-in-pattern.rs:23:9
15 | 15 |
16LL | <Foo>::trait_bar => {} 16LL | <Foo>::trait_bar => {}
@@ -22,7 +22,7 @@ error[E0533]: expected unit struct, unit variant or constant, found associated f
22LL | if let Foo::bar = 0u32 {} 22LL | if let Foo::bar = 0u32 {}
23 | ^^^^^^^^ 23 | ^^^^^^^^
24 24
25error[E0533]: expected unit struct, unit variant or constant, found associated function `Foo::bar` 25error[E0533]: expected unit struct, unit variant or constant, found associated function `<Foo>::bar`
26 --> $DIR/method-path-in-pattern.rs:28:12 26 --> $DIR/method-path-in-pattern.rs:28:12
27 | 27 |
28LL | if let <Foo>::bar = 0u32 {} 28LL | if let <Foo>::bar = 0u32 {}
diff --git a/src/test/ui/privacy/associated-item-privacy-trait.rs b/src/test/ui/privacy/associated-item-privacy-trait.rs
index 03347d5..b1482bc 100644
--- a/src/test/ui/privacy/associated-item-privacy-trait.rs
+++ b/src/test/ui/privacy/associated-item-privacy-trait.rs
@@ -21,9 +21,9 @@ mod priv_trait {
21 Pub.method(); 21 Pub.method();
22 //~^ ERROR type `for<'r> fn(&'r Self) {<Self as priv_trait::PrivTr>::method}` is private 22 //~^ ERROR type `for<'r> fn(&'r Self) {<Self as priv_trait::PrivTr>::method}` is private
23 <Pub as PrivTr>::CONST; 23 <Pub as PrivTr>::CONST;
24 //~^ ERROR associated constant `PrivTr::CONST` is private 24 //~^ ERROR associated constant `<Pub as PrivTr>::CONST` is private
25 let _: <Pub as PrivTr>::AssocTy; 25 let _: <Pub as PrivTr>::AssocTy;
26 //~^ ERROR associated type `PrivTr::AssocTy` is private 26 //~^ ERROR associated type `<Pub as PrivTr>::AssocTy` is private
27 pub type InSignatureTy = <Pub as PrivTr>::AssocTy; 27 pub type InSignatureTy = <Pub as PrivTr>::AssocTy;
28 //~^ ERROR trait `priv_trait::PrivTr` is private 28 //~^ ERROR trait `priv_trait::PrivTr` is private
29 pub trait InSignatureTr: PrivTr {} 29 pub trait InSignatureTr: PrivTr {}
@@ -115,7 +115,7 @@ mod priv_parent_substs {
115 <Priv as PubTr<_>>::CONST; 115 <Priv as PubTr<_>>::CONST;
116 //~^ ERROR type `priv_parent_substs::Priv` is private 116 //~^ ERROR type `priv_parent_substs::Priv` is private
117 117
118 let _: <Pub as PubTr>::AssocTy; // FIXME no longer an error?! 118 let _: <Pub as PubTr>::AssocTy; // FIXME no longer an error?!
119 let _: <Pub as PubTr<_>>::AssocTy; 119 let _: <Pub as PubTr<_>>::AssocTy;
120 //~^ ERROR type `priv_parent_substs::Priv` is private 120 //~^ ERROR type `priv_parent_substs::Priv` is private
121 let _: <Priv as PubTr<_>>::AssocTy; 121 let _: <Priv as PubTr<_>>::AssocTy;
diff --git a/src/test/ui/privacy/associated-item-privacy-trait.stderr b/src/test/ui/privacy/associated-item-privacy-trait.stderr
index c30cc94..b9f3e35 100644
--- a/src/test/ui/privacy/associated-item-privacy-trait.stderr
+++ b/src/test/ui/privacy/associated-item-privacy-trait.stderr
@@ -31,7 +31,7 @@ LL | priv_trait::mac!();
31 | 31 |
32 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) 32 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
33 33
34error: associated constant `PrivTr::CONST` is private 34error: associated constant `<Pub as PrivTr>::CONST` is private
35 --> $DIR/associated-item-privacy-trait.rs:23:9 35 --> $DIR/associated-item-privacy-trait.rs:23:9
36 | 36 |
37LL | <Pub as PrivTr>::CONST; 37LL | <Pub as PrivTr>::CONST;
@@ -42,7 +42,7 @@ LL | priv_trait::mac!();
42 | 42 |
43 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) 43 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
44 44
45error: associated type `PrivTr::AssocTy` is private 45error: associated type `<Pub as PrivTr>::AssocTy` is private
46 --> $DIR/associated-item-privacy-trait.rs:25:16 46 --> $DIR/associated-item-privacy-trait.rs:25:16
47 | 47 |
48LL | let _: <Pub as PrivTr>::AssocTy; 48LL | let _: <Pub as PrivTr>::AssocTy;
diff --git a/src/test/ui/qualified/qualified-path-params.stderr b/src/test/ui/qualified/qualified-path-params.stderr
index 7ff43f4..4214e25 100644
--- a/src/test/ui/qualified/qualified-path-params.stderr
+++ b/src/test/ui/qualified/qualified-path-params.stderr
@@ -1,4 +1,4 @@
1error[E0533]: expected unit struct, unit variant or constant, found associated function `<<S as Tr>::A>::f<u8>` 1error[E0533]: expected unit struct, unit variant or constant, found associated function `<S as Tr>::A::f::<u8>`
2 --> $DIR/qualified-path-params.rs:20:9 2 --> $DIR/qualified-path-params.rs:20:9
3 | 3 |
4LL | <S as Tr>::A::f::<u8> => {} 4LL | <S as Tr>::A::f::<u8> => {}