about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-08-20 23:35:03 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-08-27 01:34:10 +0300
commitc476b55e528ce854b6198de5bcfdd20b08440c9d (patch)
treed59e39ff632190cda0426a7cde8ac3658a9c641e /src/libsyntax/parse
parent2065ee9accc87a461897d06414195cfa3e92fb89 (diff)
downloadrust-c476b55e528ce854b6198de5bcfdd20b08440c9d.tar.gz
rust-c476b55e528ce854b6198de5bcfdd20b08440c9d.zip
proc_macro: Update `Span::def_site` to use the proc macro definition location
Which is no longer dummy and is available from metadata now.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 89725d8b339..47243b1ac56 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -375,10 +375,11 @@ impl<'a> Parser<'a> {
         if let Some(directory) = directory {
             parser.directory = directory;
         } else if !parser.token.span.is_dummy() {
-            if let FileName::Real(mut path) =
-                    sess.source_map().span_to_unmapped_path(parser.token.span) {
-                path.pop();
-                parser.directory.path = Cow::from(path);
+            if let Some(FileName::Real(path)) =
+                    &sess.source_map().lookup_char_pos(parser.token.span.lo()).file.unmapped_path {
+                if let Some(directory_path) = path.parent() {
+                    parser.directory.path = Cow::from(directory_path.to_path_buf());
+                }
             }
         }