Commit Graph

163504 Commits

Author SHA1 Message Date
Matthias Krüger
9246e8867c
Rollup merge of #94113 - Mizobrook-kan:issue-94025, r=estebank
document rustc_middle::mir::Field

cc #94025
2022-02-20 00:37:31 +01:00
Matthias Krüger
7cd857dc34
Rollup merge of #94112 - digama0:patch-3, r=scottmcm
Optimize char_try_from_u32

The optimization was proposed by ```````@falk-hueffner``````` in https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Micro-optimizing.20char.3A.3Afrom_u32/near/272146171,  and I simplified it a bit and added an explanation of why the optimization is correct. The generated code is 2 instructions shorter and uses 2 registers instead of 4 on x86.
2022-02-20 00:37:30 +01:00
Matthias Krüger
39a50d8290
Rollup merge of #94097 - pierwill:doc-rustc-middle-query, r=cjgillot
Add module-level docs for `rustc_middle::query`
2022-02-20 00:37:29 +01:00
Matthias Krüger
f2d4ffe81c
Rollup merge of #94093 - tmiasko:pp-no-variants, r=oli-obk
Fix pretty printing of enums without variants

92d20c4aad removed no-variants special case from `try_destructure_const` with expectation that this case would be handled gracefully when `read_discriminant` returns an error.

Alas in that case `read_discriminant` succeeds while returning a non-existing variant, so the special case is still necessary.

Fixes #94073.

r? ````@oli-obk````
2022-02-20 00:37:28 +01:00
Matthias Krüger
9e9cc66e42
Rollup merge of #94091 - GuillaumeGomez:rustdoc-const-computed-value, r=oli-obk
Fix rustdoc const computed value

Fixes #85088.

It looks like this now (instead of hexadecimal):

![Screenshot from 2022-02-17 17-55-39](https://user-images.githubusercontent.com/3050060/154532115-0f9861a0-406f-4c9c-957f-32bedd8aca7d.png)

r? ````@oli-obk````
2022-02-20 00:37:27 +01:00
Matthias Krüger
1771b98a69
Rollup merge of #94023 - krasimirgg:head-llvm-use-llvm-nm, r=Mark-Simulacrum
adapt static-nobundle test to use llvm-nm

No functional changes intended.

This updates the test case to use llvm-nm instead of the system nm.
This fixes an instance over at the experimental build of rustc with HEAD LLVM:
https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/8380#ef6f41b5-8595-49a6-be37-0eff80e0ccb5
It is related to https://github.com/rust-lang/rust/pull/94001.

The issue is that this test uses the system nm, which may not be recent
enough to understand the update to uwtable. This replaces the test to
use the llvm-nm that should be recent enough (consistent with the LLVM
sources we use to build rustc).
2022-02-20 00:37:26 +01:00
Matthias Krüger
6b69121d0d
Rollup merge of #94019 - hermitcore:target, r=Mark-Simulacrum
removing architecture requirements for RustyHermit

RustHermit and HermitCore is able to run on aarch64 and x86_64. In the future these operating systems will also support RISC-V. Consequently, the dependency to a specific target should be removed.

The build process of `hermit-abi` fails if the architecture isn't supported.
2022-02-20 00:37:25 +01:00
Matthias Krüger
1ae00e0b93
Rollup merge of #94002 - GuillaumeGomez:duplicated-sidebar-macro, r=notriddle
rustdoc: Avoid duplicating macros in sidebar

Fixes #93912.

cc ``````@jsha`````` (for the GUI test)
r? ``````@camelid``````
2022-02-20 00:37:24 +01:00
Matthias Krüger
575f6c5cc1
Rollup merge of #93686 - dbrgn:trim-on-byte-slices, r=joshtriplett
core: Implement ASCII trim functions on byte slices

Hi ````````@rust-lang/libs!```````` This is a feature that I wished for when implementing serial protocols with microcontrollers. Often these protocols may contain leading or trailing whitespace, which needs to be removed. Because oftentimes drivers will operate on the byte level, decoding to unicode and checking for unicode whitespace is unnecessary overhead.

This PR adds three new methods to byte slices:

- `trim_ascii_start`
- `trim_ascii_end`
- `trim_ascii`

I did not find any pre-existing discussions about this, which surprises me a bit. Maybe I'm missing something, and this functionality is already possible through other means? There's https://github.com/rust-lang/rfcs/issues/2547 ("Trim methods on slices"), but that has a different purpose.

As per the [std dev guide](https://std-dev-guide.rust-lang.org/feature-lifecycle/new-unstable-features.html), this is a proposed implementation without any issue / RFC. If this is the wrong process, please let me know. However, I thought discussing code is easier than discussing a mere idea, and hacking on the stdlib was fun.

Tracking issue: https://github.com/rust-lang/rust/issues/94035
2022-02-20 00:37:23 +01:00
Matthias Krüger
4f533de571
Rollup merge of #93639 - Mark-Simulacrum:relnotes, r=Mark-Simulacrum
Release notes for 1.59

cc `@rust-lang/release`
r? `@cuviper`
2022-02-20 00:37:22 +01:00
Matthias Krüger
7977af5975
Rollup merge of #93580 - m-ou-se:stabilize-pin-static-ref, r=scottmcm
Stabilize pin_static_ref.

FCP finished here: https://github.com/rust-lang/rust/issues/78186#issuecomment-1024987221

Closes #78186
2022-02-20 00:37:21 +01:00
bors
2690468727 Auto merge of #92911 - nbdd0121:unwind, r=Amanieu
Guard against unwinding in cleanup code

Currently the only safe guard we have against double unwind is the panic count (which is local to Rust). When double unwinds indeed happen (e.g. C++ exception + Rust panic, or two C++ exceptions), then the second unwind actually goes through and the first unwind is leaked. This can cause UB. cc rust-lang/project-ffi-unwind#6

E.g. given the following C++ code:
```c++
extern "C" void foo() {
    throw "A";
}

extern "C" void execute(void (*fn)()) {
    try {
        fn();
    } catch(...) {
    }
}
```

This program is well-defined to terminate:
```c++
struct dtor {
    ~dtor() noexcept(false) {
        foo();
    }
};

void a() {
    dtor a;
    dtor b;
}

int main() {
    execute(a);
    return 0;
}
```

But this Rust code doesn't catch the double unwind:
```rust
extern "C-unwind" {
    fn foo();
    fn execute(f: unsafe extern "C-unwind" fn());
}

struct Dtor;

impl Drop for Dtor {
    fn drop(&mut self) {
        unsafe { foo(); }
    }
}

extern "C-unwind" fn a() {
    let _a = Dtor;
    let _b = Dtor;
}

fn main() {
    unsafe { execute(a) };
}
```

To address this issue, this PR adds an unwind edge to an abort block, so that the Rust example aborts. This is similar to how clang guards against double unwind (except clang calls terminate per C++ spec and we abort).

The cost should be very small; it's an additional trap instruction (well, two for now, since we use TrapUnreachable, but that's a different issue) for each function with landing pads; if LLVM gains support to encode "abort/terminate" info directly in LSDA like GCC does, then it'll be free. It's an additional basic block though so compile time may be worse, so I'd like a perf run.

r? `@ghost`
`@rustbot` label: F-c_unwind
2022-02-19 23:25:06 +00:00
bors
3b348d932a Auto merge of #94165 - Mark-Simulacrum:bump-version, r=Mark-Simulacrum
Bump version to 1.61

r? `@Mark-Simulacrum`
2022-02-19 19:49:23 +00:00
Michael Goulet
b59c958ba6 Bless up 2022-02-19 11:32:05 -08:00
Michael Goulet
773fa7adbc Consolidate normalization in confirm_poly_trait_refs 2022-02-19 10:59:00 -08:00
Mark Rousskov
55c25ece89 Bump version to 1.61 2022-02-19 13:40:33 -05:00
Gary Guo
7d683f525a Fix codegen test for MSVC 2022-02-19 17:29:56 +00:00
est31
bb0a2f985c rustc_typeck: adopt let else in more places 2022-02-19 18:15:47 +01:00
est31
2ef8af6619 Adopt let else in more places 2022-02-19 17:27:43 +01:00
r00ster91
297364eb07 Some improvements to the async docs 2022-02-19 17:17:40 +01:00
Tomasz Miąsko
c2da477853 Fix pretty printing of enums without variants
92d20c4aad removed no-variants special
case from try_destructure_const with expectation that this case would be
handled gracefully when read_discriminant returns an error.

Alas in that case read_discriminant succeeds while returning a
non-existing variant, so the special case is still necessary.
2022-02-19 17:10:11 +01:00
Erik Desjardins
c2e84fa5fc reduce default uninit_const_chunk_threshold to 16 (from 256) 2022-02-19 10:36:29 -05:00
Camille GILLOT
7afcf9fcd1 Add generator_kind table. 2022-02-19 15:41:41 +01:00
Camille GILLOT
381d32e7d6 Add fn_arg_names table. 2022-02-19 15:41:41 +01:00
Camille GILLOT
6cc96a45ac Add asyncness table. 2022-02-19 15:41:41 +01:00
Camille GILLOT
7bacdb760f Add rendered_const table. 2022-02-19 15:41:41 +01:00
Camille GILLOT
f8fd9733b6 Add mir_const_qualifs table. 2022-02-19 15:41:41 +01:00
Camille GILLOT
0b7ee3aca2 Drop ImplData. 2022-02-19 15:41:41 +01:00
Camille GILLOT
c7c306f94a Do not decode span when we only need the name. 2022-02-19 15:41:41 +01:00
Camille GILLOT
f07f1bfc60 Encode metadata using queries. 2022-02-19 15:41:36 +01:00
Camille GILLOT
227d912489 Stop interning stability. 2022-02-19 15:39:42 +01:00
Guillaume Gomez
296adbac0a Add rustdoc test for const computed value 2022-02-19 14:00:36 +01:00
Guillaume Gomez
c5ce3e1dbc Don't render Const computed values in hexadecimal for Display 2022-02-19 14:00:36 +01:00
bors
e08d569360 Auto merge of #94148 - matthiaskrgr:rollup-jgea68f, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92902 (Improve the documentation of drain members)
 - #93658 (Stabilize `#[cfg(panic = "...")]`)
 - #93954 (rustdoc-json: buffer output)
 - #93979 (Add debug assertions to validate NUL terminator in c strings)
 - #93990 (pre #89862 cleanup)
 - #94006 (Use a `Field` in `ConstraintCategory::ClosureUpvar`)
 - #94086 (Fix ScalarInt to char conversion)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-19 12:15:10 +00:00
Erik Desjardins
d5769e9843 switch to limiting the number of init/uninit chunks 2022-02-19 01:29:17 -05:00
Matthias Krüger
5a083dbbe6
Rollup merge of #94086 - tmiasko:char-try-from-scalar-int, r=davidtwco
Fix ScalarInt to char conversion

to avoid panic for invalid Unicode scalar values
2022-02-19 06:45:33 +01:00
Matthias Krüger
c28940e49d
Rollup merge of #94006 - pierwill:upvar-field, r=nikomatsakis
Use a `Field` in `ConstraintCategory::ClosureUpvar`

As part of #90317, we do not want `HirId` to implement `Ord`, `PartialOrd`. This line of code has made that difficult

1b27144afc/compiler/rustc_borrowck/src/region_infer/mod.rs (L2184)

since it sorts a [`ConstraintCategory::ClosureUpvar(HirId)`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.ConstraintCategory.html#variant.ClosureUpvar).

This PR makes that variant take a [`Field`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Field.html) instead.

r? `@nikomatsakis`
2022-02-19 06:45:32 +01:00
Matthias Krüger
78e4456e1f
Rollup merge of #93990 - lcnr:pre-89862-cleanup, r=estebank
pre #89862 cleanup

changes used in #89862 which can be landed without the rest of this PR being finished.

r? `@estebank`
2022-02-19 06:45:31 +01:00
Matthias Krüger
26dd6ac830
Rollup merge of #93979 - SUPERCILEX:debug_check, r=dtolnay
Add debug assertions to validate NUL terminator in c strings

The `unchecked` variants from the stdlib usually perform the check anyway if debug assertions are on (for example, `unwrap_unchecked`). This PR does the same thing for `CStr` and `CString`, validating the correctness for the NUL byte in debug mode.
2022-02-19 06:45:30 +01:00
Matthias Krüger
554aea90b8
Rollup merge of #93954 - aDotInTheVoid:json-buffer, r=Mark-Simulacrum
rustdoc-json: buffer output

It turns out we were doing syscalls for each part of the json syntax

Before:
```
...
[pid 1801267] write(5, "\"", 1)         = 1
[pid 1801267] write(5, ",", 1)          = 1
[pid 1801267] write(5, "\"", 1)         = 1
...
```

After:

```
[pid 1974821] write(5, "{\"root\":\"0:0\",\"crate_version\":nu"..., 1575) = 1575
```

In one benchmark (one struct, almost all time in `std`), this gives ~2x perf

r? `@CraftSpider`

`@rustbot` modify labels: +A-rustdoc-json +T-rustdoc -A-testsuite
2022-02-19 06:45:30 +01:00
Matthias Krüger
f19adc7acc
Rollup merge of #93658 - cchiw:issue-77443-fix, r=joshtriplett
Stabilize `#[cfg(panic = "...")]`

[Stabilization PR](https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr) for #77443
2022-02-19 06:45:29 +01:00
Matthias Krüger
4fa71ed0f0
Rollup merge of #92902 - ssomers:docter_drain, r=yaahc
Improve the documentation of drain members

hopefully fixes #92765
2022-02-19 06:45:28 +01:00
bors
cb4ee81ef5 Auto merge of #94105 - 5225225:destabilise-entry-insert, r=Mark-Simulacrum
Destabilise entry_insert

See: https://github.com/rust-lang/rust/pull/90345

I didn't revert the rename that was done in that PR, I left it as `entry_insert`.

Additionally, before that PR, `VacantEntry::insert_entry` seemingly had no stability attribute on it? I kept the attribute, just made it an unstable one, same as the one on `Entry`.

There didn't seem to be any mention of this in the RELEASES.md, so I don't think there's anything for me to do other than this?
2022-02-19 05:08:13 +00:00
bors
1882597991 Auto merge of #94134 - matthiaskrgr:rollup-b132kjz, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #89892 (Suggest `impl Trait` return type when incorrectly using a generic return type)
 - #91675 (Add MemTagSanitizer Support)
 - #92806 (Add more information to `impl Trait` error)
 - #93497 (Pass `--test` flag through rustdoc to rustc so `#[test]` functions can be scraped)
 - #93814 (mips64-openwrt-linux-musl: correct soft-foat)
 - #93847 (kmc-solid: Use the filesystem thread-safety wrapper)
 - #93877 (asm: Allow the use of r8-r14 as clobbers on Thumb1)
 - #93892 (Only mark projection as ambiguous if GAT substs are constrained)
 - #93915 (Implement --check-cfg option (RFC 3013), take 2)
 - #93953 (Add the `known-bug` test directive, use it, and do some cleanup)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-19 02:07:43 +00:00
est31
5cc292eb1d rustc_const_eval: adopt let else in more places 2022-02-19 01:55:47 +01:00
Stein Somers
a677e60840 Collections: improve the documentation of drain members 2022-02-19 00:55:31 +01:00
Nixon Enraght-Moony
fd5adefce1 rustdoc-json: Add tests for fn qualifiers and ABI 2022-02-18 23:48:41 +00:00
Nixon Enraght-Moony
aa601574a5 rustdoc-json: Better Header Type
- Make ABI an enum, instead of being stringly typed
- Replace Qualifier HashSet with 3 bools
- Merge ABI field into header, as they always occor together
2022-02-18 23:31:33 +00:00
bors
5a1a3707ff Auto merge of #94050 - michaelwoerister:fix-unsized-tuple-debuginfo, r=pnkfelix
debuginfo: Support fat pointers to unsized tuples.

This PR makes fat pointer debuginfo generation handle the case of unsized tuples.

Fixes #93871
2022-02-18 23:18:12 +00:00
Matthias Krüger
620b0c5122
Rollup merge of #93953 - jackh726:known_bug, r=Mark-Simulacrum
Add the `known-bug` test directive, use it, and do some cleanup

cc rust-lang/compiler-team#476

Now tests can be annotated with `known-bug`, which should indicate that the test *should* pass (or at least that the current output is a bug). Adding it relaxes the requirement to add error annotations to the test (though it is still allowed). In the future, this could be extended with further relaxations - with the goal to make adding these tests need minimal effort.

I've used this attribute for the GAT tests added in #93757.

Finally, I've also cleaned up `header.rs` in compiletest a bit, by extracting out a bit of common logic. I've also split out some of the directives into their own consts. This removes a lot of very similar functions from `Config` and makes `TestProps::load_from` read nicer.

I've split these into separate commits, so I in theory could split these into separate PRs if they're controversial, but I think they're pretty straightforward.

r? ``@Mark-Simulacrum``
2022-02-18 23:23:11 +01:00