summary refs log tree commit diff
path: root/src/libstd/path.rs
AgeCommit message (Collapse)AuthorLines
2018-05-02Revert "Implement FromStr for PathBuf"Alex Crichton-27/+0
This reverts commit 05a9acc3b844ff284a3e3d85dde2d9798abfb215.
2018-04-24Auto merge of #48989 - ExpHP:path-prefix, r=dtolnaybors-9/+11
Make signature of Path::strip_prefix accept non-references I did this a while back but didn't submit a PR. Might as well see what happens. Fixes #48390. **Note: This has the potential to cause regressions in type inference.** However, in order for code to break, it would need to be relying on the signature to determine that a type is `&_`, while still being able to figure out what the `_` is. I'm having a hard time imagining such a scenario in real code.
2018-03-17elide elidable lifetime in Path::strip_prefixMichael Lamparski-4/+4
2018-03-08Rollup merge of #48292 - topecongiro:from_str-for-path-and-pathbuf, ↵Manish Goregaokar-0/+27
r=alexcrichton Implement FromStr for PathBuf Closes #44431.
2018-03-06Implement FromStr for PathBuftopecongiro-0/+27
2018-03-03core: Update stability attributes for FusedIteratorUlrik Sverdrup-3/+3
2018-03-03core: Stabilize FusedIteratorUlrik Sverdrup-2/+2
FusedIterator is a marker trait that promises that the implementing iterator continues to return `None` from `.next()` once it has returned `None` once (and/or `.next_back()`, if implemented). The effects of FusedIterator are already widely available through `.fuse()`, but with stable `FusedIterator`, stable Rust users can implement this trait for their iterators when appropriate.
2018-02-28Add std::path::Path::ancestorsTobias Stolzmann-0/+75
Squashed commit of the following: commit 1b5d55e26f667b1a25c83c5db0cbb072013a5122 Author: Tobias Stolzmann <tobias.stolzmann@gmail.com> Date: Wed Feb 28 00:06:15 2018 +0100 Bugfix commit 4265c2db0b0aaa66fdeace5d329665fd2d13903a Author: Tobias Stolzmann <tobias.stolzmann@gmail.com> Date: Tue Feb 27 22:59:12 2018 +0100 Rename std::path::Path::parents into std::path::Path::ancestors commit 2548e4b14d377d20adad0f08304a0dd6f8e48e23 Author: Tobias Stolzmann <tobias.stolzmann@gmail.com> Date: Tue Feb 27 12:50:37 2018 +0100 Add tracking issue commit 3e2ce51a6eea0e39af05849f76dd2cefd5035e86 Author: Tobias Stolzmann <tobias.stolzmann@gmail.com> Date: Mon Feb 26 15:05:15 2018 +0100 impl FusedIterator for Parents commit a7e096420809740311e19d963d4aba6df77be2f9 Author: Tobias Stolzmann <tobias.stolzmann@gmail.com> Date: Mon Feb 26 14:38:41 2018 +0100 Clarify that the iterator returned will yield at least one value commit 796a36ea203cd197cc4c810eebd21c7e3433e6f1 Author: Tobias Stolzmann <tobias.stolzmann@gmail.com> Date: Thu Feb 22 14:01:21 2018 +0100 Fix examples commit e279383b21f11c97269cb355a5b2a0ecdb65bb0c Author: Tobias Stolzmann <tobias.stolzmann@gmail.com> Date: Thu Feb 22 04:47:24 2018 +0100 Add std::path::Path::parents
2018-02-24Fix capitalisation in Path#file_name's docsDale Wijnand-1/+1
2018-02-20Make signature of Path::strip_prefix un-bizarreMichael Lamparski-8/+10
BREAKING CHANGE: This has the potential to cause regressions in type inference.
2018-02-10Correct a few stability attributesOliver Middleton-1/+1
2018-01-18Add some edge cases to the documentation of `Path`Tobias Bucher-0/+7
Affected methods are `starts_with` and `strip_prefix`.
2018-01-13Auto merge of #46461 - zackmdavis:elemental_method_suggestion_jamboree, ↵bors-0/+1
r=estebank type error method suggestions use whitelisted identity-like conversions ![method_jamboree_summit](https://user-images.githubusercontent.com/1076988/33523646-e5c43184-d7c0-11e7-98e5-1bff426ade86.png) Previously, on a type mismatch (and if this wasn't preëmpted by a higher-priority suggestion), we would look for argumentless methods returning the expected type, and list them in a `help` note. This had two major shortcomings: firstly, a lot of the suggestions didn't really make sense (if you used a &str where a String was expected, `.to_ascii_uppercase()` is probably not the solution you were hoping for). Secondly, we weren't generating suggestions from the most useful traits! We address the first problem with an internal `#[rustc_conversion_suggestion]` attribute meant to mark methods that keep the "same value" in the relevant sense, just converting the type. We address the second problem by making `FnCtxt.probe_for_return_type` pass the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe because grep reveals no other callers of `probe_for_return_type`. Also, structured suggestions are pretty and good for RLS and friends. Unfortunately, the trait probing is still not all one would hope for: at a minimum, we don't know how to rule out `into()` in cases where it wouldn't actually work, and we don't know how to rule in `.to_owned()` where it would. Issues #46459 and #46460 have been filed and are ref'd in a FIXME. This is hoped to resolve #42929, #44672, and #45777.
2018-01-13Rollup merge of #46985 - Diggsey:path-component-asref, r=alexcrichtonkennytm-0/+7
Implement AsRef<Path> for Component Fixes #41866
2018-01-06type error method suggestions use whitelisted identity-like conversionsZack M. Davis-0/+1
Previously, on a type mismatch (and if this wasn't preëmpted by a higher-priority suggestion), we would look for argumentless methods returning the expected type, and list them in a `help` note. This had two major shortcomings. Firstly, a lot of the suggestions didn't really make sense (if you used a &str where a String was expected, `.to_ascii_uppercase()` is probably not the solution you were hoping for). Secondly, we weren't generating suggestions from the most useful traits! We address the first problem with an internal `#[rustc_conversion_suggestion]` attribute meant to mark methods that keep the "same value" in the relevant sense, just converting the type. We address the second problem by making `FnCtxt.probe_for_return_type` pass the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe because grep reveals no other callers of `probe_for_return_type`. Also, structured suggestions are preferred (because they're pretty, but also for RLS and friends). Also also, we make the E0055 autoderef recursion limit error use the one-time-diagnostics set, because we can potentially hit the limit a lot during probing. (Without this, test/ui/did_you_mean/recursion_limit_deref.rs would report "aborting due to 51 errors"). Unfortunately, the trait probing is still not all one would hope for: at a minimum, we don't know how to rule out `into()` in cases where it wouldn't actually work, and we don't know how to rule in `.to_owned()` where it would. Issues #46459 and #46460 have been filed and are ref'd in a FIXME. This is hoped to resolve #42929, #44672, and #45777.
2017-12-28Implement AsRef<Path> for ComponentDiggory Blake-0/+7
2017-12-27Correct a few stability attributesOliver Middleton-4/+4
2017-11-25Implement `Rc`/`Arc` conversions for string-like typesMurarth-0/+58
Provides the following conversion implementations: * `From<`{`CString`,`&CStr`}`>` for {`Arc`,`Rc`}`<CStr>` * `From<`{`OsString`,`&OsStr`}`>` for {`Arc`,`Rc`}`<OsStr>` * `From<`{`PathBuf`,`&Path`}`>` for {`Arc`,`Rc`}`<Path>`
2017-11-21fix some typosMartin Lindhe-1/+1
2017-11-13Rollup merge of #45892 - redox-os:is_absolute_fix, r=alexcrichtonkennytm-4/+4
Redox: Return true from Path::is_absolute if a Path contains root or a scheme In Redox, different subsystems have different filesystem paths. However, the majority of applications using the `Path::is_absolute` function really only want to know if a path is absolute from the perspective of the scheme it is currently running in, usually `file:`. This makes both `file:/` and `/` return `true` from `Path::is_absolute`, meaning that most code does not have to check if it is running on Redox. Code that wants to know if a path contains a scheme can implement such a check on its own. Related to https://github.com/rust-lang/rust/pull/45893
2017-11-04Allow absolute if either contains root or a schemeJeremy Soller-4/+4
2017-11-03Copy `AsciiExt` methods to `char` directlyLukas Kalbertodt-1/+0
This is done in order to deprecate AsciiExt eventually.
2017-09-28Fix errors in Box<Path> conversionsNikolai Vazquez-2/+4
2017-09-28Remove unused 'mem' import in 'path' moduleNikolai Vazquez-1/+0
2017-09-28Remove mem::transmute used in Path conversionsNikolai Vazquez-8/+9
2017-08-23Rollup merge of #43983 - ids1024:redox-path-prefix, r=alexcrichtonCorey Farwell-3/+13
Redox: correct is_absolute() and has_root() This is awkward, but representing schemes properly in `Components` is not easily possible without breaking backwards compatibility, as discussed earlier in https://github.com/rust-lang/rust/pull/37702. But these methods can be corrected anyway.
2017-08-23Auto merge of #43830 - alexcrichton:path-display-regression, r=aturonbors-0/+6
std: Respect formatting flags for str-like OsStr Historically many `Display` and `Debug` implementations for `OsStr`-like abstractions have gone through `String::from_utf8_lossy`, but this was updated in #42613 to use an internal `Utf8Lossy` abstraction instead. This had the unfortunate side effect of causing a regression (#43765) in code which relied on these `fmt` trait implementations respecting the various formatting flags specified. This commit opportunistically adds back interpretation of formatting trait flags in the "common case" where where `OsStr`-like "thing" is all valid utf-8 and can delegate to the formatting implementation for `str`. This doesn't entirely solve the regression as non-utf8 paths will format differently than they did before still (in that they will not respect formatting flags), but this should solve the regression for all "real world" use cases of paths and such. The door's also still open for handling these flags in the future! Closes #43765
2017-08-22Simplify code for handling Redox pathsIan Douglas Scott-10/+5
2017-08-22Use cfg! instead of #[cfg]Ian Douglas Scott-13/+3
2017-08-18Correct has_root() on RedoxIan Douglas Scott-3/+20
2017-08-18redox: Require scheme for path to be absoluteIan Douglas Scott-2/+10
Redox paths are problematic. It would make sense to add a `Scheme` variant to the `std::path::Component` enum; but that would presumably be a breaking change due to exhaustive matching. Alternately it could use the existing `Prefix` variant, like Windows, but none of the existing types of prefix make sense, Redox only has one kind, and adding a new variant to that enum has the same issue as `Component`.
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-1/+1
Like #43008 (f668999), but _much more aggressive_.
2017-08-13std: Respect formatting flags for str-like OsStrAlex Crichton-0/+6
Historically many `Display` and `Debug` implementations for `OsStr`-like abstractions have gone through `String::from_utf8_lossy`, but this was updated in #42613 to use an internal `Utf8Lossy` abstraction instead. This had the unfortunate side effect of causing a regression (#43765) in code which relied on these `fmt` trait implementations respecting the various formatting flags specified. This commit opportunistically adds back interpretation of formatting trait flags in the "common case" where where `OsStr`-like "thing" is all valid utf-8 and can delegate to the formatting implementation for `str`. This doesn't entirely solve the regression as non-utf8 paths will format differently than they did before still (in that they will not respect formatting flags), but this should solve the regression for all "real world" use cases of paths and such. The door's also still open for handling these flags in the future! Closes #43765
2017-08-02Emphasise that these functions look at the disk, not just the pathKornel-2/+2
2017-07-25std: Stabilize CString/OsString/PathBuf extra methodsAlex Crichton-2/+2
Stabilizes: * `CString::as_c_str` * `CString::into_boxed_c_str` * `CStr::into_c_string` * `OsString::into_boxed_os_str` * `OsStr::into_os_string` * `PathBuf::into_boxed_path` * `PathBuf::into_path_buf` Closes #40380
2017-07-23Fix some doc/comment typos.Bruce Mitchener-3/+3
2017-07-14Rollup merge of #43229 - kennytm:return-false-if-path-is-relative-hahaha, ↵Corey Farwell-10/+10
r=steveklabnik Fix minor typo in std::path documentation. Fix minor typo in `std::path` documentation. Replace all `'C' as u8` with `b'C'`.
2017-07-14Fix minor typo in std::path documentation.kennytm-10/+10
Replace all `'C' as u8` with `b'C'`.
2017-07-13Rollup merge of #42926 - Havvy:doc-path-ext, r=steveklabnikSteve Klabnik-0/+34
Document what happens on failure in path ext is_file is_dir r? @steveklabnik Also, what other ways could there be an error that gets discarded and returns false? Should we list them all? Should we say that any errors trying to access the metadata at that path causes it to return false, even if there might be a file or directory there? Should I add a See also link to the original functions that do return Results?
2017-07-12Document error coercion to false in path-ext methods + see also sectionsHavvy-0/+34
2017-07-04Rollup merge of #42227 - ollie27:into_to_from, r=aturonMark Simulacrum-4/+4
Convert Intos to Froms. This is a resubmission of #42129 without `impl<T> From<Vec<T>> for Box<[T]>`.
2017-06-28Document that `/` works as separator on WindowsAleksey Kladov-6/+7
2017-06-21Update version numbers for From implsOliver Middleton-1/+1
2017-06-21Convert Intos to Froms.Clar Charr-3/+3
2017-06-15Avoid allocations in Debug for os_strStepan Koltsov-4/+4
Fixes #38879
2017-05-20Remove unused lifetimes.Clar Charr-1/+1
2017-05-20Correct some stability versionsOliver Middleton-3/+3
These were found by running tidy on stable versions of rust and finding features stabilised with the wrong version numbers.
2017-05-09Add more ways to create a PathBuf to docssteveklabnik-1/+35
The best way to do this wasn't in the documentation, and the ways that were there needed some extra text to elaborate. Fixes #40159
2017-04-22Fix invalid linkageGuillaume Gomez-1/+1
2017-04-20Expanded docs and examples for PathBuf::file_name and friendsMatt Brubeck-2/+15