]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAdd tests
Albin Hedman [Sat, 13 Mar 2021 17:40:47 +0000 (18:40 +0100)]
Add tests

2 years agoimpl const From<num> for num
Albin Hedman [Sun, 27 Dec 2020 18:46:01 +0000 (19:46 +0100)]
impl const From<num> for num

2 years agoAuto merge of #87810 - devnexen:haiku_os_simpl, r=Mark-Simulacrum
bors [Sat, 7 Aug 2021 12:44:09 +0000 (12:44 +0000)]
Auto merge of #87810 - devnexen:haiku_os_simpl, r=Mark-Simulacrum

current_exe haiku code path simplification all of these part of libc

2 years agoAuto merge of #87796 - nielx:fix/socket2-0.4.1, r=Mark-Simulacrum
bors [Sat, 7 Aug 2021 05:33:21 +0000 (05:33 +0000)]
Auto merge of #87796 - nielx:fix/socket2-0.4.1, r=Mark-Simulacrum

Update socket2 dependency from 0.4.0 to 0.4.1

This update contains a fix for building the tools that depend on this package on Haiku (tier 3).

2 years agoAuto merge of #87408 - kornelski:try_reserve_error, r=yaahc
bors [Sat, 7 Aug 2021 01:26:15 +0000 (01:26 +0000)]
Auto merge of #87408 - kornelski:try_reserve_error, r=yaahc

Hide allocator details from TryReserveError

I think there's [no need for TryReserveError to carry detailed information](https://github.com/rust-lang/rust/issues/48043#issuecomment-825139280), but I wouldn't want that issue to delay stabilization of the `try_reserve` feature.

So I'm proposing to stabilize `try_reserve` with a `TryReserveError` as an opaque structure, and if needed, expose error details later.

This PR moves the `enum` to an unstable inner `TryReserveErrorKind` that lives under a separate feature flag. `TryReserveErrorKind` could possibly be left as an implementation detail forever, and the `TryReserveError` get methods such as `allocation_size() -> Option<usize>` or `layout() -> Option<Layout>` instead, or the details could be dropped completely to make try-reserve errors just a unit struct, and thus smaller and cheaper.

2 years agoAuto merge of #87774 - camelid:process-typo, r=jyn514
bors [Fri, 6 Aug 2021 22:42:25 +0000 (22:42 +0000)]
Auto merge of #87774 - camelid:process-typo, r=jyn514

Fix typo

Add missing "by".

2 years agoAuto merge of #87822 - JohnTitor:rollup-kxojii0, r=JohnTitor
bors [Fri, 6 Aug 2021 18:23:14 +0000 (18:23 +0000)]
Auto merge of #87822 - JohnTitor:rollup-kxojii0, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #85807 (bootstrap: Disable initial-exec TLS model on powerpc)
 - #87761 (Fix overflow in rustc happening if the `err_count()` is reduced in a stage.)
 - #87775 (Add hint for unresolved associated trait items if the trait has a single item)
 - #87779 (Remove special case for statement `NodeId` assignment)
 - #87787 (Use `C-unwind` ABI for `__rust_start_panic` in `panic_abort`)
 - #87809 (Fix typo in the ptr documentation)
 - #87816 (Sync rustc_codegen_cranelift)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoRollup merge of #87816 - bjorn3:sync_cg_clif-2021-08-06, r=bjorn3
Yuki Okushi [Fri, 6 Aug 2021 16:46:37 +0000 (01:46 +0900)]
Rollup merge of #87816 - bjorn3:sync_cg_clif-2021-08-06, r=bjorn3

Sync rustc_codegen_cranelift

05677b6bd6c938ed760835d9b1f6514992654ae3 removes two assertions that should have been removed in https://github.com/rust-lang/rust/pull/87515. They are no longer correct and trigger while compiling the sysroot.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler

2 years agoRollup merge of #87809 - InnovativeInventor:pointer-typo, r=dtolnay
Yuki Okushi [Fri, 6 Aug 2021 16:46:36 +0000 (01:46 +0900)]
Rollup merge of #87809 - InnovativeInventor:pointer-typo, r=dtolnay

Fix typo in the ptr documentation

Spotted a minor typo in the docs ;). Pointers are cool!

2 years agoRollup merge of #87787 - hyd-dev:c-unwind, r=RalfJung
Yuki Okushi [Fri, 6 Aug 2021 16:46:35 +0000 (01:46 +0900)]
Rollup merge of #87787 - hyd-dev:c-unwind, r=RalfJung

Use `C-unwind` ABI for `__rust_start_panic` in `panic_abort`

The function originally has `C` ABI but is called using `C-unwind` ABI in `std`:
https://github.com/rust-lang/rust/blob/d4ad1cfc63ba5824196bfb2370451ddb5af2e020/library/std/src/panicking.rs#L49-L54
Which might be [problematic](https://github.com/rust-lang/miri/pull/1745#discussion_r596096876) and triggers this [Miri error](https://github.com/rust-lang/rust/issues/87778#issuecomment-893306222):
```
error: Undefined Behavior: calling a function with ABI C using caller ABI C-unwind
   --> /home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:672:9
    |
672 |         __rust_start_panic(obj)
    |         ^^^^^^^^^^^^^^^^^^^^^^^ calling a function with ABI C using caller ABI C-unwind
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
```
Changing the ABI of the function to `C-unwind` fixes the error above.

2 years agoRollup merge of #87779 - Aaron1011:stmt-ast-id, r=petrochenkov
Yuki Okushi [Fri, 6 Aug 2021 16:46:34 +0000 (01:46 +0900)]
Rollup merge of #87779 - Aaron1011:stmt-ast-id, r=petrochenkov

Remove special case for statement `NodeId` assignment

We now let `noop_flat_map_stmt` assign `NodeId`s (via `visit_id`),
just as we do for other AST nodes.

2 years agoRollup merge of #87775 - Kobzol:single-associated-item-hint, r=oli-obk
Yuki Okushi [Fri, 6 Aug 2021 16:46:33 +0000 (01:46 +0900)]
Rollup merge of #87775 - Kobzol:single-associated-item-hint, r=oli-obk

Add hint for unresolved associated trait items if the trait has a single item

This PR introduces a special-cased hint for unresolved trait items paths. It is shown if:
- the path was not resolved to any existing trait item
- and no existing trait item's name was reasonably close with regard to edit distance
- and the trait only has a single item in the corresponding namespace

I didn't know where I should put tests, therefore so far I just managed to bless two existing tests. I would be glad for hints where should tests for a hint like this be created, how should they be named (with reference to the original issue?) and what tests should I create (is it enough to test it just for types? or create separate tests also for functions and constants?).

It could also be turned into a machine applicable suggestion I suppose.

This is my first `rustc` PR, so please go easy on me :)

Fixes: https://github.com/rust-lang/rust/issues/87638
2 years agoRollup merge of #87761 - rusticstuff:rustc_error_overflow, r=Mark-Simulacrum
Yuki Okushi [Fri, 6 Aug 2021 16:46:32 +0000 (01:46 +0900)]
Rollup merge of #87761 - rusticstuff:rustc_error_overflow, r=Mark-Simulacrum

Fix overflow in rustc happening if the `err_count()` is reduced in a stage.

This can happen if stashed diagnostics are removed or replaced with fewer errors. The semantics stay the same if built without overflow checks. Fixes #84219.

Background: I came across this independently by running `RUSTFLAGS="-C overflow-checks=on" ./x.py test`. Fixing this will allow us to move on and find further overflow errors with testing or fuzzing.

2 years agoRollup merge of #85807 - glaubitz:powerpc-disable-initial-exec-tls, r=Mark-Simulacrum
Yuki Okushi [Fri, 6 Aug 2021 16:46:31 +0000 (01:46 +0900)]
Rollup merge of #85807 - glaubitz:powerpc-disable-initial-exec-tls, r=Mark-Simulacrum

bootstrap: Disable initial-exec TLS model on powerpc

Fixes #81334.

2 years agoAuto merge of #87784 - rusticstuff:bootstrap_config_overflow_checks, r=Mark-Simulacrum
bors [Fri, 6 Aug 2021 15:35:01 +0000 (15:35 +0000)]
Auto merge of #87784 - rusticstuff:bootstrap_config_overflow_checks, r=Mark-Simulacrum

Add config.toml options for enabling overflow checks in rustc and std

The names are `overflow-checks` and `overflow-checks-std` and they work similar to  `debug-assertions` and `debug-assertions-std`. Once added we can measure how big the performance impact actually is and maybe enable them for CI tests.

Enabling them already makes two ui tests fail:
```
failures:
    [ui] ui/parser/item-free-const-no-body-semantic-fail.rs
    [ui] ui/parser/item-free-static-no-body-semantic-fail.rs
```
(See #84219 and #87761.)

2 years agoRemove special case for statement `NodeId` assignment
Aaron Hill [Thu, 5 Aug 2021 00:41:13 +0000 (19:41 -0500)]
Remove special case for statement `NodeId` assignment

We now let `noop_flat_map_stmt` assign `NodeId`s (via `visit_id`),
just as we do for other AST nodes.

2 years agoMerge commit '05677b6bd6c938ed760835d9b1f6514992654ae3' into sync_cg_clif-2021-08-06
bjorn3 [Fri, 6 Aug 2021 14:26:56 +0000 (16:26 +0200)]
Merge commit '05677b6bd6c938ed760835d9b1f6514992654ae3' into sync_cg_clif-2021-08-06

2 years agoAuto merge of #87777 - the8472:fix-mir-max-rss, r=oli-obk,joshtriplett
bors [Fri, 6 Aug 2021 12:11:30 +0000 (12:11 +0000)]
Auto merge of #87777 - the8472:fix-mir-max-rss, r=oli-obk,joshtriplett

Use zeroed allocations in the mir interpreter instead eagerly touching the memory

#86255 introduced a 30% regression in [page faults](https://perf.rust-lang.org/compare.html?start=64ae15ddd3f3cca7036ab2b2f3a6b130b62af4da&end=39e20f1ae5f13451eb35247808d6a2527cb7d060&stat=faults
) and a 3% regression in [max-rss](https://perf.rust-lang.org/index.html?start=2021-07-01&end=&absolute=false&stat=max-rss) in the ctfe-stress benchmarks.
That's most likely happened because it separated allocation from initialization of the vec which defeats the zero-optimization.

Currently there's no allocation API that is fallible, zeroing and returns a slice, so this PR introduces one and then uses that to solve the problem. In principle `vec.resize(len, 0)` could be optimized to use `alloc::grow_zeroed` where appropriate but that would require new specializations and new plumbing in `RawVec`.

2 years agoAdd options for enabling overflow checks in rustc and std.
Hans Kratz [Thu, 5 Aug 2021 05:28:40 +0000 (05:28 +0000)]
Add options for enabling overflow checks in rustc and std.

The options are `overflow-checks` and `overflow-checks-std`
defaulting to false.

2 years agoAdd hint for unresolved associated trait items if the trait has a single item
Jakub Beránek [Wed, 4 Aug 2021 21:29:30 +0000 (23:29 +0200)]
Add hint for unresolved associated trait items if the trait has a single item

2 years agocurrent_exe haiku code path simplification all of these part of libc
David Carlier [Fri, 6 Aug 2021 06:32:36 +0000 (07:32 +0100)]
current_exe haiku code path simplification all of these part of libc

2 years agoAuto merge of #87808 - JohnTitor:rollup-qqp79xs, r=JohnTitor
bors [Fri, 6 Aug 2021 05:02:35 +0000 (05:02 +0000)]
Auto merge of #87808 - JohnTitor:rollup-qqp79xs, r=JohnTitor

Rollup of 9 pull requests

Successful merges:

 - #87561 (thread set_name haiku implementation.)
 - #87715 (Add long error explanation for E0625)
 - #87727 (explicit_generic_args_with_impl_trait: fix min expected number of generics)
 - #87742 (Validate FFI-safety warnings on naked functions)
 - #87756 (Add back -Zno-profiler-runtime)
 - #87759 (Re-use std::sealed::Sealed in os/linux/process.)
 - #87760 (Promote `aarch64-apple-ios-sim` to Tier 2)
 - #87770 (permit drop impls with generic constants in where clauses)
 - #87780 (alloc: Use intra doc links for the reserve function)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

2 years agoFix typo in the ptr documentation
Max Fan [Fri, 6 Aug 2021 02:50:56 +0000 (22:50 -0400)]
Fix typo in the ptr documentation

2 years agoRollup merge of #87780 - est31:intra_doc_links, r=jyn514
Yuki Okushi [Fri, 6 Aug 2021 02:21:36 +0000 (11:21 +0900)]
Rollup merge of #87780 - est31:intra_doc_links, r=jyn514

alloc: Use intra doc links for the reserve function

The sentence exists to highlight the existence of a
performance footgun of repeated calls of the
reserve_exact function.

2 years agoRollup merge of #87770 - BoxyUwU:cec-drop-impl, r=lcnr
Yuki Okushi [Fri, 6 Aug 2021 02:21:35 +0000 (11:21 +0900)]
Rollup merge of #87770 - BoxyUwU:cec-drop-impl, r=lcnr

permit drop impls with generic constants in where clauses

Fixes #79248

`==` is not sufficient to check for equality between unevaluated consts which causes the above issue because the const in `[(); N - 1]:` on the impl and the const in `[(); N - 1]:` on the struct def are not seen as equal. Any predicate that can contain an unevaluated const cant use `==` here as it will cause us to incorrectly emit an error.

I dont know much about chalk but it seems like we ought to be relating the `TypeWellFormedFromEnv` instead of `==` as it contains a `Ty` so I added that too...

r? ``````@lcnr``````

2 years agoRollup merge of #87760 - badboy:promote-ios-sim-target, r=Mark-Simulacrum
Yuki Okushi [Fri, 6 Aug 2021 02:21:34 +0000 (11:21 +0900)]
Rollup merge of #87760 - badboy:promote-ios-sim-target, r=Mark-Simulacrum

Promote `aarch64-apple-ios-sim` to Tier 2

As per https://github.com/rust-lang/compiler-team/issues/428 this target becomes Tier 2.

---

I tested that the latest nightly has the target and I'm already building my project with that on CI and locally.

2 years agoRollup merge of #87759 - m-ou-se:linux-process-sealed, r=jyn514
Yuki Okushi [Fri, 6 Aug 2021 02:21:33 +0000 (11:21 +0900)]
Rollup merge of #87759 - m-ou-se:linux-process-sealed, r=jyn514

Re-use std::sealed::Sealed in os/linux/process.

This uses `std::sealed::Sealed` in `std::os::linux::process` instead of defining new `Sealed` traits there.

2 years agoRollup merge of #87756 - Amanieu:no_profiler_runtime, r=jackh726
Yuki Okushi [Fri, 6 Aug 2021 02:21:32 +0000 (11:21 +0900)]
Rollup merge of #87756 - Amanieu:no_profiler_runtime, r=jackh726

Add back -Zno-profiler-runtime

This was removed by #85284 in favor of `-Zprofiler-runtime=<name>`.However the suggested `-Zprofiler-runtime=None` doesn't work because`None` is treated as a crate name.

2 years agoRollup merge of #87742 - npmccallum:naked_ffi, r=Amanieu
Yuki Okushi [Fri, 6 Aug 2021 02:21:31 +0000 (11:21 +0900)]
Rollup merge of #87742 - npmccallum:naked_ffi, r=Amanieu

Validate FFI-safety warnings on naked functions

Test that FFI-safety warnings don't get accidentally dropped on naked
functions. The big picture is that if you implement a naked function
with the Rust ABI you'll get a warning. Further, if you implement a
naked function with a standardized ABI, but use non-FFI-safe types you
will still get a warning.

rust-lang/rfcs#2774
rust-lang/rfcs#2972

cc ``````@joshtriplett`````` ``````@Amanieu`````` ``````@haraldh``````

2 years agoRollup merge of #87727 - SkiFire13:fix-87718, r=jackh726
Yuki Okushi [Fri, 6 Aug 2021 02:21:30 +0000 (11:21 +0900)]
Rollup merge of #87727 - SkiFire13:fix-87718, r=jackh726

explicit_generic_args_with_impl_trait: fix min expected number of generics

Fixes #87718

The problem was that `synth_type_param_count` was already subtracted from `named_type_param_count`, so this ended up being subtracted again. This caused `expected_min` to overflow, and ultimately resulting in weird and wrong behaviour.

I've also added another test not present in the original issue but caused by the same bug.

2 years agoRollup merge of #87715 - bhgomes:long-explanation-E0625, r=GuillaumeGomez
Yuki Okushi [Fri, 6 Aug 2021 02:21:29 +0000 (11:21 +0900)]
Rollup merge of #87715 - bhgomes:long-explanation-E0625, r=GuillaumeGomez

Add long error explanation for E0625

For #61137.

2 years agoRollup merge of #87561 - devnexen:haiku_thread_build_fix, r=yaahc
Yuki Okushi [Fri, 6 Aug 2021 02:21:28 +0000 (11:21 +0900)]
Rollup merge of #87561 - devnexen:haiku_thread_build_fix, r=yaahc

thread set_name haiku implementation.

2 years agoAuto merge of #87462 - ibraheemdev:tidy-file-length-ignore-comment, r=Mark-Simulacrum
bors [Fri, 6 Aug 2021 02:07:01 +0000 (02:07 +0000)]
Auto merge of #87462 - ibraheemdev:tidy-file-length-ignore-comment, r=Mark-Simulacrum

Ignore comments in tidy-filelength

Ref https://github.com/rust-lang/rust/issues/60302#issuecomment-652402127

2 years agoAuto merge of #84176 - GuillaumeGomez:src-to-definition, r=jyn514
bors [Thu, 5 Aug 2021 22:13:32 +0000 (22:13 +0000)]
Auto merge of #84176 - GuillaumeGomez:src-to-definition, r=jyn514

Generate links to definition in rustdoc source code pages

## Description

This PR adds an option (disabled by default) to add links in the source code page on ident. So for for example:

```rust
mod other_module;
struct Foo;
fn bar() {}

fn x<T: other_module::Trait>(f: Foo, g: other_module::Whatever, t: &T) {
    let f: Foo = Foo;
    bar();
    f.some_method();
}
```

In the example (mostly in the `x` function), `other_module::Trait`, `Foo`, `other_module::Whatever`, `bar` and `some_method` are now links (and `other_module` at the top too).

In case there is a type coming from another crate, it'll link to its documentation page and not its definition (but you can then click on `[src]` so I guess it's fine).

Another important detail: I voluntarily didn't add links for primitive types. I think we can discuss about adding links on them or not in a later PR (adding the support for them would require only a few lines).

Here is a video summing up everything I wrote above:

https://user-images.githubusercontent.com/3050060/114622354-21307b00-9cae-11eb-834d-f6d8178a37bd.mp4

## Performance impact

So, on my computer, the performance remains more or less the same (which is quite surprising but that's a nice surprise). Here are the numbers:

Without the option:
 * core:  1m 21s
 * alloc: 26.78s
 * std: 27.30s
 * proc_macro: 4.50s

With source to definition links generation (I enabled by default the option):
 * core: 1m 25s
 * alloc: 25.76s
 * std: 27.07s
 * proc_macro: 4.66s

So no real change here (again, I'm very surprised by this fact).

For the size of the generated source files (only taking into account the `src` folder here since it's the only one impacted) by running `du -shc .` (when I am in the source folder).

Without the option: 11.939 MB
With the option: 12.611 MB

So not a big change here either. In all those docs, I ran `grep -nR '<a class=' . | wc -l` and got 43917. So there are quite a lot of links added. :)

cc `@rust-lang/rustdoc`
r? `@jyn514`

2 years agoFix URL conflict for std type
Guillaume Gomez [Thu, 5 Aug 2021 21:33:43 +0000 (23:33 +0200)]
Fix URL conflict for std type

2 years agoRemove LightSpan and use Span directly
Guillaume Gomez [Mon, 2 Aug 2021 15:44:04 +0000 (17:44 +0200)]
Remove LightSpan and use Span directly

2 years agoRemove warnings/errors from compiler when using typeck_body in rustdoc span map builder
Guillaume Gomez [Wed, 21 Jul 2021 12:53:13 +0000 (14:53 +0200)]
Remove warnings/errors from compiler when using typeck_body in rustdoc span map builder

2 years ago* Rename LightSpan::empty into LightSpan::dummy
Guillaume Gomez [Tue, 13 Jul 2021 13:28:43 +0000 (15:28 +0200)]
* Rename LightSpan::empty into LightSpan::dummy
* Add Classifier::new_light_span to wrap LightSpan::new_in_file constructor

2 years agoAdd missing root_path when generating links using href
Guillaume Gomez [Sat, 12 Jun 2021 20:08:43 +0000 (22:08 +0200)]
Add missing root_path when generating links using href

2 years agoAdd documentation and FIXME
Guillaume Gomez [Thu, 20 May 2021 08:42:18 +0000 (10:42 +0200)]
Add documentation and FIXME

2 years agoFix invalid generation of HTML in highlight
Guillaume Gomez [Wed, 12 May 2021 15:29:51 +0000 (17:29 +0200)]
Fix invalid generation of HTML in highlight

2 years agoformatting
Guillaume Gomez [Fri, 7 May 2021 11:00:53 +0000 (13:00 +0200)]
formatting

2 years agoUse rustdoc Span in LinkFromSrc directly
Guillaume Gomez [Wed, 5 May 2021 12:48:41 +0000 (14:48 +0200)]
Use rustdoc Span in LinkFromSrc directly

2 years agoMove extra arguments for highlight URL generation into a new ContextInfo struct for...
Guillaume Gomez [Wed, 5 May 2021 12:19:51 +0000 (14:19 +0200)]
Move extra arguments for highlight URL generation into a new ContextInfo struct for better readability

2 years agoWrap the span_map tuple index into a type called "LightSpan"
Guillaume Gomez [Tue, 4 May 2021 19:41:45 +0000 (21:41 +0200)]
Wrap the span_map tuple index into a type called "LightSpan"

2 years agoImprove code readability
Guillaume Gomez [Tue, 4 May 2021 11:52:53 +0000 (13:52 +0200)]
Improve code readability

2 years ago* Rename Span::from_rustc_span to Span::new
Guillaume Gomez [Thu, 22 Apr 2021 13:14:49 +0000 (15:14 +0200)]
* Rename Span::from_rustc_span to Span::new
* Rename Span::wrap to Span::wrap_raw
* Improve documentation for Span::wrap_raw

2 years ago* Rename 'move_span' into 'local_span_to_global_span'
Guillaume Gomez [Tue, 20 Apr 2021 15:42:06 +0000 (17:42 +0200)]
* Rename 'move_span' into 'local_span_to_global_span'
* Add documentation on new arguments/functions

2 years agoUnderline source code links on hover
Guillaume Gomez [Wed, 14 Apr 2021 11:26:49 +0000 (13:26 +0200)]
Underline source code links on hover

2 years agoUpdate rustdoc tests
Guillaume Gomez [Tue, 13 Apr 2021 22:52:35 +0000 (00:52 +0200)]
Update rustdoc tests

2 years agoGenerate links for modules as well
Guillaume Gomez [Tue, 13 Apr 2021 20:51:56 +0000 (22:51 +0200)]
Generate links for modules as well

2 years agoAdd test for source code pages URLs
Guillaume Gomez [Tue, 13 Apr 2021 20:03:29 +0000 (22:03 +0200)]
Add test for source code pages URLs

2 years agoGenerate links for methods as well
Guillaume Gomez [Tue, 13 Apr 2021 18:00:36 +0000 (20:00 +0200)]
Generate links for methods as well

2 years agoEnsure that --generate-link-to-definition is only used with HTML output and is unstable
Guillaume Gomez [Tue, 4 May 2021 09:51:11 +0000 (11:51 +0200)]
Ensure that --generate-link-to-definition is only used with HTML output and is unstable

2 years agoAdd an option for the source code link generation
Guillaume Gomez [Tue, 13 Apr 2021 13:52:41 +0000 (15:52 +0200)]
Add an option for the source code link generation

2 years agoAdd links on source types to go to definition
Guillaume Gomez [Mon, 5 Apr 2021 22:07:46 +0000 (00:07 +0200)]
Add links on source types to go to definition

2 years agoadd Box::try_new_uninit_slice for symmetry
The8472 [Thu, 5 Aug 2021 19:21:52 +0000 (21:21 +0200)]
add Box::try_new_uninit_slice for symmetry

2 years agoreplace Vec<u8> with Box<[u8]>
The8472 [Thu, 5 Aug 2021 17:52:08 +0000 (19:52 +0200)]
replace Vec<u8> with Box<[u8]>

2 years agoAuto merge of #87768 - rust-lang:core-features-cleanup, r=dtolnay
bors [Thu, 5 Aug 2021 17:45:43 +0000 (17:45 +0000)]
Auto merge of #87768 - rust-lang:core-features-cleanup, r=dtolnay

Core features cleanup

This sorts and categorizes the `#![features]` in `core` and removes unused ones.

This is part of #87766

The following feature attributes were unnecessary and are removed:

```diff
// Library features:
-#![feature(bool_to_option)]
-#![feature(char_indices_offset)]
-#![feature(pin_deref_mut)]
-#![feature(str_split_as_str)]
-#![feature(str_split_inclusive_as_str)]

// Language features:
-#![feature(arbitrary_self_types)]
-#![feature(custom_inner_attributes)]
-#![feature(nll)]
```

2 years agoremove cfg gate on `use RawVec` since it is now also used in fallible code
The8472 [Thu, 5 Aug 2021 17:45:02 +0000 (19:45 +0200)]
remove cfg gate on `use RawVec` since it is now also used in fallible code

2 years agoUpdate socket2 dependency from 0.4.0 to 0.4.1
Niels Sascha Reedijk [Thu, 5 Aug 2021 14:54:18 +0000 (15:54 +0100)]
Update socket2 dependency from 0.4.0 to 0.4.1

2 years agoAuto merge of #87737 - LeSeulArtichaut:unsafeck-less-freeze, r=oli-obk
bors [Thu, 5 Aug 2021 14:45:09 +0000 (14:45 +0000)]
Auto merge of #87737 - LeSeulArtichaut:unsafeck-less-freeze, r=oli-obk

Only compute `is_freeze` for layout-constrained ADTs

Places are usually shallow and quick to visit. By contrast, computing `is_freeze` can be much costlier, involving inference and trait solving. Making sure to call `is_freeze` only when necessary should be beneficial for performance in most cases.

See [this comparison](https://perf.rust-lang.org/compare.html?start=81f08a4763e7537b92506fa5a597e6bf774d20cc&end=56a58d347b1c7dd0c2984b8fc3930c408e26fbc2&stat=instructions%3Au) from #87710.

r? `@oli-obk`

2 years agoRustup to rustc 1.56.0-nightly (25b764849 2021-08-04)
bjorn3 [Thu, 5 Aug 2021 13:32:02 +0000 (15:32 +0200)]
Rustup to rustc 1.56.0-nightly (25b764849 2021-08-04)

2 years agoSync from rust 2ddb65c32253872c0e7a02e43ec520877900370e
bjorn3 [Thu, 5 Aug 2021 12:39:37 +0000 (14:39 +0200)]
Sync from rust 2ddb65c32253872c0e7a02e43ec520877900370e

2 years agoMake rustfmt happy.
Mara Bos [Wed, 4 Aug 2021 16:24:57 +0000 (18:24 +0200)]
Make rustfmt happy.

2 years agoRemove unnecessary #[unstable] from internal macro.
Mara Bos [Wed, 4 Aug 2021 16:16:03 +0000 (18:16 +0200)]
Remove unnecessary #[unstable] from internal macro.

After this change, all library #![feature]s enabled in core are for
const fns.

2 years agoRemove unused langauge #![feature]s from core.
Mara Bos [Wed, 4 Aug 2021 16:14:17 +0000 (18:14 +0200)]
Remove unused langauge #![feature]s from core.

2 years agoRemove unused library #![feature]s from core.
Mara Bos [Wed, 4 Aug 2021 16:13:52 +0000 (18:13 +0200)]
Remove unused library #![feature]s from core.

2 years agoSort and categorize lint and feature attributes in core.
Mara Bos [Wed, 4 Aug 2021 15:54:07 +0000 (17:54 +0200)]
Sort and categorize lint and feature attributes in core.

2 years agoAuto merge of #87740 - npmccallum:naked_args, r=Amanieu
bors [Thu, 5 Aug 2021 10:35:21 +0000 (10:35 +0000)]
Auto merge of #87740 - npmccallum:naked_args, r=Amanieu

Disable unused variable lint for naked functions

In most calling conventions, accessing function parameters may require
stack access. However, naked functions have no assembly prelude to set
up stack access.  This is why naked functions may only contain a single
`asm!()` block. All parameter access is done inside the `asm!()` block,
so we cannot validate the liveness of the input parameters. Therefore,
we should disable the lint for naked functions.

rust-lang/rfcs#2774
rust-lang/rfcs#2972

`@joshtriplett` `@Amanieu` `@haraldh`

2 years agoUse `C-unwind` ABI for `__rust_start_panic` in `panic_abort`
hyd-dev [Thu, 5 Aug 2021 09:42:27 +0000 (17:42 +0800)]
Use `C-unwind` ABI for `__rust_start_panic` in `panic_abort`

2 years agoAuto merge of #87532 - tlyu:bootstrap-rev-list, r=jyn514
bors [Thu, 5 Aug 2021 07:33:20 +0000 (07:33 +0000)]
Auto merge of #87532 - tlyu:bootstrap-rev-list, r=jyn514

bootstrap.py: use `git rev-list` for robustness

Use `git rev-list` instead of `git log` to be more robust against
UI changes in git. Also, use the full email address for bors,
because `--author` uses a substring match.

Based on #87513, but is separate because it's less minimal and may require additional manual testing.

~Open questions:~
* ~Should the `merge_base` search also use `--first-parent`?~
* ~Do we exclude non-merge commits from bors? There are a few, and I'm not sure what they have in common. Some of them look like squashes, and some look like they're in rollup branches.~

r? `@jyn514`
`@rustbot` label +A-rustbuild +C-cleanup

2 years agouse box->vec conversion API that doesn't reallocate
The8472 [Thu, 5 Aug 2021 07:32:41 +0000 (09:32 +0200)]
use box->vec conversion API that doesn't reallocate

2 years agoalloc: Use intra doc links for the reserve function
est31 [Thu, 5 Aug 2021 02:22:14 +0000 (04:22 +0200)]
alloc: Use intra doc links for the reserve function

The sentence exists to highlight the existence of a
performance footgun of repeated calls of the
reserve_exact function.

2 years agoremove tywf relation
Ellen [Thu, 5 Aug 2021 02:09:01 +0000 (03:09 +0100)]
remove tywf relation

2 years agoAuto merge of #87641 - HackAttack:expand-unknown-option-message, r=wesleywiser
bors [Thu, 5 Aug 2021 00:11:05 +0000 (00:11 +0000)]
Auto merge of #87641 - HackAttack:expand-unknown-option-message, r=wesleywiser

Allow more "unknown argument" strings from linker

Some toolchains emit slightly different errors, e.g.

    ppc-vle-gcc: error: unrecognized option '-no-pie'

2 years agouse zeroed allocation instead of eagerly initializing the memory
The8472 [Wed, 4 Aug 2021 22:24:31 +0000 (00:24 +0200)]
use zeroed allocation instead of eagerly initializing the memory

2 years agoadd Box::try_new_zeroed_slice()
The8472 [Wed, 4 Aug 2021 22:23:19 +0000 (00:23 +0200)]
add Box::try_new_zeroed_slice()

Currently there is no API that allows fallible zero-allocation of a Vec.
Vec.try_reserve is not appropriate for this job since it doesn't know
whether it should zero or arbitrary uninitialized memory is fine.

Since Box currently holds most of the zeroing/uninit/slice allocation APIs
it's the best place to add yet another entry into this feature matrix.

2 years agoAuto merge of #86155 - alexcrichton:abort-on-unwind, r=nikomatsakis
bors [Wed, 4 Aug 2021 21:09:53 +0000 (21:09 +0000)]
Auto merge of #86155 - alexcrichton:abort-on-unwind, r=nikomatsakis

rustc: Fill out remaining parts of C-unwind ABI

This commit intends to fill out some of the remaining pieces of the
C-unwind ABI. This has a number of other changes with it though to move
this design space forward a bit. Notably contained within here is:

* On `panic=unwind`, the `extern "C"` ABI is now considered as "may
  unwind". This fixes a longstanding soundness issue where if you
  `panic!()` in an `extern "C"` function defined in Rust that's actually
  UB because the LLVM representation for the function has the `nounwind`
  attribute, but then you unwind.

* Whether or not a function unwinds now mainly considers the ABI of the
  function instead of first checking the panic strategy. This fixes a
  miscompile of `extern "C-unwind"` with `panic=abort` because that ABI
  can still unwind.

* The aborting stub for non-unwinding ABIs with `panic=unwind` has been
  reimplemented. Previously this was done as a small tweak during MIR
  generation, but this has been moved to a separate and dedicated MIR
  pass. This new pass will, for appropriate functions and function
  calls, insert a `cleanup` landing pad for any function call that may
  unwind within a function that is itself not allowed to unwind. Note
  that this subtly changes some behavior from before where previously on
  an unwind which was caught-to-abort it would run active destructors in
  the function, and now it simply immediately aborts the process.

* The `#[unwind]` attribute has been removed and all users in tests and
  such are now using `C-unwind` and `#![feature(c_unwind)]`.

I think this is largely the last piece of the RFC to implement.
Unfortunately I believe this is still not stabilizable as-is because
activating the feature gate changes the behavior of the existing `extern
"C"` ABI in a way that has no replacement. My thinking for how to enable
this is that we add support for the `C-unwind` ABI on stable Rust first,
and then after it hits stable we change the behavior of the `C` ABI.
That way anyone straddling stable/beta/nightly can switch to `C-unwind`
safely.

2 years agoFix typo
Noah Lev [Wed, 4 Aug 2021 21:04:58 +0000 (14:04 -0700)]
Fix typo

2 years agomove full explanation to after erroneous example
Brandon H. Gomes [Wed, 4 Aug 2021 19:49:00 +0000 (15:49 -0400)]
move full explanation to after erroneous example

2 years agoDisable unused variable lint for naked functions
Nathaniel McCallum [Tue, 3 Aug 2021 20:45:55 +0000 (16:45 -0400)]
Disable unused variable lint for naked functions

In most calling conventions, accessing function parameters may require
stack access. However, naked functions have no assembly prelude to set
up stack access.  This is why naked functions may only contain a single
`asm!()` block. All parameter access is done inside the `asm!()` block,
so we cannot validate the liveness of the input parameters. Therefore,
we should disable the lint for naked functions.

rust-lang/rfcs#2774
rust-lang/rfcs#2972

2 years agoAdd test for naked function unused variables lint
Nathaniel McCallum [Tue, 3 Aug 2021 15:19:35 +0000 (11:19 -0400)]
Add test for naked function unused variables lint

This test proves that naked functions are treated the same as regular
functions regarding unused function parameters. We will change this
behavior in the next patch.

2 years agoAuto merge of #87695 - tmiasko:gep-opaque-pointers, r=nagisa
bors [Wed, 4 Aug 2021 18:22:29 +0000 (18:22 +0000)]
Auto merge of #87695 - tmiasko:gep-opaque-pointers, r=nagisa

Prepare GEP building for opaque pointers

2 years agodropck
Ellen [Wed, 4 Aug 2021 17:30:41 +0000 (18:30 +0100)]
dropck

2 years agoAuto merge of #87736 - the8472:inline-advance-by, r=Mark-Simulacrum
bors [Wed, 4 Aug 2021 15:39:20 +0000 (15:39 +0000)]
Auto merge of #87736 - the8472:inline-advance-by, r=Mark-Simulacrum

#[inline] slice::Iter::advance_by

https://github.com/rust-lang/rust/pull/87387#issuecomment-891942661 was marked as a regression. One of the methods in the PR was missing an inline annotation unlike all the other methods on slice iterators.

Let's see if that makes a difference.

2 years agoFix assertions in `coverage-reports` test
Alex Crichton [Wed, 4 Aug 2021 14:43:28 +0000 (07:43 -0700)]
Fix assertions in `coverage-reports` test

Update some `C-unwind` bits and then

2 years agoFix overflow in rustc happening if the `err_count()` is reduced in a stage.
Hans Kratz [Wed, 4 Aug 2021 14:25:45 +0000 (14:25 +0000)]
Fix overflow in rustc happening if the `err_count()` is reduced in a stage.

This can happen if stashed diagnostics are removed or replaced with fewer errors. The semantics stay the same if built without overflow. Fixes #84219.

2 years agoReplace LLVMConstInBoundsGEP with LLVMConstInBoundsGEP2*
Tomasz Miąsko [Sat, 31 Jul 2021 00:00:00 +0000 (00:00 +0000)]
Replace LLVMConstInBoundsGEP with LLVMConstInBoundsGEP2*

A custom reimplementation of LLVMConstInBoundsGEP2 is used, since the
LLVM contains a declaration of LLVMConstInBoundsGEP2 but not the
implementation.

2 years agoPrepare inbounds_gep for opaque pointers
Tomasz Miąsko [Sun, 1 Aug 2021 00:00:00 +0000 (00:00 +0000)]
Prepare inbounds_gep for opaque pointers

Implement inbounds_gep using LLVMBuildInBoundsGEP2 which takes an
explicit type argument instead of deriving it from a pointer type.

2 years agoPrepare gep for opaque pointers
Tomasz Miąsko [Sat, 31 Jul 2021 00:00:00 +0000 (00:00 +0000)]
Prepare gep for opaque pointers

Implement gep using LLVMBuildGEP2 which takes an explicit type argument
instead of deriving it from a pointer type.

2 years agoPrepare struct_gep for opaque pointers
Tomasz Miąsko [Sun, 1 Aug 2021 00:00:00 +0000 (00:00 +0000)]
Prepare struct_gep for opaque pointers

Imlement struct_gep using LLVMBuildStructGEP2 which takes an explicit
type argument instead of deriving it from a pointer type.

2 years agoPromote `aarch64-apple-ios-sim` to Tier 2
Jan-Erik Rediger [Mon, 2 Aug 2021 12:43:20 +0000 (14:43 +0200)]
Promote `aarch64-apple-ios-sim` to Tier 2

As per MCP#428[1] this target becomes Tier 2.

[1]: https://github.com/rust-lang/compiler-team/issues/428

2 years agoAuto merge of #87150 - rusticstuff:simplify_wrapping_neg, r=m-ou-se
bors [Wed, 4 Aug 2021 12:58:31 +0000 (12:58 +0000)]
Auto merge of #87150 - rusticstuff:simplify_wrapping_neg, r=m-ou-se

Make wrapping_neg() use wrapping_sub(), #[inline(always)]

This is a follow-up change to the fix for #75598. It simplifies the implementation of wrapping_neg() for all integer types by just calling 0.wrapping_sub(self) and always inlines it. This leads to much less assembly code being emitted for opt-level≤1 and thus much better performance for debug-compiled code.

Background is [this discussion on the internals forum](https://internals.rust-lang.org/t/why-does-rust-generate-10x-as-much-unoptimized-assembly-as-gcc/14930).

2 years agoRe-use std::sealed::Sealed in os/linux/process.
Mara Bos [Wed, 4 Aug 2021 12:15:05 +0000 (14:15 +0200)]
Re-use std::sealed::Sealed in os/linux/process.

2 years agoAuto merge of #86197 - FabianWolff:trailing-whitespace, r=JohnTitor
bors [Wed, 4 Aug 2021 09:58:16 +0000 (09:58 +0000)]
Auto merge of #86197 - FabianWolff:trailing-whitespace, r=JohnTitor

Remove unnecessary trailing whitespace from error messages

Some error messages currently contain unnecessary trailing whitespace. There are some legitimate reasons for having trailing whitespace in the output, such as for uniform indentation of possibly-empty input lines, but the whitespace I have addressed here occurs in a line used only for spacing, and I see no reason why that should have trailing whitespace (spacing lines inserted in other places also don't have trailing whitespace).

I have also removed a superfluous call to `buffer.putc()`, which has no effect because the same character is already placed there by `draw_col_separator()`.

Use `git diff --ignore-space-at-eol` to see my changes; otherwise the diff is quite large due to the whitespace removed from expected outputs in `src/test/ui/`.

2 years agoAdd back -Zno-profiler-runtime
Amanieu d'Antras [Wed, 4 Aug 2021 09:43:44 +0000 (10:43 +0100)]
Add back -Zno-profiler-runtime

This was removed by #85284 in favor of -Zprofiler-runtime=<name>.
However the suggested -Zprofiler-runtime=None doesn't work because
"None" is treated as a crate name.

2 years agoRemove trailing whitespace from error messages
Fabian Wolff [Thu, 10 Jun 2021 11:52:00 +0000 (13:52 +0200)]
Remove trailing whitespace from error messages

2 years agochange instructions for manually compiling y.rs (#1191)
Gheorghe Anghelescu [Wed, 4 Aug 2021 07:23:27 +0000 (10:23 +0300)]
change instructions for manually compiling y.rs (#1191)

This prevents an error on windows where the `build_sysroot` function was trying to delete `y.exe`.

2 years agoAuto merge of #87026 - FabianWolff:issue-86948, r=estebank
bors [Wed, 4 Aug 2021 07:17:25 +0000 (07:17 +0000)]
Auto merge of #87026 - FabianWolff:issue-86948, r=estebank

Allow labeled loops as value expressions for `break`

Fixes #86948. This is currently allowed:
```rust
return 'label: loop { break 'label 42; };
break ('label: loop { break 'label 42; });
break 1 + 'label: loop { break 'label 42; };
break 'outer 'inner: loop { break 'inner 42; };
```
But not this:
```rust
break 'label: loop { break 'label 42; };
```
I have fixed this, so that the above now parses as an unlabeled break with a labeled loop as its value expression.