]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoRollup merge of #74707 - matklad:split_once, r=dtolnay
Yuki Okushi [Wed, 29 Jul 2020 00:24:17 +0000 (09:24 +0900)]
Rollup merge of #74707 - matklad:split_once, r=dtolnay

Add str::[r]split_once

This is useful for quick&dirty parsing of key: value config pairs. Used a bunch in Cargo and rust-analyzer:

* https://github.com/rust-lang/cargo/search?q=splitn%282&unscoped_q=splitn%282
* https://github.com/rust-analyzer/rust-analyzer/search?q=split_delim&unscoped_q=split_delim

In theory, once const-generics are done, this functionality could be achieved without a dedicated method with

```rust
match s.splitn(delimier, 2).collect_array::<2>() {
  Some([prefix, suffix]) => todo!(),
  None => todo!(),
}
```

Even in that world, having a dedicated method seems clearer on the intention.

I am not sure about naming -- this is something I've just came up with yesterday, I don't know off the top of my head analogs in other languages.

If T-libs thinks this is a reasonable API to have, I'll open a tracking issue and add more thorough tests.

4 years agoRollup merge of #74671 - rust-lang:const-generics-coerce-unsized, r=nikomatsakis
Yuki Okushi [Wed, 29 Jul 2020 00:24:15 +0000 (09:24 +0900)]
Rollup merge of #74671 - rust-lang:const-generics-coerce-unsized, r=nikomatsakis

add const generics array coercion test

4 years agoRollup merge of #74266 - GuillaumeGomez:cleanup-e0720, r=Dylan-DPC
Yuki Okushi [Wed, 29 Jul 2020 00:24:13 +0000 (09:24 +0900)]
Rollup merge of #74266 - GuillaumeGomez:cleanup-e0720, r=Dylan-DPC

Clean up E0720 explanation

r? @Dylan-DPC

4 years agoAuto merge of #74791 - tmiasko:raw-waker-inline, r=LukasKalbertodt
bors [Tue, 28 Jul 2020 23:45:05 +0000 (23:45 +0000)]
Auto merge of #74791 - tmiasko:raw-waker-inline, r=LukasKalbertodt

Add #[inline] to RawWaker::new

`RawWaker::new` is used when creating a new waker or cloning an existing one,
for example as in code below. The `RawWakerVTable::new` can be const evaluated,
but `RawWaker::new` itself cannot since waker pointer is not known at compile
time. Add `#[inline]` to avoid overhead of a function call.

```rust
unsafe fn clone_waker<W: Wake + Send + Sync + 'static>(waker: *const ()) -> RawWaker {
    unsafe { Arc::incr_strong_count(waker as *const W) };
    RawWaker::new(
        waker as *const (),
        &RawWakerVTable::new(clone_waker::<W>, wake::<W>, wake_by_ref::<W>, drop_waker::<W>),
    )
}
```

4 years agostd: Switch from libbacktrace to gimli
Alex Crichton [Wed, 13 May 2020 21:22:37 +0000 (14:22 -0700)]
std: Switch from libbacktrace to gimli

This commit is a proof-of-concept for switching the standard library's
backtrace symbolication mechanism on most platforms from libbacktrace to
gimli. The standard library's support for `RUST_BACKTRACE=1` requires
in-process parsing of object files and DWARF debug information to
interpret it and print the filename/line number of stack frames as part
of a backtrace.

Historically this support in the standard library has come from a
library called "libbacktrace". The libbacktrace library seems to have
been extracted from gcc at some point and is written in C. We've had a
lot of issues with libbacktrace over time, unfortunately, though. The
library does not appear to be actively maintained since we've had
patches sit for months-to-years without comments. We have discovered a
good number of soundness issues with the library itself, both when
parsing valid DWARF as well as invalid DWARF. This is enough of an issue
that the libs team has previously decided that we cannot feed untrusted
inputs to libbacktrace. This also doesn't take into account the
portability of libbacktrace which has been difficult to manage and
maintain over time. While possible there are lots of exceptions and it's
the main C dependency of the standard library right now.

For years it's been the desire to switch over to a Rust-based solution
for symbolicating backtraces. It's been assumed that we'll be using the
Gimli family of crates for this purpose, which are targeted at safely
and efficiently parsing DWARF debug information. I've been working
recently to shore up the Gimli support in the `backtrace` crate. As of a
few weeks ago the `backtrace` crate, by default, uses Gimli when loaded
from crates.io. This transition has gone well enough that I figured it
was time to start talking seriously about this change to the standard
library.

This commit is a preview of what's probably the best way to integrate
the `backtrace` crate into the standard library with the Gimli feature
turned on. While today it's used as a crates.io dependency, this commit
switches the `backtrace` crate to a submodule of this repository which
will need to be updated manually. This is not done lightly, but is
thought to be the best solution. The primary reason for this is that the
`backtrace` crate needs to do some pretty nontrivial filesystem
interactions to locate debug information. Working without `std::fs` is
not an option, and while it might be possible to do some sort of
trait-based solution when prototyped it was found to be too unergonomic.
Using a submodule allows the `backtrace` crate to build as a submodule
of the `std` crate itself, enabling it to use `std::fs` and such.

Otherwise this adds new dependencies to the standard library. This step
requires extra attention because this means that these crates are now
going to be included with all Rust programs by default. It's important
to note, however, that we're already shipping libbacktrace with all Rust
programs by default and it has a bunch of C code implementing all of
this internally anyway, so we're basically already switching
already-shipping functionality to Rust from C.

* `object` - this crate is used to parse object file headers and
  contents. Very low-level support is used from this crate and almost
  all of it is disabled. Largely we're just using struct definitions as
  well as convenience methods internally to read bytes and such.

* `addr2line` - this is the main meat of the implementation for
  symbolication. This crate depends on `gimli` for DWARF parsing and
  then provides interfaces needed by the `backtrace` crate to turn an
  address into a filename / line number. This crate is actually pretty
  small (fits in a single file almost!) and mirrors most of what
  `dwarf.c` does for libbacktrace.

* `miniz_oxide` - the libbacktrace crate transparently handles
  compressed debug information which is compressed with zlib. This crate
  is used to decompress compressed debug sections.

* `gimli` - not actually used directly, but a dependency of `addr2line`.

* `adler32`- not used directly either, but a dependency of
  `miniz_oxide`.

The goal of this change is to improve the safety of backtrace
symbolication in the standard library, especially in the face of
possibly malformed DWARF debug information. Even to this day we're still
seeing segfaults in libbacktrace which could possibly become security
vulnerabilities. This change should almost entirely eliminate this
possibility whilc also paving the way forward to adding more features
like split debug information.

Some references for those interested are:

* Original addition of libbacktrace - #12602
* OOM with libbacktrace - #24231
* Backtrace failure due to use of uninitialized value - #28447
* Possibility to feed untrusted data to libbacktrace - #21889
* Soundness fix for libbacktrace - #33729
* Crash in libbacktrace - #39468
* Support for macOS, never merged - ianlancetaylor/libbacktrace#2
* Performance issues with libbacktrace - #29293, #37477
* Update procedure is quite complicated due to how many patches we
  need to carry - #50955
* Libbacktrace doesn't work on MinGW with dynamic libs - #71060
* Segfault in libbacktrace on macOS - #71397

Switching to Rust will not make us immune to all of these issues. The
crashes are expected to go away, but correctness and performance may
still have bugs arise. The gimli and `backtrace` crates, however, are
actively maintained unlike libbacktrace, so this should enable us to at
least efficiently apply fixes as situations come up.

4 years agoRefactor MIR coverage instrumentation
Rich Kadel [Mon, 27 Jul 2020 23:25:08 +0000 (16:25 -0700)]
Refactor MIR coverage instrumentation

Lays a better foundation for injecting more counters in each function.

4 years agohandle ConstEquate in rustdoc
Bastian Kauschke [Tue, 28 Jul 2020 22:00:55 +0000 (00:00 +0200)]
handle ConstEquate in rustdoc

4 years agoAuto merge of #74861 - mark-i-m:mv-std-followup, r=Mark-Simulacrum
bors [Tue, 28 Jul 2020 21:48:22 +0000 (21:48 +0000)]
Auto merge of #74861 - mark-i-m:mv-std-followup, r=Mark-Simulacrum

Re-enable linkcheck after moving std

4 years agoCache non-exhaustive separately from attributes
Mark Rousskov [Tue, 28 Jul 2020 17:31:48 +0000 (13:31 -0400)]
Cache non-exhaustive separately from attributes

4 years agoAuto merge of #74471 - da-x:string-type-diagnostic-item, r=petrochenkov
bors [Tue, 28 Jul 2020 20:00:37 +0000 (20:00 +0000)]
Auto merge of #74471 - da-x:string-type-diagnostic-item, r=petrochenkov

librustc_typeck: use diag item instead of string compare

4 years agoCollect library features from library/
Mark Rousskov [Tue, 28 Jul 2020 13:52:39 +0000 (09:52 -0400)]
Collect library features from library/

4 years agoreenable tests after moving std
mark [Tue, 28 Jul 2020 04:02:34 +0000 (23:02 -0500)]
reenable tests after moving std

4 years agoAuto merge of #74482 - alexcrichton:update-stdarch, r=hanna-kruppe
bors [Tue, 28 Jul 2020 17:39:39 +0000 (17:39 +0000)]
Auto merge of #74482 - alexcrichton:update-stdarch, r=hanna-kruppe

Update stdarch submodule

This commit updates the src/stdarch submodule primarily to include
rust-lang/stdarch#874 which updated and revamped WebAssembly SIMD
intrinsics and renamed WebAssembly atomics intrinsics. This is all
unstable surface area of the standard library so the changes should be
ok here. The SIMD updates also enable SIMD intrinsics to be used by any
program any any time, yay!

cc #74372, a tracking issue I've opened for the stabilization of SIMD
intrinsics

4 years agoReplace write-to-vec hack by introducing a display renderer for allocations
Oliver Scherer [Tue, 28 Jul 2020 17:16:09 +0000 (19:16 +0200)]
Replace write-to-vec hack by introducing a display renderer for allocations

4 years agoAdd note to clearly mark the RFC as rejected
Alexis Bourget [Sun, 26 Jul 2020 20:00:29 +0000 (22:00 +0200)]
Add note to clearly mark the RFC as rejected

4 years agoRemove links to rejected errata 4406 for RFC 4291
Alexis Bourget [Sat, 25 Jul 2020 12:55:51 +0000 (14:55 +0200)]
Remove links to rejected errata 4406 for RFC 4291

4 years agoUpdate stdarch submodule
Alex Crichton [Sat, 18 Jul 2020 15:43:09 +0000 (08:43 -0700)]
Update stdarch submodule

This commit updates the src/stdarch submodule primarily to include
rust-lang/stdarch#874 which updated and revamped WebAssembly SIMD
intrinsics and renamed WebAssembly atomics intrinsics. This is all
unstable surface area of the standard library so the changes should be
ok here. The SIMD updates also enable SIMD intrinsics to be used by any
program any any time, yay!

cc #74372, a tracking issue I've opened for the stabilization of SIMD
intrinsics

4 years agoReplace all uses of `log::log_enabled` with `Debug` printers
Oliver Scherer [Tue, 28 Jul 2020 14:15:40 +0000 (16:15 +0200)]
Replace all uses of `log::log_enabled` with `Debug` printers

4 years agoAuto merge of #73964 - jyn514:sane-defaults, r=Mark-Simulacrum
bors [Tue, 28 Jul 2020 13:56:32 +0000 (13:56 +0000)]
Auto merge of #73964 - jyn514:sane-defaults, r=Mark-Simulacrum

Improve defaults in x.py

- Make the default stage dependent on the subcommand
- Don't build stage1 rustc artifacts with x.py build --stage 1. If this is what you want, use x.py build --stage 2 instead, which gives you a working libstd.
- Change default debuginfo when debug = true from 2 to 1

I tried to fix CI to use `--stage 2` everywhere it currently has no stage, but I might have missed a spot.
This does not update much of the documentation - most of it is in https://github.com/rust-lang/rustc-dev-guide/ or https://github.com/rust-lang/rust-forge and will need a separate PR.

See individual commits for a detailed rationale of each change.
See also the MCP: https://github.com/rust-lang/compiler-team/issues/326

r? @Mark-Simulacrum , but anyone is free to give an opinion.

4 years agoUse --stage 2 in checktools
Joshua Nelson [Tue, 28 Jul 2020 13:36:56 +0000 (09:36 -0400)]
Use --stage 2 in checktools

- Remove useless --stage 2 argument to checktools.sh
- Fix help text for expand-yaml-anchors (it had a typo)

4 years agoFix bad rebase
Joshua Nelson [Tue, 28 Jul 2020 12:34:59 +0000 (08:34 -0400)]
Fix bad rebase

4 years agosymbol mangling: use ty::print::Print for consts
Bastian Kauschke [Tue, 28 Jul 2020 12:34:18 +0000 (14:34 +0200)]
symbol mangling: use ty::print::Print for consts

4 years agoEnable to ping RISC-V group via triagebot
Yuki Okushi [Tue, 28 Jul 2020 12:01:13 +0000 (21:01 +0900)]
Enable to ping RISC-V group via triagebot

4 years agoEnable docs on dist-x86_64-musl
David Sonder [Tue, 28 Jul 2020 11:28:43 +0000 (13:28 +0200)]
Enable docs on dist-x86_64-musl

Add the rust-docs component to toolchain x86_64-unknown-linux-musl, which allows
people using rustup on their musl-based linux distribution to download the
rust-docs.

4 years agoAuto merge of #74796 - infinity0:master, r=nikomatsakis
bors [Tue, 28 Jul 2020 09:02:32 +0000 (09:02 +0000)]
Auto merge of #74796 - infinity0:master, r=nikomatsakis

config.toml.example: Update remap-debuginfo doc to be more general & accurate

This makes it more obvious that the work-around to #74786 is actually correct, and a custom `--remap-path-prefix` isn't needed.

In fact the previous comment `/rustc/$hash/$crate` was wrong, it is not `$crate` but whatever path exists in the rustc source tree, so either `src/$crate` or `vendor/$crate`. I've fixed that as well to avoid future confusion.

4 years agoAdd str::[r]split_once
Aleksey Kladov [Fri, 24 Jul 2020 07:39:09 +0000 (09:39 +0200)]
Add str::[r]split_once

This is useful for quick&dirty parsing of key: value config pairs

4 years agoFix RefUnwindSafe & UnwinsSafe impls for lazy::SyncLazy
Aleksey Kladov [Mon, 27 Jul 2020 09:22:36 +0000 (11:22 +0200)]
Fix RefUnwindSafe & UnwinsSafe impls for lazy::SyncLazy

The logic here is the same as for Send&Sync impls.

4 years agoDon't use "weak count" around Weak::from_raw_ptr
Michal 'vorner' Vaner [Sun, 26 Jul 2020 13:31:58 +0000 (15:31 +0200)]
Don't use "weak count" around Weak::from_raw_ptr

As `Rc/Arc::weak_count` returns 0 when having no strong counts, this
could be confusing and it's better to avoid using that completely.

Closes #73840.

4 years agoAuto merge of #74855 - jyn514:separate-lints, r=Manishearth
bors [Tue, 28 Jul 2020 05:49:59 +0000 (05:49 +0000)]
Auto merge of #74855 - jyn514:separate-lints, r=Manishearth

Separate `missing_doc_code_examples` from intra-doc links

These two lints have no relation other than both being nightly-only.
This allows stabilizing intra-doc links without stabilizing `missing_doc_code_examples`.

Fixes one of the issues spotted by @ollie27 in https://github.com/rust-lang/rust/pull/74430#issuecomment-664693080.

r? @Manishearth

4 years agoayu theme: Change doccomment color to `#a1ac88`
Lzu Tao [Tue, 28 Jul 2020 05:12:12 +0000 (05:12 +0000)]
ayu theme: Change doccomment color to `#a1ac88`

Co-authored-by: Cldfire <cldfire@3grid.net>
4 years agoupdate stderr for polymorphic ui test
Ashley Mannix [Tue, 28 Jul 2020 04:37:31 +0000 (14:37 +1000)]
update stderr for polymorphic ui test

4 years agoAdd #[inline] to RawWaker::new
Tomasz Miąsko [Sun, 26 Jul 2020 00:00:00 +0000 (00:00 +0000)]
Add #[inline] to RawWaker::new

4 years agoAuto merge of #74841 - infinity0:fix-exec, r=Mark-Simulacrum
bors [Tue, 28 Jul 2020 03:42:22 +0000 (03:42 +0000)]
Auto merge of #74841 - infinity0:fix-exec, r=Mark-Simulacrum

rustbuild: use Display for exit status instead of Debug, see #74832 for justification

4 years agoremove unstable const_type_id feature
Ashley Mannix [Tue, 28 Jul 2020 03:33:08 +0000 (13:33 +1000)]
remove unstable const_type_id feature

4 years agobump const type id stabilization to 1.46.0
Ashley Mannix [Tue, 30 Jun 2020 00:21:22 +0000 (10:21 +1000)]
bump const type id stabilization to 1.46.0

4 years agostabilize const_type_id feature
Ashley Mannix [Sat, 23 May 2020 05:17:19 +0000 (15:17 +1000)]
stabilize const_type_id feature

4 years agoprivate_items_doc_tests -> doc_test_lints
Joshua Nelson [Tue, 28 Jul 2020 03:05:01 +0000 (23:05 -0400)]
private_items_doc_tests -> doc_test_lints

4 years agoUse exhaustive match for assert
Joshua Nelson [Tue, 28 Jul 2020 01:53:10 +0000 (21:53 -0400)]
Use exhaustive match for assert

4 years agoAdd assert that tests happen with stage 2 in CI
Joshua Nelson [Mon, 27 Jul 2020 19:53:01 +0000 (15:53 -0400)]
Add assert that tests happen with stage 2 in CI

- Use stage 2 for makefile
- Move assert to builder
- Don't add an assert for --help
- Allow --stage 0 if passed explicitly
- Don't assert defaults during tests

Otherwise it's impossible to test the defaults!

4 years agoUse --stage 2 explicitly in CI
Joshua Nelson [Tue, 14 Jul 2020 02:28:26 +0000 (22:28 -0400)]
Use --stage 2 explicitly in CI

- expand yaml anchors
- don't use --stage 2 for dist; that's already the default

4 years agoAdd tests for the new behavior
Joshua Nelson [Tue, 14 Jul 2020 00:25:21 +0000 (20:25 -0400)]
Add tests for the new behavior

- Only set stage 2 in dist tests
- Add test for `x.py doc` without args
- Add test for `x.py build` without args
- Add test for `x.py build --stage 0`

4 years agoMove tests into a submodule
Joshua Nelson [Tue, 14 Jul 2020 00:20:42 +0000 (20:20 -0400)]
Move tests into a submodule

4 years agoFix most bootstrap tests
Joshua Nelson [Mon, 13 Jul 2020 23:55:33 +0000 (19:55 -0400)]
Fix most bootstrap tests

Uses --stage 2 for all the existing tests

4 years agoChange debuginfo to default to 1 if `debug = true` is set
Joshua Nelson [Thu, 2 Jul 2020 12:59:50 +0000 (08:59 -0400)]
Change debuginfo to default to 1 if `debug = true` is set

From [a conversation in discord](https://discordapp.com/channels/442252698964721669/443151243398086667/719200989269327882):

> Linking seems to consume all available RAM, leading to the OS to swap memory to disk and slowing down everything in the process
Compiling itself doesn't seem to take up as much RAM, and I'm only looking to check whether a minimal testcase can be compiled by rustc, where the runtime performance isn't much of an issue

> do you have debug = true or debuginfo-level = 2 in config.toml?
> if so I think that results in over 2GB of debuginfo nowadays and is likely the culprit
> which might mean we're giving out bad advice :(

Anecdotally, this sped up my stage 1 build from 15 to 10 minutes.

This still adds line numbers, it only removes variable and type information.

- Improve wording for debuginfo description

Co-authored-by: Teymour Aldridge <42674621+teymour-aldridge@users.noreply.github.com>
4 years agoDon't build rustc without std
Joshua Nelson [Thu, 2 Jul 2020 12:40:34 +0000 (08:40 -0400)]
Don't build rustc without std

- Set rustc to build only when explicitly asked for

This allows building the stage2 rustc artifacts, which nothing depends
on.

Previously the behavior was as follows (where stageN <-> stage(N-1) artifacts, except for stage0 libstd):

- `x.py build --stage 0`:
  - stage0 libstd
  - stage1 rustc (but without putting rustc in stage0/)

This leaves you without any rustc at all except for the beta compiler
(https://github.com/rust-lang/rust/issues/73519). This is never what you want.

- `x.py build --stage 1`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage1 rustdoc
  - stage2 rustc

This leaves you with a broken stage2 rustc which doesn't even have
libcore and is effectively useless. Additionally, it compiles rustc
twice, which is not normally what you want.

- `x.py build --stage 2`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage2 rustc
  - stage2 rustdoc and tools

This builds all tools in release mode. This is the correct usage for CI,
but takes far to long for development.

Now the behavior is as follows:

- `x.py build --stage 0`:
  - stage0 libstd

This is suitable for contributors only working on the standard library,
as it means rustc never has to be compiled.

- `x.py build --stage 1`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage1 rustdoc

This is suitable for contributors working on the compiler. It ensures
that you have a working rustc and libstd without having to pass
`src/libstd` in addition.

- `x.py build --stage 2`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage2 rustc
  - stage2 libstd
  - stage2 rustdoc

This is suitable for debugging errors which only appear with the stage2
compiler.

- `x.py build --stage 2 src/libstd src/rustc`
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage2 rustc
  - stage2 libstd
  - stage2 rustdoc, tools, etc.
  - stage2 rustc artifacts ('stage3')

This is suitable for CI, which wants all tools in release mode.
However, most of the use cases for this should use `x.py dist` instead,
which builds all the tools without each having to be named individually.

4 years agoMake the default stage dependent on the subcommand
Joshua Nelson [Thu, 2 Jul 2020 12:08:09 +0000 (08:08 -0400)]
Make the default stage dependent on the subcommand

 ### x.py build/test: stage 1

I've seen very few people who actually use full stage 2 builds on purpose. These compile rustc and libstd twice and don't give you much more information than a stage 1 build (except in rare cases like https://github.com/rust-lang/rust/pull/68692#discussion_r376392145). For new contributors, this makes the build process even more daunting than it already is. As long as CI is changed to use `--stage 2` I see no downside here.

 ### x.py bench/dist/install: stage 2

These commands have to do with a finished, optimized version of rustc. It seems very rare to want to use these with a stage 1 build.

 ### x.py doc: stage 0

Normally when you document things you're just fixing a typo. In this case there is no need to build the whole rust compiler, since the documentation will usually be the same when generated with the beta compiler or with stage 1.

Note that for this release cycle only there will be a significant different between stage0 and stage1 docs: https://github.com/rust-lang/rust/pull/73101. However most of the time this will not be the case.

4 years agoDon't duplicate builder code
Joshua Nelson [Thu, 2 Jul 2020 12:07:56 +0000 (08:07 -0400)]
Don't duplicate builder code

- Add Builder::new_internal

4 years agoUpdate outdated readme
Who? Me?! [Tue, 28 Jul 2020 03:05:34 +0000 (22:05 -0500)]
Update outdated readme

4 years agoMove `look_for_tests` to `private_items_doc_tests`
Joshua Nelson [Tue, 28 Jul 2020 03:03:56 +0000 (23:03 -0400)]
Move `look_for_tests` to `private_items_doc_tests`

4 years agoSeparate `missing_doc_code_examples` from intra-doc links
Joshua Nelson [Tue, 28 Jul 2020 02:16:41 +0000 (22:16 -0400)]
Separate `missing_doc_code_examples` from intra-doc links

These two lints have no relation other than both being nightly-only.
This allows stabilizing intra-doc links without stabilizing
missing_doc_code_examples.

4 years agoAuto merge of #73265 - mark-i-m:mv-std, r=Mark-Simulacrum,mark-i-m
bors [Tue, 28 Jul 2020 00:51:53 +0000 (00:51 +0000)]
Auto merge of #73265 - mark-i-m:mv-std, r=Mark-Simulacrum,mark-i-m

mv std libs to library/

This is the first step in refactoring the directory layout of this repository, with further followup steps planned (but not done yet).

Background: currently, all crates are under src/, without nested src directories and with the unconventional `lib*` prefixes (e.g., `src/libcore/lib.rs`). This directory structures is not idiomatic and makes the `src/` directory rather overwhelming. To improve contributor experience and make things a bit more approachable, we are reorganizing the repo a bit.

In this PR, we move the standard libs (basically anything that is "runtime", as opposed to part of the compiler, build system, or one of the tools, etc). The new layout moves these libraries to a new `library/` directory in the root of the repo. Additionally, we remove the `lib*` prefixes and add nested `src/` directories.  The other crates/tools in this repo are not touched. So in summary:

```
library/<crate>/src/*.rs
src/<all the rest>     // unchanged
```

where `<crate>` is:
- core
- alloc
- std
- test
- proc_macro
- panic_abort
- panic_unwind
- profiler_builtins
- term
- unwind
- rtstartup
- backtrace
- rustc-std-workspace-*

There was a lot of discussion about this and a few rounds of compiler team approvals, FCPs, MCPs, and nominations. The original MCP is https://github.com/rust-lang/compiler-team/issues/298. The final approval of the compiler team was given here: https://github.com/rust-lang/rust/pull/73265#issuecomment-659498446.

The name `library` was chosen to complement a later move of the compiler crates to a `compiler/` directory. There was a lot of discussion around adding the nested `src/` directories. Note that this does increase the nesting depth (plausibly important for manual traversal of the tree, e.g., through GitHub's UI or `cd`), but this is deemed to be better as it fits the standard layout of Rust crates throughout most of the ecosystem, though there is some debate about how much this should apply to multi-crate projects. Overall, there seem to be more people in favor of nested `src/` than against.

After this PR, there are no dependencies out of the `library/` directory except on the `build_helper` (or crates.io crates).

4 years agomv std libs to library/
mark [Fri, 12 Jun 2020 02:31:49 +0000 (21:31 -0500)]
mv std libs to library/

4 years agoMake closures and generators a must use types
Tomasz Miąsko [Tue, 28 Jul 2020 00:00:00 +0000 (00:00 +0000)]
Make closures and generators a must use types

Warn about unused expressions with closure or generator type. This follows
existing precedence of must use annotations present on `FnOnce`, `FnMut`, `Fn`
traits, which already indirectly apply to closures in some cases, e.g.,:

```rust
fn f() -> impl FnOnce() {
    || {}
}

fn main() {
    // an existing warning: unused implementer of `std::ops::FnOnce` that must be used:
    f();

    // a new warning: unused closure that must be used:
    || {};
}
```

4 years agoAuto merge of #73583 - anp:location-eq, r=dtolnay
bors [Mon, 27 Jul 2020 22:38:25 +0000 (22:38 +0000)]
Auto merge of #73583 - anp:location-eq, r=dtolnay

Derive common traits for panic::Location.

Now that `#[track_caller]` is on track to stabilize, one of the roughest edges of working with it is the fact that you can't do much with `Location` except turn it back into a `(&str, u32, u32)`. Which makes sense because the type was defined around the panic machinery originally passing around that tuple (it has the same layout as Location even).

This PR derives common traits for the type in accordance with the [API guidelines](https://rust-lang.github.io/api-guidelines/interoperability.html#types-eagerly-implement-common-traits-c-common-traits) (those apply to core, right?).

There's a risk here, e.g. if we ever change the representation of `Location` in a way that makes it harder to implement `Ord`, we might not be able to make that change in a backwards-compatible way. I don't think there's any other compatibility hazard here, as the only changes we currently imagine for the type are to add end fields.

cc @rust-lang/libs

4 years agoMore requested changes
Joseph Ryan [Mon, 27 Jul 2020 22:34:17 +0000 (17:34 -0500)]
More requested changes

4 years agoSuppress debuginfo on naked function arguments
Nathaniel McCallum [Mon, 6 Jul 2020 18:32:30 +0000 (14:32 -0400)]
Suppress debuginfo on naked function arguments

A function that has no prologue cannot be reasonably expected to support
debuginfo. In fact, the existing code (before this patch) would generate
invalid instructions that caused crashes. We can solve this easily by
just not emitting the debuginfo in this case.

Fixes https://github.com/rust-lang/rust/issues/42779
cc https://github.com/rust-lang/rust/issues/32408

4 years agorustbuild: refactor how the wrapper deals with exit codes
Ximin Luo [Mon, 27 Jul 2020 22:22:07 +0000 (23:22 +0100)]
rustbuild: refactor how the wrapper deals with exit codes

4 years agorustbuild: format both Ok/Err separately, since Result doesn't do it
Ximin Luo [Mon, 27 Jul 2020 21:44:48 +0000 (22:44 +0100)]
rustbuild: format both Ok/Err separately, since Result doesn't do it

4 years agoEnable the profiler on FreeBSD
Alan Somers [Mon, 27 Jul 2020 21:17:15 +0000 (15:17 -0600)]
Enable the profiler on FreeBSD

FreeBSD has been doing this in our own package builds for two months
now.

https://svnweb.freebsd.org/ports?view=revision&revision=535771

4 years agorustbuild: use Display for exit status instead of Debug, see #74832 for justification
Ximin Luo [Mon, 27 Jul 2020 21:06:04 +0000 (22:06 +0100)]
rustbuild: use Display for exit status instead of Debug, see #74832 for justification

4 years agoMake requested changes
Joseph Ryan [Mon, 29 Jun 2020 23:22:58 +0000 (18:22 -0500)]
Make requested changes

4 years agoTODO -> FIXME
Joseph Ryan [Fri, 26 Jun 2020 14:14:45 +0000 (09:14 -0500)]
TODO -> FIXME

4 years agoPull out more types from html
Joseph Ryan [Fri, 26 Jun 2020 13:18:20 +0000 (08:18 -0500)]
Pull out more types from html

4 years agoExtract `Cache` and other types from `html` module
Joseph Ryan [Wed, 24 Jun 2020 13:16:21 +0000 (08:16 -0500)]
Extract `Cache` and other types from `html` module

4 years agoRefactor html backend to use generic interface
Joseph Ryan [Wed, 17 Jun 2020 17:41:45 +0000 (12:41 -0500)]
Refactor html backend to use generic interface

4 years agoMove `Error` and `RenderInfo` out of `html` module
Joseph Ryan [Mon, 15 Jun 2020 18:42:29 +0000 (13:42 -0500)]
Move `Error` and `RenderInfo` out of `html` module

4 years agoAuto merge of #73503 - lcnr:forall-predicate-what-and-why-2, r=nikomatsakis
bors [Mon, 27 Jul 2020 20:16:36 +0000 (20:16 +0000)]
Auto merge of #73503 - lcnr:forall-predicate-what-and-why-2, r=nikomatsakis

convert higher ranked `Predicate`s to `PredicateKind::ForAll`

implements step 2 of https://github.com/rust-lang/compiler-team/issues/285
r? @nikomatsakis

4 years agoclippy
Bastian Kauschke [Mon, 27 Jul 2020 19:17:28 +0000 (21:17 +0200)]
clippy

4 years agocleanup
Bastian Kauschke [Tue, 21 Jul 2020 13:42:18 +0000 (15:42 +0200)]
cleanup

4 years agofix rustdoc
Bastian Kauschke [Sat, 18 Jul 2020 16:46:30 +0000 (18:46 +0200)]
fix rustdoc

4 years agoit works again :tada:
Bastian Kauschke [Sat, 18 Jul 2020 12:37:36 +0000 (14:37 +0200)]
it works again :tada:

4 years agofix rebase
Bastian Kauschke [Sat, 18 Jul 2020 10:06:47 +0000 (12:06 +0200)]
fix rebase

4 years agodirectly contain `PredicateAtom` in `PredicateKind::ForAll`
Bastian Kauschke [Sat, 18 Jul 2020 09:46:38 +0000 (11:46 +0200)]
directly contain `PredicateAtom` in `PredicateKind::ForAll`

4 years agointroduce PredicateAtom
Bastian Kauschke [Wed, 8 Jul 2020 22:35:55 +0000 (00:35 +0200)]
introduce PredicateAtom

4 years agoadd reuse_or_mk_predicate
Bastian Kauschke [Wed, 24 Jun 2020 16:06:04 +0000 (18:06 +0200)]
add reuse_or_mk_predicate

4 years agorefactor query_outlives_constraints_into_obligations
Bastian Kauschke [Wed, 24 Jun 2020 15:54:13 +0000 (17:54 +0200)]
refactor query_outlives_constraints_into_obligations

4 years agothis might be unqualified, but at least it's now quantified
Bastian Kauschke [Wed, 24 Jun 2020 15:40:28 +0000 (17:40 +0200)]
this might be unqualified, but at least it's now quantified

4 years agofix rustdoc
Bastian Kauschke [Sun, 21 Jun 2020 12:42:47 +0000 (14:42 +0200)]
fix rustdoc

4 years agosplit ignore_qualifiers
Bastian Kauschke [Sun, 21 Jun 2020 10:26:17 +0000 (12:26 +0200)]
split ignore_qualifiers

4 years agoreview
Bastian Kauschke [Fri, 19 Jun 2020 22:21:59 +0000 (00:21 +0200)]
review

4 years agofix elaborate for predicates with unbound variables
Bastian Kauschke [Fri, 19 Jun 2020 17:19:21 +0000 (19:19 +0200)]
fix elaborate for predicates with unbound variables

4 years agoclippy
Bastian Kauschke [Fri, 19 Jun 2020 08:22:25 +0000 (10:22 +0200)]
clippy

4 years agorustdoc
Bastian Kauschke [Fri, 19 Jun 2020 08:05:05 +0000 (10:05 +0200)]
rustdoc

4 years ago`PredicateKint` -> `PredicateKind`, the beginning of the end
Bastian Kauschke [Thu, 18 Jun 2020 18:41:43 +0000 (20:41 +0200)]
`PredicateKint` -> `PredicateKind`, the beginning of the end

4 years agoprogress
Bastian Kauschke [Thu, 18 Jun 2020 18:33:52 +0000 (20:33 +0200)]
progress

4 years agoelaborate
Bastian Kauschke [Thu, 18 Jun 2020 15:43:26 +0000 (17:43 +0200)]
elaborate

4 years agosubst_supertrait
Bastian Kauschke [Wed, 17 Jun 2020 22:18:58 +0000 (00:18 +0200)]
subst_supertrait

4 years agosomewhat related cleanup
Bastian Kauschke [Wed, 17 Jun 2020 21:20:17 +0000 (23:20 +0200)]
somewhat related cleanup

4 years agowf
Bastian Kauschke [Wed, 17 Jun 2020 20:50:28 +0000 (22:50 +0200)]
wf

4 years agoconvert trivial predicates
Bastian Kauschke [Wed, 17 Jun 2020 09:30:18 +0000 (11:30 +0200)]
convert trivial predicates

4 years agoquery_outlives_constraints_into_obligations
Bastian Kauschke [Wed, 17 Jun 2020 08:46:52 +0000 (10:46 +0200)]
query_outlives_constraints_into_obligations

4 years agoanonymize_predicate
Bastian Kauschke [Tue, 16 Jun 2020 22:13:00 +0000 (00:13 +0200)]
anonymize_predicate

4 years agoHandle trait/projection predicates with bound regions correctly
Matthew Jasper [Sun, 14 Jun 2020 12:22:51 +0000 (13:22 +0100)]
Handle trait/projection predicates with bound regions correctly

4 years agominimal
Bastian Kauschke [Sat, 13 Jun 2020 13:04:28 +0000 (15:04 +0200)]
minimal

4 years agoClean up E0734 explanation
Guillaume Gomez [Mon, 27 Jul 2020 18:55:30 +0000 (20:55 +0200)]
Clean up E0734 explanation

4 years agoadd `PredicateKint`, because who doesn't like bodging
Bastian Kauschke [Thu, 11 Jun 2020 19:42:39 +0000 (21:42 +0200)]
add `PredicateKint`, because who doesn't like bodging

4 years agoAuto merge of #74831 - Manishearth:rollup-ugw4pt4, r=Manishearth
bors [Mon, 27 Jul 2020 16:21:09 +0000 (16:21 +0000)]
Auto merge of #74831 - Manishearth:rollup-ugw4pt4, r=Manishearth

Rollup of 4 pull requests

Successful merges:

 - #73858 (Make more primitive integer methods const)
 - #74487 (Forbid generic parameters in anon consts inside of type defaults)
 - #74803 (rustbuild: fix bad usage of UNIX exec() in rustc wrapper)
 - #74822 (More ensure stack to avoid segfault with increased `recursion_limit`)

Failed merges:

r? @ghost

4 years agoRollup merge of #74822 - JohnTitor:no-sigsegv, r=oli-obk
Manish Goregaokar [Mon, 27 Jul 2020 16:20:20 +0000 (09:20 -0700)]
Rollup merge of #74822 - JohnTitor:no-sigsegv, r=oli-obk

More ensure stack to avoid segfault with increased `recursion_limit`

Fixes #74711
I do not add the test here since the limit value depends on the machine and it's hard to test the output.
r? @oli-obk

4 years agoRollup merge of #74803 - infinity0:fix-exec, r=nagisa
Manish Goregaokar [Mon, 27 Jul 2020 16:20:18 +0000 (09:20 -0700)]
Rollup merge of #74803 - infinity0:fix-exec, r=nagisa

rustbuild: fix bad usage of UNIX exec() in rustc wrapper

exec never returns, it replaces the current process. so anything after it is unreachable. that's not how exec_cmd() is used in the surrounding code

We use `--on-fail env` on Debian. `env` always returns exit code 0. This means that the `rustc` bootstrap wrapper always returns exit code 0 even when it fails. However, the crossbeam-utils build process (due to autocfg) relies on `rustc` returning error exit codes when detecting CPU features, and ends up writing `cargo:rustc-cfg=has_atomic_u128` even when it's not detected, because the `rustc` wrapper is always giving exit code 0.

(This separately is causing our builds to try to compile rustc 40+ times, due to #74801.)

4 years agoRollup merge of #74487 - lcnr:const-in-ty-default, r=varkor
Manish Goregaokar [Mon, 27 Jul 2020 16:20:16 +0000 (09:20 -0700)]
Rollup merge of #74487 - lcnr:const-in-ty-default, r=varkor

Forbid generic parameters in anon consts inside of type defaults

Emit a resolution error for `struct Foo<T, U = [u8; std::mem::size_of::<T>()]>`.
We are unable to support this with the way `ty::Generics` is currently used,
so let's just forbid it entirely for now.

Fixes some ICE on stable, e.g.
```rust
struct Foo<T, U = [u8; std::mem::size_of::<*mut T>()]>(T, U);
```

r? @varkor @eddyb