]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agostd: Add capacity guarantees notes for OsString
Xuanwo [Mon, 28 Mar 2022 02:25:35 +0000 (10:25 +0800)]
std: Add capacity guarantees notes for OsString

Signed-off-by: Xuanwo <github@xuanwo.io>
2 years agoAuto merge of #96800 - nbdd0121:const, r=nagisa
bors [Wed, 18 May 2022 15:07:47 +0000 (15:07 +0000)]
Auto merge of #96800 - nbdd0121:const, r=nagisa

Permit `asm_const` and `asm_sym` to reference generic params

Related #96557

These constructs will be allowed:
```rust
fn foofoo<const N: usize>() {}

unsafe fn foo<const N: usize>() {
    asm!("/* {0} */", const N);
    asm!("/* {0} */", const N + 1);
    asm!("/* {0} */", sym foofoo::<N>);
}

fn barbar<T>() {}

unsafe fn bar<T>() {
    asm!("/* {0} */", const std::mem::size_of::<T>());
    asm!("/* {0} */", const std::mem::size_of::<(T, T)>());
    asm!("/* {0} */", sym barbar::<T>);
    asm!("/* {0} */", sym barbar::<(T, T)>);
}
```

`@Amanieu,` I didn't switch inline asms to use `DefKind::InlineAsm`, as I see little value doing that; given that no type inference is needed, it will only make typecking slower and more complex but will have no real gains. I did switch them to follow the same code path as inline asm during symbol resolution, though.
The `error: unconstrained generic constant` you mentioned in #76001 is due to the fact that `to_const` will actually add a wfness obligation to the constant, which we don't need for `asm_const`, so I have that removed.

`@rustbot` label: +A-inline-assembly +F-asm

2 years agoAuto merge of #96867 - michaelwoerister:path-prefix-fixes-2, r=davidtwco
bors [Wed, 18 May 2022 12:45:44 +0000 (12:45 +0000)]
Auto merge of #96867 - michaelwoerister:path-prefix-fixes-2, r=davidtwco

--remap-path-prefix: Fix duplicated path components in debuginfo

This PR fixes an issue with `--remap-path-prefix` where path components could appear twice in the remapped version of the path (e.g. https://github.com/rust-lang/rust/issues/78479). The underlying problem was that `--remap-path-prefix` is often used to map an absolute path to something that looks like a relative path, e.g.:

```
--remap-path-prefix=/home/calvin/.cargo/registry/src/github.com-1ecc6299db9ec823=crates.io",
```

and relative paths in debuginfo are interpreted as being relative to the compilation directory. So if Cargo invokes the compiler with `/home/calvin/.cargo/registry/src/github.com-1ecc6299db9ec823/some_crate-0.1.0/src/lib.rs` as input and `/home/calvin/.cargo/registry/src/github.com-1ecc6299db9ec823/some_crate-0.1.0` as the compiler's working directory, then debuginfo will state that the working directory was `crates.io/some_crate-0.1.0` and the file is question was `crates.io/some_crate-0.1.0/src/lib.rs`, which combined gives the path:

```
crates.io/some_crate-0.1.0/crates.io/some_crate-0.1.0/src/lib.rs
```

With this PR the compiler will detect this situation and set up debuginfo in LLVM in a way that makes it strip the duplicated path components when emitting DWARF.

The PR also extracts the logic for making remapped paths absolute into a common helper function that is now used by debuginfo too (instead of just during crate metadata generation).

2 years agoProperly apply path prefix remapping paths emitted into debuginfo.
Michael Woerister [Thu, 5 May 2022 15:26:22 +0000 (17:26 +0200)]
Properly apply path prefix remapping paths emitted into debuginfo.

2 years agoAuto merge of #97110 - Kobzol:pgo-pid-in-profile, r=lqd
bors [Wed, 18 May 2022 09:53:01 +0000 (09:53 +0000)]
Auto merge of #97110 - Kobzol:pgo-pid-in-profile, r=lqd

Add PID to PGO profile data filename

After experimenting with PGO, it looks like the generated profile data files can be sometimes overwritten if there is a race condition, because multiple `rustc` processes are usually invoked in parallel by `cargo`. Adding the PID to the resulting profile filename pattern makes sure that the profiles will be stored in separate files.

This generates ~20 GiB more space on disk on the CI run, but that seems harmless (?). Merging the profiles is not a bottleneck, the perf. run took the same amount of time as usually (~1h 24m).

r? `@lqd`

2 years agoAdd tests for FilePathMapping::to_embeddable_absolute_path().
Michael Woerister [Thu, 5 May 2022 15:05:08 +0000 (17:05 +0200)]
Add tests for FilePathMapping::to_embeddable_absolute_path().

2 years agoMove logic for making potentially remapped paths absolute into helper method.
Michael Woerister [Thu, 5 May 2022 15:03:51 +0000 (17:03 +0200)]
Move logic for making potentially remapped paths absolute into helper method.

2 years agoAdd debug tracing to FilePathMapping::map_prefix
Michael Woerister [Thu, 5 May 2022 15:01:39 +0000 (17:01 +0200)]
Add debug tracing to FilePathMapping::map_prefix

2 years agoAuto merge of #97135 - Dylan-DPC:rollup-06u9pqn, r=Dylan-DPC
bors [Wed, 18 May 2022 07:12:11 +0000 (07:12 +0000)]
Auto merge of #97135 - Dylan-DPC:rollup-06u9pqn, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #94639 (Suggest dereferencing non-lval mutable reference on assignment)
 - #95979 (update coherence docs, fix generator + opaque type ICE)
 - #96378 (Mention traits and types involved in unstable trait upcasting)
 - #96917 (Make HashMap fall back to RtlGenRandom if BCryptGenRandom fails)
 - #97101 (Add tracking issue for ExitCode::exit_process)
 - #97123 (Clean fix for #96223)

Failed merges:

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

2 years agoRollup merge of #97123 - ricked-twice:issue-96223-clean-fix, r=jackh726
Dylan DPC [Wed, 18 May 2022 06:41:18 +0000 (08:41 +0200)]
Rollup merge of #97123 - ricked-twice:issue-96223-clean-fix, r=jackh726

Clean fix for #96223

Okay, so here we are (hopefully) :+1:

Closes #96223

Thanks a lot to `@jackh726` for your help and explanation :pray:

- Modified `InferCtxt::mk_trait_obligation_with_new_self_ty` to take as argument a `Binder<(TraitPredicate, Ty)>` instead of a `Binder<TraitPredicate>` and a separate `Ty` with no bound vars.

- Modified all call places to avoid calling `Binder::no_bounds_var` or `Binder::skip_binder` when it is not safe.

r? `@jackh726`

2 years agoRollup merge of #97101 - coolreader18:exitcode-method-issue, r=yaahc
Dylan DPC [Wed, 18 May 2022 06:41:17 +0000 (08:41 +0200)]
Rollup merge of #97101 - coolreader18:exitcode-method-issue, r=yaahc

Add tracking issue for ExitCode::exit_process

r? `@yaahc`

2 years agoRollup merge of #96917 - marti4d:master, r=ChrisDenton
Dylan DPC [Wed, 18 May 2022 06:41:16 +0000 (08:41 +0200)]
Rollup merge of #96917 - marti4d:master, r=ChrisDenton

Make HashMap fall back to RtlGenRandom if BCryptGenRandom fails

With PR #84096, Rust `std::collections::hash_map::RandomState` changed from using `RtlGenRandom()` ([msdn](https://docs.microsoft.com/en-us/windows/win32/api/ntsecapi/nf-ntsecapi-rtlgenrandom)) to `BCryptGenRandom()` ([msdn](https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom)) as its source of secure randomness after much discussion ([here](https://github.com/rust-random/getrandom/issues/65#issuecomment-753634074), among other places).

Unfortunately, after that PR landed, Mozilla Firefox started experiencing fairly-rare crashes during startup while attempting to initialize the `env_logger` crate. ([docs for env_logger](https://docs.rs/env_logger/latest/env_logger/)) The root issue is that on some machines, `BCryptGenRandom()` will fail with an `Access is denied. (os error 5)` error message. ([Bugzilla issue 1754490](https://bugzilla.mozilla.org/show_bug.cgi?id=1754490)) (Discussion in issue #94098)

Note that this is happening upon startup of Firefox's unsandboxed Main Process, so this behavior is different and separate from previous issues ([like this](https://bugzilla.mozilla.org/show_bug.cgi?id=1746254)) where BCrypt DLLs were blocked by process sandboxing. In the case of sandboxing, we knew we were doing something abnormal and expected that we'd have to resort to abnormal measures to make it work.

However, in this case we are in a regular unsandboxed process just trying to initialize `env_logger` and getting a panic. We suspect that this may be caused by a virus scanner or some other security software blocking the loading of the BCrypt DLLs, but we're not completely sure as we haven't been able to replicate locally.

It is also possible that Firefox is not the only software affected by this; we just may be one of the pieces of Rust software that has the telemetry and crash reporting necessary to catch it.

I have read some of the historical discussion around using `BCryptGenRandom()` in Rust code, and I respect the decision that was made and agree that it was a good course of action, so I'm not trying to open a discussion about a return to `RtlGenRandom()`. Instead, I'd like to suggest that perhaps we use `RtlGenRandom()` as a "fallback RNG" in the case that BCrypt doesn't work.

This pull request implements this fallback behavior. I believe this would improve the robustness of this essential data structure within the standard library, and I see only 2 potential drawbacks:

1. Slight added overhead: It should be quite minimal though. The first call to `sys::rand::hashmap_random_keys()` will incur a bit of initialization overhead, and every call after will incur roughly 2 non-atomic global reads and 2 easily predictable branches. Both should be negligible compared to the actual cost of generating secure random numbers
2. `RtlGenRandom()` is deprecated by Microsoft: Technically true, but as mentioned in [this comment on GoLang](https://github.com/golang/go/issues/33542#issuecomment-626124873), this API is ubiquitous in Windows software and actually removing it would break lots of things. Also, Firefox uses it already in [our C++ code](https://searchfox.org/mozilla-central/rev/5f88c1d6977e03e22d3420d0cdf8ad0113c2eb31/mfbt/RandomNum.cpp#25), and [Chromium uses it in their code as well](https://source.chromium.org/chromium/chromium/src/+/main:base/rand_util_win.cc) (which transitively means that Microsoft uses it in their own web browser, Edge). If there did come a time when Microsoft truly removes this API, it should be easy enough for Rust to simply remove the fallback in the code I've added here

2 years agoRollup merge of #96378 - compiler-errors:trait-upcast-error, r=nagisa
Dylan DPC [Wed, 18 May 2022 06:41:15 +0000 (08:41 +0200)]
Rollup merge of #96378 - compiler-errors:trait-upcast-error, r=nagisa

Mention traits and types involved in unstable trait upcasting

Fixes #95972  by printing the traits being upcasted and the types being coerced that cause that upcasting...

---

the poor span mentioned in the original issue has nothing to do with trait upcasting diagnostic here...

>  The original example I had that made me run into this issue had an even longer expression there (multiple chained
iterator methods) which just got all highlighted as one big block saying "somewhere here trait coercion is used and it's not allowed".

I don't think I can solve that issue in general without fixing the ObligationCauseCode and span that gets passed into Coerce.

2 years agoRollup merge of #95979 - lcnr:coherence-docs, r=compiler-errors
Dylan DPC [Wed, 18 May 2022 06:41:14 +0000 (08:41 +0200)]
Rollup merge of #95979 - lcnr:coherence-docs, r=compiler-errors

update coherence docs, fix generator + opaque type ICE

the world is confusing, this makes it slightly less so

2 years agoRollup merge of #94639 - compiler-errors:rval-mutref, r=wesleywiser
Dylan DPC [Wed, 18 May 2022 06:41:13 +0000 (08:41 +0200)]
Rollup merge of #94639 - compiler-errors:rval-mutref, r=wesleywiser

Suggest dereferencing non-lval mutable reference on assignment

1. Adds deref suggestions for LHS of assignment (or assign-binop) when it implements `DerefMut`
2. Fixes missing deref suggestions for LHS when it isn't a place expr

Fixes #46276
Fixes #93980

2 years agoMention traits being upcasted, types being coerced
Michael Goulet [Mon, 25 Apr 2022 04:07:46 +0000 (21:07 -0700)]
Mention traits being upcasted, types being coerced

2 years agobetter lvalue errors for things implementing DerefMut
Michael Goulet [Sat, 5 Mar 2022 09:57:43 +0000 (01:57 -0800)]
better lvalue errors for things implementing DerefMut

2 years agoAuto merge of #97126 - JohnTitor:rollup-7gdt2aw, r=JohnTitor
bors [Wed, 18 May 2022 03:42:04 +0000 (03:42 +0000)]
Auto merge of #97126 - JohnTitor:rollup-7gdt2aw, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #96647 (rustdoc-json: Fix HRTBs for WherePredicate::BoundPredicate)
 - #96651 (Omit unnecessary help to add `#[cfg(test)]` when already annotated)
 - #96761 (rustdoc: don't build `rayon` for non-windows targets)
 - #97096 (Types with reachable constructors are reachable)
 - #97097 (Add tmm_reg clobbers)
 - #97113 (Search GUI fixes)
 - #97116 (interpret/validity: reject references to uninhabited types)

Failed merges:

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

2 years agobetter error for bad LHS in binop-assign
Michael Goulet [Sat, 5 Mar 2022 07:17:31 +0000 (23:17 -0800)]
better error for bad LHS in binop-assign

2 years agoSuggest deref non-lvalue mutable reference
Michael Goulet [Sat, 5 Mar 2022 05:59:13 +0000 (21:59 -0800)]
Suggest deref non-lvalue mutable reference

2 years agoRollup merge of #97116 - RalfJung:ref-validity, r=oli-obk
Yuki Okushi [Tue, 17 May 2022 22:41:01 +0000 (07:41 +0900)]
Rollup merge of #97116 - RalfJung:ref-validity, r=oli-obk

interpret/validity: reject references to uninhabited types

According to https://doc.rust-lang.org/reference/behavior-considered-undefined.html, this is definitely UB. And we can check this without actually looking up anything in memory, we just need the reference value and its type, making this a great candidate for a validity invariant IMO and my favorite resolution of https://github.com/rust-lang/unsafe-code-guidelines/issues/77.

With this PR, Miri with `-Zmiri-check-number-validity` implements all my preferred options for what the validity invariants of our types could be. :)

CTFE has been doing recursive checking anyway, so this is backwards compatible but might change the error output. I will submit a PR with the new Miri tests soon.

r? `@oli-obk`

2 years agoRollup merge of #97113 - GuillaumeGomez:search-ui-fixes, r=notriddle
Yuki Okushi [Tue, 17 May 2022 22:41:00 +0000 (07:41 +0900)]
Rollup merge of #97113 - GuillaumeGomez:search-ui-fixes, r=notriddle

Search GUI fixes

The first fix is about the duplicated "in":

![Screenshot from 2022-05-17 13-25-53](https://user-images.githubusercontent.com/3050060/168814186-a4e9064f-4325-469c-8bf6-46ea2737a24f.png)

The second fix is about the `<select>` broken style:

![Screenshot from 2022-05-17 13-37-03](https://user-images.githubusercontent.com/3050060/168814182-b1c5ae66-d8cf-4fd5-a227-5aa8cd8453ab.png)
![Screenshot from 2022-05-17 13-36-55](https://user-images.githubusercontent.com/3050060/168814184-be9e56f8-fad4-477c-899e-9abff4d4910c.png)

You can test it [here](https://rustdoc.crud.net/imperio/search-ui-fixes/doc/foo/index.html?search=test).

r? `@notriddle`

2 years agoRollup merge of #97097 - chorman0773:add_tmm_clobers, r=joshtriplett
Yuki Okushi [Tue, 17 May 2022 22:40:59 +0000 (07:40 +0900)]
Rollup merge of #97097 - chorman0773:add_tmm_clobers, r=joshtriplett

Add tmm_reg clobbers

This adds support for naming the 8 tile registers from intel AMX as clobbers from `asm!` invocations on x86_64 (only). It does not add the registers as input or output operands.

2 years agoRollup merge of #97096 - tmiasko:reachable-constructor, r=petrochenkov
Yuki Okushi [Tue, 17 May 2022 22:40:58 +0000 (07:40 +0900)]
Rollup merge of #97096 - tmiasko:reachable-constructor, r=petrochenkov

Types with reachable constructors are reachable

Fixes #96934.

r? `@petrochenkov`

2 years agoRollup merge of #96761 - klensy:no-rayon-here, r=CraftSpider
Yuki Okushi [Tue, 17 May 2022 22:40:57 +0000 (07:40 +0900)]
Rollup merge of #96761 - klensy:no-rayon-here, r=CraftSpider

rustdoc: don't build `rayon` for non-windows targets

`rayon` used only on windows targets, so no need to build it otherwise.

2 years agoRollup merge of #96651 - ken-matsui:omit-unnecessary-help-to-add-cfg-test, r=cjgillot
Yuki Okushi [Tue, 17 May 2022 22:40:56 +0000 (07:40 +0900)]
Rollup merge of #96651 - ken-matsui:omit-unnecessary-help-to-add-cfg-test, r=cjgillot

Omit unnecessary help to add `#[cfg(test)]` when already annotated

Closes: https://github.com/rust-lang/rust/issues/96611
The related PR is: https://github.com/rust-lang/rust/pull/91770

2 years agoRollup merge of #96647 - Enselic:fix-hrtb-for-wherepredicate, r=CraftSpider
Yuki Okushi [Tue, 17 May 2022 22:40:55 +0000 (07:40 +0900)]
Rollup merge of #96647 - Enselic:fix-hrtb-for-wherepredicate, r=CraftSpider

rustdoc-json: Fix HRTBs for WherePredicate::BoundPredicate

Information about HRTBs are already present for `GenericBound:: TraitBound` and `FunctionPointer`. This PR adds HRTB info also to `WherePredicate::BoundPredicate`.

Use the same field name and type as for the other ones (`generic_params: Vec<GenericParamDef>`). I have verified that this gives rustdoc JSON clients the data they need and in a format that is easy to work with (see https://github.com/Enselic/public-api/pull/92).

I will be happy to add tests for this change (and bump `FORMAT_VERSION` which I just realized I forgot), but it is always nice to get one round of feedback first, so that I don't put a lot of effort into tests that then have to be discarded.

`@rustbot` modify labels: +T-rustdoc +A-rustdoc-json

2 years agoTaking review into account
ricked-twice [Tue, 17 May 2022 20:59:13 +0000 (22:59 +0200)]
Taking review into account

2 years agoAuto merge of #92570 - jsha:rustdoc-search-refactor, r=GuillaumeGomez
bors [Tue, 17 May 2022 19:50:44 +0000 (19:50 +0000)]
Auto merge of #92570 - jsha:rustdoc-search-refactor, r=GuillaumeGomez

Simplify rustdoc search test

Previously, rustdoc search attempted to parse search.js and extract out only certain methods and variables.

This change makes search.js and search-index.js loadable as [CommonJS modules](https://nodejs.org/api/modules.html#modules-commonjs-modules), so they can be loaded directly.

As part of that change, I had to separate execSearch from interacting with the DOM. This wound up being a nice cleanup that made more explicit what inputs it was taking.

I removed search.js' dependency on storage.js by moving hasOwnPropertyRustdoc directly into search.js, and replacing onEach with forEach in a path that is called by the tester.

r? `@GuillaumeGomez`

Demo: https://rustdoc.crud.net/jsha/rustdoc-search-refactor/std/?search=foo

2 years agoClean fix for #96223
ricked-twice [Tue, 17 May 2022 18:31:48 +0000 (20:31 +0200)]
Clean fix for #96223
- Modified `InferCtxt::mk_trait_obligation_with_new_self_ty` to take as
  argument a `Binder<(TraitPredicate, Ty)>` instead of a
  `Binder<TraitPredicate>` and a separate `Ty` with no bound vars.

- Modified all call places to avoid calling `Binder::no_bounds_var` or
  `Binder::skip_binder` when it is not safe.

2 years agoAdd PID to rustc PGO profiles generated in CI
Jakub Beránek [Tue, 17 May 2022 17:10:55 +0000 (19:10 +0200)]
Add PID to rustc PGO profiles generated in CI

2 years agobless 32bit
Ralf Jung [Tue, 17 May 2022 17:05:14 +0000 (19:05 +0200)]
bless 32bit

2 years agorustdoc: make search.js a module
Jacob Hoffman-Andrews [Mon, 16 May 2022 04:09:55 +0000 (21:09 -0700)]
rustdoc: make search.js a module

Previously, search.js relied on the DOM and the `window` object. It can now be
loaded in the absence of the DOM, for instance by Node. The same is true of
search-index.js.

This allows removing a lot of code from src/tools/rustdoc-js/tester.js that
tried to parse search.js and extract specific functions that were needed for
testing.

2 years agointerpret/validity: reject references to uninhabited types
Ralf Jung [Tue, 17 May 2022 15:32:36 +0000 (17:32 +0200)]
interpret/validity: reject references to uninhabited types

2 years agoAuto merge of #96959 - nbdd0121:unwind, r=Amanieu
bors [Tue, 17 May 2022 15:04:50 +0000 (15:04 +0000)]
Auto merge of #96959 - nbdd0121:unwind, r=Amanieu

Prevent unwinding when `-C panic=abort` is used regardless declared ABI

Ensures that Rust code will abort with `-C panic=abort` regardless ABI used.
```rust
extern "C-unwind" {
    fn may_unwind();
}

// Will be nounwind with `-C panic=abort`, despite `C-unwind` ABI.
pub unsafe extern "C-unwind" fn rust_item_that_can_unwind() {
    may_unwind();
}
```

Current behaviour is that unwind will propagate through. While the current behaviour won't cause unsoundness it is inconsistent with the text reading of [RFC2945](https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html).

I tweaked `fn_can_unwind` instead of tweaking `AbortUnwindingCalls` because this approach would allow Rust (non-direct) callers to also see that this function is nounwind, so it can prevent excessive landing pads generation.

For more discussions: https://rust-lang.zulipchat.com/#narrow/stream/210922-project-ffi-unwind/topic/soundness.20in.20mixed.20panic.20mode.

cc `@alexcrichton,` `@BatmanAoD`
r? `@Amanieu`

`@rustbot` label: T-compiler T-lang F-c_unwind

2 years agoAdd GUI test for search crate filter select CSS properties
Guillaume Gomez [Tue, 17 May 2022 12:45:23 +0000 (14:45 +0200)]
Add GUI test for search crate filter select CSS properties

2 years agoFix display of search crate filter select
Guillaume Gomez [Tue, 17 May 2022 12:20:34 +0000 (14:20 +0200)]
Fix display of search crate filter select

2 years agoAuto merge of #97111 - JohnTitor:rollup-x3vjf6u, r=JohnTitor
bors [Tue, 17 May 2022 12:01:12 +0000 (12:01 +0000)]
Auto merge of #97111 - JohnTitor:rollup-x3vjf6u, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #96329 (Add a couple tests for #90887 fixes)
 - #97009 (Allow `unused_macro_rules` in path tests)
 - #97075 (Add regression test for #81804)
 - #97079 (Change `Successors` to `impl Iterator<Item = BasicBlock>`)
 - #97080 (remove the `RelateResultCompare` trait)
 - #97093 (Migrate `maybe_recover_from_bad_type_plus` diagnostic)
 - #97102 (Update function pointer call error message)

Failed merges:

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

2 years agoAdd GUI test for search result "title"
Guillaume Gomez [Tue, 17 May 2022 11:28:22 +0000 (13:28 +0200)]
Add GUI test for search result "title"

2 years agoFix duplicated "in" in the search result text
Guillaume Gomez [Tue, 17 May 2022 11:15:49 +0000 (13:15 +0200)]
Fix duplicated "in" in the search result text

2 years agoUpdate browser-ui-test version to 0.9.2
Guillaume Gomez [Mon, 16 May 2022 19:15:19 +0000 (21:15 +0200)]
Update browser-ui-test version to 0.9.2

2 years agofix clobber_abi tests
Connor Horman [Tue, 17 May 2022 11:11:29 +0000 (07:11 -0400)]
fix clobber_abi tests

2 years agoAdd ABI clobbers
Connor Horman [Tue, 17 May 2022 10:48:03 +0000 (06:48 -0400)]
Add ABI clobbers

2 years agoHandle tmm_reg in rustc_codegen_gcc
Connor Horman [Tue, 17 May 2022 10:34:58 +0000 (06:34 -0400)]
Handle tmm_reg in rustc_codegen_gcc

2 years agoRollup merge of #97102 - mbartlett21:fn-pointer-error, r=lcnr
Yuki Okushi [Tue, 17 May 2022 10:01:35 +0000 (19:01 +0900)]
Rollup merge of #97102 - mbartlett21:fn-pointer-error, r=lcnr

Update function pointer call error message

It now uses the type of context. (fixes #97082)

2 years agoRollup merge of #97093 - pvdrz:migrate-maybe-recover-from-bad-type-plus, r=davidtwco
Yuki Okushi [Tue, 17 May 2022 10:01:34 +0000 (19:01 +0900)]
Rollup merge of #97093 - pvdrz:migrate-maybe-recover-from-bad-type-plus, r=davidtwco

Migrate `maybe_recover_from_bad_type_plus` diagnostic

r? `@davidtwco`

2 years agoRollup merge of #97080 - lcnr:relate-sus, r=oli-obk
Yuki Okushi [Tue, 17 May 2022 10:01:33 +0000 (19:01 +0900)]
Rollup merge of #97080 - lcnr:relate-sus, r=oli-obk

remove the `RelateResultCompare` trait

it's unused

2 years agoRollup merge of #97079 - SparrowLii:successors, r=lcnr
Yuki Okushi [Tue, 17 May 2022 10:01:32 +0000 (19:01 +0900)]
Rollup merge of #97079 - SparrowLii:successors, r=lcnr

Change `Successors` to `impl Iterator<Item = BasicBlock>`

This PR fixes the FIXME in `compiler\rustc_middle\src\mir\mod.rs`.
This can omit several `&`, `*` or `cloned` operations on Successros' generated elements

2 years agoRollup merge of #97075 - JohnTitor:issue-81804, r=compiler-errors
Yuki Okushi [Tue, 17 May 2022 10:01:31 +0000 (19:01 +0900)]
Rollup merge of #97075 - JohnTitor:issue-81804, r=compiler-errors

Add regression test for #81804

Closes #81804
r? ``@compiler-errors``

2 years agoRollup merge of #97009 - fortanix:raoul/unused_macro_sgx, r=thomcc
Yuki Okushi [Tue, 17 May 2022 10:01:30 +0000 (19:01 +0900)]
Rollup merge of #97009 - fortanix:raoul/unused_macro_sgx, r=thomcc

Allow `unused_macro_rules` in path tests

PR #96150 adds a new lint to warn about unused macro rules (arms/matchers). This causes errors in `library/std/src/path/tests.rs` on the `x86_64-fortanix-unknown-sgx` platform. This PR fixes compilation errors on that platform by allowing unused macro rules.

2 years agoRollup merge of #96329 - aliemjay:fixed-by-90887, r=jackh726
Yuki Okushi [Tue, 17 May 2022 10:01:29 +0000 (19:01 +0900)]
Rollup merge of #96329 - aliemjay:fixed-by-90887, r=jackh726

Add a couple tests for #90887 fixes

closes #56556
closes #90875

These are confirmed fixes by #90887, so
r? ``@jackh726``

2 years agoAuto merge of #97012 - oli-obk:🦀_intrinsics, r=davidtwco
bors [Tue, 17 May 2022 09:39:26 +0000 (09:39 +0000)]
Auto merge of #97012 - oli-obk:🦀_intrinsics, r=davidtwco

Add a query for checking whether a function is an intrinsic.

work towards #93145

This will reduce churn when we add more ways to declare intrinsics

r? `@scottmcm`

2 years agoAdd a test for fn pointer calls in consts
mbartlett21 [Tue, 17 May 2022 07:24:47 +0000 (07:24 +0000)]
Add a test for fn pointer calls in consts

2 years agoAuto merge of #96825 - kckeiks:remove-item-like-visitor-trait, r=cjgillot
bors [Tue, 17 May 2022 06:51:45 +0000 (06:51 +0000)]
Auto merge of #96825 - kckeiks:remove-item-like-visitor-trait, r=cjgillot

 Retire `ItemLikeVisitor` trait

Issue #95004
cc `@cjgillot`

2 years agoAuto merge of #96907 - sunfishcode:sunfishcode/update-wasi, r=Mark-Simulacrum
bors [Tue, 17 May 2022 04:37:47 +0000 (04:37 +0000)]
Auto merge of #96907 - sunfishcode:sunfishcode/update-wasi, r=Mark-Simulacrum

Update the wasi toolchain.

Update the WASI build to LLVM 14.0 and the wasi-libc version from wasi-sdk-15.

This will require a ci-mirrors.rust-lang.org file load. Specifically, we
need [this LLVM release tarball] uploaded to be downloadable from
[this URL].

[this LLVM release tarball]: https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
[this URL]: https://ci-mirrors.rust-lang.org/rustc/2022-05-10-clang%2Bllvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz

2 years agoUpdate function pointer call error message
mbartlett21 [Tue, 17 May 2022 04:11:18 +0000 (04:11 +0000)]
Update function pointer call error message

It now uses the type of context. (issue 97082)

2 years agoAdd tracking issue for ExitCode::exit_process
Noa [Tue, 17 May 2022 03:56:26 +0000 (22:56 -0500)]
Add tracking issue for ExitCode::exit_process

2 years agokeep bounds where they were
Christian Poveda [Tue, 17 May 2022 03:23:32 +0000 (22:23 -0500)]
keep bounds where they were

2 years agoAuto merge of #96892 - oli-obk:🐌_obligation_cause_code_🐌, r=estebank
bors [Tue, 17 May 2022 01:46:25 +0000 (01:46 +0000)]
Auto merge of #96892 - oli-obk:🐌_obligation_cause_code_🐌, r=estebank

Clean up derived obligation creation

r? `@estebank`

working on fixing the perf regression from https://github.com/rust-lang/rust/pull/91030#issuecomment-1083360210

2 years agoChange `Successors` to `impl Iterator<Item = BasicBlock>`
SparrowLii [Tue, 17 May 2022 00:41:01 +0000 (08:41 +0800)]
Change `Successors` to `impl Iterator<Item = BasicBlock>`

2 years agoadd clobbers
Connor Horman [Tue, 17 May 2022 00:40:19 +0000 (20:40 -0400)]
add clobbers

2 years agoAdd tmm_reg clobbers
Connor Horman [Tue, 17 May 2022 00:15:06 +0000 (20:15 -0400)]
Add tmm_reg clobbers

2 years agoTypes with reachable constructors are reachable
Tomasz Miąsko [Tue, 17 May 2022 00:00:00 +0000 (00:00 +0000)]
Types with reachable constructors are reachable

2 years agoAuto merge of #96713 - petrochenkov:doclink8, r=notriddle
bors [Mon, 16 May 2022 23:01:28 +0000 (23:01 +0000)]
Auto merge of #96713 - petrochenkov:doclink8, r=notriddle

rustdoc: Resolve some more doc links early 2

The subset of https://github.com/rust-lang/rust/pull/94857 that shouldn't be too expensive.

2 years agomigrate `maybe_recover_from_bad_type_plus` diagnostic
Christian Poveda [Mon, 16 May 2022 22:16:27 +0000 (17:16 -0500)]
migrate `maybe_recover_from_bad_type_plus` diagnostic

2 years agoOmit unnecessary help to add `#[cfg(test)]` when already annotated
Ken Matsui [Mon, 2 May 2022 21:46:25 +0000 (06:46 +0900)]
Omit unnecessary help to add `#[cfg(test)]` when already annotated

2 years agoImprove error message for fallback RNG failure
Chris Martin [Mon, 16 May 2022 17:49:12 +0000 (13:49 -0400)]
Improve error message for fallback RNG failure

2 years agorustdoc: Resolve some more doc links early
Vadim Petrochenkov [Tue, 1 Feb 2022 12:30:32 +0000 (20:30 +0800)]
rustdoc: Resolve some more doc links early

2 years agoAuto merge of #96676 - petrochenkov:docrules, r=GuillaumeGomez
bors [Mon, 16 May 2022 13:53:40 +0000 (13:53 +0000)]
Auto merge of #96676 - petrochenkov:docrules, r=GuillaumeGomez

rustdoc: Remove doc link resolution fallback to all `macro_rules` in the crate

This is a deny-by-default lint detecting such fallback for crater run, as discussed in https://github.com/rust-lang/rust/pull/96521.

2 years agoremove the `RelateResultCompare` trait
lcnr [Mon, 16 May 2022 13:41:05 +0000 (15:41 +0200)]
remove the `RelateResultCompare` trait

2 years agoForce inline InternedObligationCauseCode creation
Oli Scherer [Mon, 16 May 2022 13:34:03 +0000 (13:34 +0000)]
Force inline InternedObligationCauseCode creation

2 years agoUpdate how CC etc. are set in the wasi-libc Makefile.
Dan Gohman [Mon, 16 May 2022 12:07:28 +0000 (05:07 -0700)]
Update how CC etc. are set in the wasi-libc Makefile.

wasi-libc's Makefile changed how it detects the compiler to use; update
Rust's script to set `CC` directly to the compiler it installs.

2 years agoAdd regression test for #81804
Yuki Okushi [Mon, 16 May 2022 10:34:30 +0000 (19:34 +0900)]
Add regression test for #81804

2 years agoAdd a query for checking whether a function is an intrinsic.
Oli Scherer [Fri, 13 May 2022 13:50:21 +0000 (13:50 +0000)]
Add a query for checking whether a function is an intrinsic.

2 years agoAllow `unused_macro_rules` in path tests
Raoul Strackx [Fri, 13 May 2022 12:08:32 +0000 (14:08 +0200)]
Allow `unused_macro_rules` in path tests

2 years agoAuto merge of #97053 - CAD97:realloc-clarification, r=dtolnay
bors [Mon, 16 May 2022 02:33:34 +0000 (02:33 +0000)]
Auto merge of #97053 - CAD97:realloc-clarification, r=dtolnay

Remove potentially misleading realloc parenthetical

This parenthetical is problematic, because it suggests that the following is sound:

```rust
let layout = Layout::new::<[u8; 32]>();
let p1 = alloc(layout);
let p2 = realloc(p1, layout, 32);
if p1 == p2 {
    p1.write([0; 32]);
    dealloc(p1, layout);
} else {
    dealloc(p2, layout);
}
```

At the very least, this isn't the case for [ANSI `realloc`](https://en.cppreference.com/w/c/memory/realloc)

> The original pointer `ptr` is invalidated and any access to it is undefined behavior (even if reallocation was in-place).

and [Windows `HeapReAlloc`](https://docs.microsoft.com/en-us/windows/win32/api/heapapi/nf-heapapi-heaprealloc) is unclear at best (`HEAP_REALLOC_IN_PLACE_ONLY`'s description may imply that the old pointer may be used if `HEAP_REALLOC_IN_PLACE_ONLY` is provided).

The conservative position is to just remove the parenthetical.

cc `@rust-lang/wg-unsafe-code-guidelines` `@rust-lang/wg-allocators`

2 years agoAuto merge of #97065 - gabriel-doriath-dohler:master, r=joshtriplett
bors [Mon, 16 May 2022 00:12:06 +0000 (00:12 +0000)]
Auto merge of #97065 - gabriel-doriath-dohler:master, r=joshtriplett

Rename `eq_ignore_case` to `starts_with_ignore_case`

The method doesn't test for equality. It tests if the object starts with
a given byte array, so its name is confusing.

2 years agoRename `eq_ignore_case` to `starts_with_ignore_case`
gabriel-doriath-dohler [Sun, 15 May 2022 23:59:59 +0000 (23:59 +0000)]
Rename `eq_ignore_case` to `starts_with_ignore_case`

The method doesn't test for equality. It tests if the object starts with
a given byte array, so its name is confusing.

2 years agoAuto merge of #97057 - bjorn3:sync_cg_clif-2022-05-15, r=bjorn3
bors [Sun, 15 May 2022 21:17:46 +0000 (21:17 +0000)]
Auto merge of #97057 - bjorn3:sync_cg_clif-2022-05-15, r=bjorn3

Sync rustc_codegen_cranelift

Since the last sync there have mostly been fixes of various sorts. I also changed cg_clif from using a custom driver to `-Zcodegen-backend` when built as separate project. When built as part of rust it was already using `-Zcodegen-backend`.

r? `@ghost`

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

2 years agoAuto merge of #97063 - Dylan-DPC:rollup-u5el7hb, r=Dylan-DPC
bors [Sun, 15 May 2022 18:52:28 +0000 (18:52 +0000)]
Auto merge of #97063 - Dylan-DPC:rollup-u5el7hb, r=Dylan-DPC

Rollup of 4 pull requests

Successful merges:

 - #96947 (Add rustc_nonnull_optimization_guaranteed to Owned/Borrowed Fd/Socket)
 - #97021 (Added note in documentation)
 - #97042 (Add new eslint rule about brace style)
 - #97060 (Fix use of SetHandleInformation on UWP)

Failed merges:

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

2 years agorustdoc: Remove doc link resolution fallback to all `macro_rules` in the crate
Vadim Petrochenkov [Sun, 15 May 2022 17:05:52 +0000 (20:05 +0300)]
rustdoc: Remove doc link resolution fallback to all `macro_rules` in the crate

2 years agoRollup merge of #97060 - bdbai:fix/uwphandle, r=ChrisDenton
Dylan DPC [Sun, 15 May 2022 16:41:27 +0000 (18:41 +0200)]
Rollup merge of #97060 - bdbai:fix/uwphandle, r=ChrisDenton

Fix use of SetHandleInformation on UWP

The use of `SetHandleInformation` (introduced in #96441 to make `HANDLE` inheritable) breaks UWP builds because it is not available for UWP targets.

Proposed workaround: duplicate the `HANDLE` with `inherit = true` and immediately close the old one. Traditional Windows Desktop programs are not affected.

cc `@ChrisDenton`

2 years agoRollup merge of #97042 - GuillaumeGomez:eslint-brace-style, r=notriddle
Dylan DPC [Sun, 15 May 2022 16:41:26 +0000 (18:41 +0200)]
Rollup merge of #97042 - GuillaumeGomez:eslint-brace-style, r=notriddle

Add new eslint rule about brace style

It also prevents one liners.

r? `@notriddle`

2 years agoRollup merge of #97021 - Volker-Weissmann:patch-1, r=Dylan-DPC
Dylan DPC [Sun, 15 May 2022 16:41:26 +0000 (18:41 +0200)]
Rollup merge of #97021 - Volker-Weissmann:patch-1, r=Dylan-DPC

Added note in documentation

I added this note, because if you forget the `--target` flags, you get a really ugly error message.
https://github.com/rust-lang/cargo/issues/10666

2 years agoRollup merge of #96947 - sunfishcode:sunfishcode/rustc-nonnull-optimization-guarantee...
Dylan DPC [Sun, 15 May 2022 16:41:25 +0000 (18:41 +0200)]
Rollup merge of #96947 - sunfishcode:sunfishcode/rustc-nonnull-optimization-guaranteed, r=joshtriplett

Add rustc_nonnull_optimization_guaranteed to Owned/Borrowed Fd/Socket

PR #94586 added support for using
`rustc_nonnull_optimization_guaranteed` on values where the "null" value
is the all-ones bitpattern.

Now that #94586 has made it to the stage0 compiler, add
`rustc_nonnull_optimization_guaranteed` to `OwnedFd`, `BorrowedFd`,
`OwnedSocket`, and `BorrowedSocket`, since these types all exclude
all-ones bitpatterns.

This allows `Option<OwnedFd>`, `Option<BorrowedFd>`, `Option<OwnedSocket>`,
and `Option<BorrowedSocket>` to be used in FFI declarations, as described
in the [I/O safety RFC].

[I/O safety RFC]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md#ownedfd-and-borrowedfdfd-1

2 years agoAuto merge of #96895 - SparrowLii:interval, r=Mark-Simulacrum
bors [Sun, 15 May 2022 16:27:43 +0000 (16:27 +0000)]
Auto merge of #96895 - SparrowLii:interval, r=Mark-Simulacrum

optimize `insert_range` method of `IntervalSet`

This PR fixes the FIXME in the `insert_range` method that avoids recurse calculations when overlaping

2 years agoAuto merge of #97056 - RalfJung:miri, r=RalfJung
bors [Sun, 15 May 2022 13:46:54 +0000 (13:46 +0000)]
Auto merge of #97056 - RalfJung:miri, r=RalfJung

update miri

Fixes https://github.com/rust-lang/rust/issues/96975
r? `@ghost`

2 years agofix use of SetHandleInformation on UWP
bdbai [Sun, 15 May 2022 13:15:45 +0000 (21:15 +0800)]
fix use of SetHandleInformation on UWP

2 years agoAdd new eslint rule about brace style
Guillaume Gomez [Sat, 14 May 2022 11:50:52 +0000 (13:50 +0200)]
Add new eslint rule about brace style

2 years agoupdate miri
Ralf Jung [Sun, 15 May 2022 11:37:04 +0000 (13:37 +0200)]
update miri

2 years agoAuto merge of #96885 - petrochenkov:linkstrict2, r=cjgillot,luqmana
bors [Sun, 15 May 2022 11:19:27 +0000 (11:19 +0000)]
Auto merge of #96885 - petrochenkov:linkstrict2, r=cjgillot,luqmana

rustc: Stricter checking for #[link] attributes

A subset of https://github.com/rust-lang/rust/pull/94962 that doesn't touch library renaming/reordering/deduplication.

`#[link]` attributes are checked for all kinds of unexpected arguments inside them.
I also tried to make wording for these errors more consistent, that's why some existing errors are changed, including errors for command line `-l` options.
Spans are also made more precise where possible.

2 years agoMerge commit '63734fcdd718cca089f84c42f3a42c0096cfd431' into sync_cg_clif-2022-05-15
bjorn3 [Sun, 15 May 2022 10:32:19 +0000 (12:32 +0200)]
Merge commit '63734fcdd718cca089f84c42f3a42c0096cfd431' into sync_cg_clif-2022-05-15

2 years agoRustup to rustc 1.62.0-nightly (70b3681bf 2022-05-14)
bjorn3 [Sun, 15 May 2022 10:22:00 +0000 (12:22 +0200)]
Rustup to rustc 1.62.0-nightly (70b3681bf 2022-05-14)

2 years agoSync from rust e1ec3260d79497080ca86540562d410ba67d2a95
bjorn3 [Sun, 15 May 2022 10:25:32 +0000 (12:25 +0200)]
Sync from rust e1ec3260d79497080ca86540562d410ba67d2a95

2 years agoAuto merge of #97055 - matthiaskrgr:rollup-1nqwfzx, r=matthiaskrgr
bors [Sun, 15 May 2022 07:32:58 +0000 (07:32 +0000)]
Auto merge of #97055 - matthiaskrgr:rollup-1nqwfzx, r=matthiaskrgr

Rollup of 3 pull requests

Successful merges:

 - #96958 (Improve settings menu display and remove theme menu)
 - #97032 (Allow the unused_macro_rules lint for now)
 - #97041 (Fix `download-ci-llvm` NixOS patching for `.so`s.)

Failed merges:

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

2 years agoRollup merge of #97041 - eddyb:nixos-llvm-ci-patchelf, r=Mark-Simulacrum
Matthias Krüger [Sun, 15 May 2022 06:10:44 +0000 (08:10 +0200)]
Rollup merge of #97041 - eddyb:nixos-llvm-ci-patchelf, r=Mark-Simulacrum

Fix `download-ci-llvm` NixOS patching for `.so`s.

See https://github.com/rust-lang/rust/pull/95170#discussion_r872960686 - in short, `Path::ends_with` doesn't do the same thing as `str::ends_with`, and can only be used to check for whole file names, not extensions.

With this PR, I get the full suite of:
```
extracting /home/eddy/Projects/rust-A/build/cache/llvm-ebb80ec4e90f8622440f3e33562db0d6e6c66555-true/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz to /home/eddy/Projects/rust-A/build/x86_64-unknown-linux-gnu/ci-llvm
info: you seem to be using Nix. Attempting to patch /home/eddy/Projects/rust-A/build/x86_64-unknown-linux-gnu/ci-llvm/bin/llvm-config
/nix/store/r4bzq2xilvv8fmqjg626hzwi22ah3hf4-rust-stage0-dependencies
info: you seem to be using Nix. Attempting to patch /home/eddy/Projects/rust-A/build/x86_64-unknown-linux-gnu/ci-llvm/bin/FileCheck
info: you seem to be using Nix. Attempting to patch /home/eddy/Projects/rust-A/build/x86_64-unknown-linux-gnu/ci-llvm/lib/libLLVM-14-rust-1.62.0-nightly.so
```
(that `libLLVM-14-rust-1.62.0-nightly.so` at the end having been missing before)

r? `@Mark-Simulacrum` cc `@jyn514`

2 years agoRollup merge of #97032 - est31:unused_macro_rules, r=petrochenkov
Matthias Krüger [Sun, 15 May 2022 06:10:42 +0000 (08:10 +0200)]
Rollup merge of #97032 - est31:unused_macro_rules, r=petrochenkov

Allow the unused_macro_rules lint for now

It was newly added by #96150 with warn by default, which is great as it gave exposure to the community, and their feedback gave me ideas for improvements.

Allowing the lint is good for two reasons:

* It makes the transition easier as e.g. allow directives won't fire the unknown lint warning once it is turned to warn by default in the future. The [commit that allowed the lint in fuchsia](https://fuchsia.googlesource.com/fuchsia/+/9d8f96517c3963de2f0e25598fd36061914524cd%5E%21/) had to allow unknown lints for example.
This is especially important compared to other lints in the unused group,
because the _ prefix trick doesn't exist for macro rules, allowing is the
only option (either of unused_macro_rules, or of the entire unused group,
but that is not as informative to readers). Allowing the lint also makes it
possible to work on possible heuristics for disabling the macro in specific
cases.
* It gives time for implementing heuristics for when to suppress the lint, e.g.
when `compile_error!` is invoked by that arm (so it's only there to yield an error).

See: https://github.com/rust-lang/rust/pull/96150#issuecomment-1126599107

I would also like this to be backported to the 1.62 beta branch (cc #97016).

2 years agoRollup merge of #96958 - GuillaumeGomez:settings-menu-display, r=jsha
Matthias Krüger [Sun, 15 May 2022 06:10:42 +0000 (08:10 +0200)]
Rollup merge of #96958 - GuillaumeGomez:settings-menu-display, r=jsha

Improve settings menu display and remove theme menu

We talked about improving the settings menu and we mentioned that firefox pocket was a nice inspiration so I implemented it. The result looks like this:

![Screenshot from 2022-05-11 23-59-53](https://user-images.githubusercontent.com/3050060/167954743-438c0a06-4628-478c-bf0c-d20313c1fdfc.png)

You can test it [here](https://rustdoc.crud.net/imperio/settings-menu-display/doc/foo/index.html).

Only question I have is: should I re-assign the shortcut `T` to this setting menu now that the theme menu is gone? For now I simply removed it.

Important to be noted: the full settings page (at `settings.html`) is still rendered the same as currently.

r? ``@jsha``

2 years agoAuto merge of #96602 - TApplencourt:patch-1, r=Mark-Simulacrum
bors [Sun, 15 May 2022 04:52:16 +0000 (04:52 +0000)]
Auto merge of #96602 - TApplencourt:patch-1, r=Mark-Simulacrum

boostrap.py use curl by default

Fixes #61611

2 years agoRemove potentially misleading realloc parenthetical
CAD97 [Sun, 15 May 2022 03:30:14 +0000 (22:30 -0500)]
Remove potentially misleading realloc parenthetical