rustbuild: Build jemalloc and libbacktrace only once (take 2)
This is a rebase of https://github.com/rust-lang/rust/pull/38583 without any additions, but with implemented @alexcrichton's suggestions.
~~This includes `exists(Makefile)` => `cfg(stage0)` suggestion... but it will break cross-compilation, no? Are `libstd/liballoc_jemalloc` cross-compiled for `target != host` built during `stage0`?~~
r? @alexcrichton
Extend Cell to work with non-Copy types
I'm not sure that I did this right but all of the tests pass.
I also had to move the `new()` function so that `Cell`s with non-`Copy` `T`s could be created. That wasn't in the RFC but I assume it needed to be done?
The previous way was not friendly to incremental compilation. The new
plan is to compute, for each body, a set of trait imports used in that
body (slightly subtle: for a closure, we assign the trait imports to the
enclosing fn). Then we walk all bodies and union these sets. The reason
we do this is that we can save the individual sets in the incremental
state, and then recompute only those sets that are needed. Before we
were planning to save only the final union, but in that case if some
components are invalidated we have to recompute *all* of them since we
don't have enough information to "partly" invalidate a result.
In truth, this set probably ought to be part of the `TypeckTables`;
however, I opted not to do that because I don't want to have to
save/restore the entire tables in the incremental state yet (since it
contains a lot of `NodeId` references, and removing those is a
significant refactoring).
rustdoc: mark FFI functions with unsafety icon
Currently, in the list of functions, unsafe functions are marked with a superscript ⚠, but unsafe FFI functions are not. This patch treats unsafe FFI functions like other unsafe functions in this regard.
Remove the workaround for gh32959
This workaround is no longer necessary as Rust, and by extension MIR, now support uninhabited type
properly. This removes the workaround for the gh32959 that was introduced in gh33267.
Fixes#32959
Remove unnecessary LLVMRustPersonalityFn binding
LLVM Core C bindings provide this function for all the versions back to what we support (3.7), and
helps to avoid this unnecessary builder->function transition every time. Also a negative diff.
Fixes#38462 (although it was pretty much fixed already)
Improve doc cfg(test) and tests directory
Hi,
I was facing a problem with my code organisation. I was using a tests directory and i defined some `#[cfg(test)]` in my `src/`. But i was not able to use it in my `tests` folder.
```bash
.
├── Cargo.lock
├── Cargo.toml
├── src
│ ├── lib.rs
│ └── test.rs
└── tests
└── x.rs
```
> src/lib.rs
```rust
pub mod test;
fn tesst() {
assert!(test::t());
}
```
> src/test.rs
```rust
pub fn t() -> bool { true }
```
> test/x.rs
```rust
extern crate testt;
use testt::test;
fn tesst() {
assert!(test::t());
}
```
I was unable to compile using `cargo test`:
```bash
error[E0432]: unresolved import `testt::test`
--> tests/x.rs:3:5
|
3 | use testt::test;
| ^^^^^^^^^^^ no `test` in `testt`
```
If i remove the `tests` directory everything works fine. To use an utils module in your `tests` directory, you need to create a module in the directory (like `tests/utils.rs`). My `tests/x.rs` look like this now:
```rust
extern crate testt;
mod utils;
fn tesst() {
assert!(utils::t());
}
```
And my tree:
```bash
.
├── Cargo.lock
├── Cargo.toml
├── src
│ └── lib.rs
└── tests
├── utils.rs
└── x.rs
```
I think that thing must be documented in the book.
Ping:
- @badboy : Because he's the one who showed me the path
- @shahn : Because he helped me too to find the solution
Signed-off-by: Freyskeyd <simon.paitrault@iadvize.com>
Use less syscalls in `anon_pipe()`
Save a `ENOSYS` failure from `pipe2` and don't try again.
Use `cvt` instead of `cvt_r` for `pipe2` - `EINTR` is not an error
`pipe2` can return.
Add clearer error message using `&str + &str`
This is the first part of #39018. One of the common things for new users
coming from more dynamic languages like JavaScript, Python or Ruby is to
use `+` to concatenate strings. However, this doesn't work that way in
Rust unless the first type is a `String`. This commit adds a check for
this use case and outputs a new error as well as a suggestion to guide
the user towards the desired behavior. It also adds a new test case to
test the output of the error.
Privatize constructors of tuple structs with private fields
This PR implements the strictest version of such "privatization" - it just sets visibilities for struct constructors, this affects everything including imports.
```
visibility(struct_ctor) = min(visibility(struct), visibility(field_1), ..., visibility(field_N))
```
Needs crater run before proceeding.
Resolves https://github.com/rust-lang/rfcs/issues/902
r? @nikomatsakis