From 42c4e481cd98bd392839144c9ac83e55e445a12a Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Mon, 9 Mar 2015 08:49:10 -0700 Subject: Stabilize std::path This commit stabilizes essentially all of the new `std::path` API. The API itself is changed in a couple of ways (which brings it in closer alignment with the RFC): * `.` components are now normalized away, unless they appear at the start of a path. This in turn effects the semantics of e.g. asking for the file name of `foo/` or `foo/.`, both of which yield `Some("foo")` now. This semantics is what the original RFC specified, and is also desirable given early experience rolling out the new API. * The `parent` function now succeeds if, and only if, the path has at least one non-root/prefix component. This change affects `pop` as well. * The `Prefix` component now involves a separate `PrefixComponent` struct, to better allow for keeping both parsed and unparsed prefix data. In addition, the `old_path` module is now deprecated. Closes #23264 [breaking-change] --- src/libsyntax/ext/source_util.rs | 6 +----- src/libsyntax/lib.rs | 1 - src/libsyntax/parse/parser.rs | 8 +------- src/libsyntax/parse/token.rs | 2 ++ 4 files changed, 4 insertions(+), 13 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 62d98be8b85..eb0daac3ab8 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -195,11 +195,7 @@ fn res_rel_file(cx: &mut ExtCtxt, sp: codemap::Span, arg: &Path) -> PathBuf { // NB: relative paths are resolved relative to the compilation unit if !arg.is_absolute() { let mut cu = PathBuf::new(&cx.codemap().span_to_filename(sp)); - if cu.parent().is_some() { - cu.pop(); - } else { - cu = PathBuf::new(""); - } + cu.pop(); cu.push(arg); cu } else { diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index ba3f495cdac..90f0dc30c75 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -38,7 +38,6 @@ #![feature(staged_api)] #![feature(std_misc)] #![feature(unicode)] -#![feature(path)] #![feature(io)] #![feature(path_ext)] diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 28d757e9be9..495c619c273 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5254,13 +5254,7 @@ impl<'a> Parser<'a> { -> (ast::Item_, Vec ) { let mut prefix = PathBuf::new(&self.sess.span_diagnostic.cm .span_to_filename(self.span)); - // FIXME(acrichto): right now "a".pop() == "a", but need to confirm with - // aturon whether this is expected or not. - if prefix.parent().is_some() { - prefix.pop(); - } else { - prefix = PathBuf::new(""); - } + prefix.pop(); let mut dir_path = prefix; for part in &self.mod_path_stack { dir_path.push(&**part); diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 61a3a5ca82a..17b42e4e05c 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -25,6 +25,7 @@ use serialize::{Decodable, Decoder, Encodable, Encoder}; use std::fmt; use std::mem; use std::ops::Deref; +#[allow(deprecated)] use std::old_path::BytesContainer; use std::rc::Rc; @@ -638,6 +639,7 @@ impl Deref for InternedString { fn deref(&self) -> &str { &*self.string } } +#[allow(deprecated)] impl BytesContainer for InternedString { fn container_as_bytes<'a>(&'a self) -> &'a [u8] { // FIXME #12938: This is a workaround for the incorrect signature -- cgit 1.4.1-3-g733a5