os::getcwd() panics if the current directory is not available. According
to getcwd(3), there are three cases:
- EACCES: Permission denied.
- ENOENT: The current working directory has been removed.
- ERANGE: The buffer size is less than the actual absolute path.
This commit makes os::getcwd() return IoResult<Path>, not just Path,
preventing it from panicking.
As os::make_absolute() depends on os::getcwd(), it is also modified to
return IoResult<Path>.
Fixes#16946.
[breaking-change]
Edit: whoops, didn't mean to hit post.
Anyway, this is something I tried to do when I first implemented cloned, but couldn't figure out. Somewhere between then and the PR actually landing, we got Deref of references, so now this works! 🎉
Also turns out the test for the functionality was never marked as a #[test]. Oops!
Also added a Cloned iterator adaptor. If this isn't desirable, it can be taken out of the PR (seperate commits).
Reduces memory usage significantly and opens opportunities for more parallel compilation.
This PR was previously #19002 but I closed it because bors didn't seem to recognize the `r+` annotations there.
The trait has an obvious, sensible implementation directly on vectors so
the MemWriter wrapper is unnecessary. This will halt the trend towards
providing all of the vector methods on MemWriter along with eliminating
the noise caused by conversions between the two types. It also provides
the useful default Writer methods on Vec<u8>.
After the type is removed and code has been migrated, it would make
sense to add a new implementation of MemWriter with seeking support. The
simple use cases can be covered with vectors alone, and ones with the
need for seeks can use a new MemWriter implementation.
The trait has an obvious, sensible implementation directly on vectors so
the MemWriter wrapper is unnecessary. This will halt the trend towards
providing all of the vector methods on MemWriter along with eliminating
the noise caused by conversions between the two types. It also provides
the useful default Writer methods on Vec<u8>.
After the type is removed and code has been migrated, it would make
sense to add a new implementation of MemWriter with seeking support. The
simple use cases can be covered with vectors alone, and ones with the
need for seeks can use a new MemWriter implementation.
- CFG_CFLAGS is only used for jemalloc
- We grew an extra set of flags for jemalloc (CFG_JEMALLOC_CFLAGS) in addition to CFG_CFLAGS
- This kills of CFG_CFLAGS and keeps the more specific and less confusing CFG_JEMALLOC_CFLAGS
- Additionally, pass CFG_JEMALLOC_CFLAGS to jemalloc's configure slightly differently so things work when people use --sysroot in their CFLAGS.
Came up on IRC that this was a bit unhelpful as to what should actually be *done*. I am new to changing compiler messages, please let me know if there's anything else that needs to be done to accomadate this change.
(My build system is still constantly crashing [Is bors contagious?], so this hasn't been formally `check`ed. I figure it's a simple enough change that any consequences [like compile-fail expected messages?] can be eyeballed by someone more experienced.)
Hello,
`dylib` [seems][1] to be no longer an option for the `kind` key of the `link` attribute.
UPDATE: It should be the other way around: It [seems][1] `dylib` has been lost as a possible variant of the `kind` key of the `link` attribute. See the comment below.
Regards,
Ivan
[1]: 8f87538786/src/librustc/metadata/creader.rs (L237)
creating a new Id object requires the format to match a subset of `ID` format defined by the DOT language. When the format did not match, the function called assert. This was not mentioned in the docs or the spec. I made the failure explicit by returning an Result<Id, ()>.
`slice_shift_char` splits a `str` into it's leading `char` and the remainder of the `str`. Currently, it returns a `(Option<char>, &str)` such that:
"bar".slice_shift_char() => (Some('b'), "ar")
"ar".slice_shift_char() => (Some('a'), "r")
"r".slice_shift_char() => (Some('r'), "")
"".slice_shift_char() => (None, "")
This is a little odd. Either a `str` can be split into both a head and a tail or it cannot. So the return type should be `Option<(char, &str)>`. With the current behaviour, in the case of the empty string, the `str` returned is meaningless - it is always the empty string.
This PR changes `slice_shift_char` so that:
"bar".slice_shift_char() => Some(('b', "ar"))
"ar".slice_shift_char() => Some(('a', "r"))
"r".slice_shift_char() => Some(('r', ""))
"".slice_shift_char() => None
Following [the collections reform RFC](https://github.com/rust-lang/rfcs/pull/235), this PR:
* Adds a new `borrow` module to libcore. The module contains traits for borrowing data (`BorrowFrom` and `BorrowFromMut`), generalized cloning (`ToOwned`), and a clone-on-write smartpointer (`Cow`).
* Deprecates the `_equiv` family of methods on `HashMap` and `HashSet` by instead generalizing the "normal" methods like `get` and `remove` to use the new `std::borrow` infrastructure.
* Generalizes `TreeMap`, `TreeSet`, `BTreeMap` and `BTreeSet` to use the new `std::borrow` infrastructure for lookups.
[breaking-change]
This is especially useful for declaring a static with external linkage in an executable. There isn't any way to do that currently since we mark everything in an executable as internal by default.
Also, a quick fix to have the no-compiler-rt target option respected when building staticlibs as well.
- CFG_CFLAGS is gone (it was previously only used by jemalloc anyhow).
- CFG_JEMALLOC_CFLAGS may contain flags needed for the compiler to
function (produce a binary output).
- jemalloc's configure runs $(CC) without EXTRA_CFLAGS, and (without
this change) will fail if any flags are required for CC to work.
This is a pretty major refactoring of the method dispatch infrastructure. It is intended to avoid gross inefficiencies and enable caching and other optimizations (e.g. #17995), though it itself doesn't seem to execute particularly faster yet. It also solves some cases where we were failing to resolve methods that we theoretically should have succeeded with.
Fixes#18674.
cc #18208