about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-10-08 22:17:46 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2019-10-13 06:58:51 +0200
commit742ec4b9bf7ae7d693da7fe75e5f974e0fafb9d0 (patch)
tree279b7b118176d564d71813e9ba0ed2caa5fd5a37 /src/libsyntax/parse/parser.rs
parentd131abefc3aa53fc6376593729e6931326270503 (diff)
downloadrust-742ec4b9bf7ae7d693da7fe75e5f974e0fafb9d0.tar.gz
rust-742ec4b9bf7ae7d693da7fe75e5f974e0fafb9d0.zip
ast: remove implicit pprust dependency via Display.
Instead just use `pprust::path_to_string(..)` where needed.

This has two benefits:

a) The AST definition is now independent of printing it.
   (Therefore we get closer to extracting a data-crate.)

b) Debugging should be easier as program flow is clearer.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 4a457f5a43c..a19380657fd 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1454,12 +1454,14 @@ impl<'a> Parser<'a> {
 `pub(super)`: visible only in the current module's parent
 `pub(in path::to::module)`: visible only on the specified path"##;
 
+        let path_str = pprust::path_to_string(&path);
+
         struct_span_err!(self.sess.span_diagnostic, path.span, E0704, "{}", msg)
             .help(suggestion)
             .span_suggestion(
                 path.span,
-                &format!("make this visible only to module `{}` with `in`", path),
-                format!("in {}", path),
+                &format!("make this visible only to module `{}` with `in`", path_str),
+                format!("in {}", path_str),
                 Applicability::MachineApplicable,
             )
             .emit();