]> git.lizzy.rs Git - rust.git/log
rust.git
18 months agoAuto merge of #105613 - Nilstrieb:rename-assert_uninit_valid, r=RalfJung
bors [Wed, 21 Dec 2022 23:20:04 +0000 (23:20 +0000)]
Auto merge of #105613 - Nilstrieb:rename-assert_uninit_valid, r=RalfJung

Rename `assert_uninit_valid` intrinsic

It's not about "uninit" anymore but about "filling with 0x01 bytes" so the name should at least try to reflect that.

This is actually not fully correct though, as it does still panic for all uninit with `-Zstrict-init-checks`. I'm not sure what the best way is to deal with that not causing confusion. I guess we could just remove the flag? I don't think having it makes a lot of sense anymore with the direction that we have chose to go. It could be relevant again if #100423 lands so removing it may be a bit over eager.

r? `@RalfJung`

18 months agoMerge commit '2bb3996244cf1b89878da9e39841e9f6bf061602' into sync_cg_clif-2022-12-14
bjorn3 [Wed, 14 Dec 2022 18:30:46 +0000 (19:30 +0100)]
Merge commit '2bb3996244cf1b89878da9e39841e9f6bf061602' into sync_cg_clif-2022-12-14

18 months agoRename `assert_uninit_valid` intrinsic
Nilstrieb [Mon, 12 Dec 2022 14:47:32 +0000 (15:47 +0100)]
Rename `assert_uninit_valid` intrinsic

It's not about "uninit" anymore but about "filling with 0x01 bytes" so
the name should at least try to reflect that.

18 months agobug! with a better error message for failing Instance::resolve
Michael Goulet [Sun, 11 Dec 2022 19:46:58 +0000 (19:46 +0000)]
bug! with a better error message for failing Instance::resolve

18 months agoRemove unneeded field from `SwitchTargets`
Jakob Degen [Sun, 4 Dec 2022 00:03:27 +0000 (16:03 -0800)]
Remove unneeded field from `SwitchTargets`

18 months agoAuto merge of #97485 - bjorn3:new_archive_writer, r=wesleywiser
bors [Sat, 3 Dec 2022 15:07:39 +0000 (15:07 +0000)]
Auto merge of #97485 - bjorn3:new_archive_writer, r=wesleywiser

Rewrite LLVM's archive writer in Rust

This allows it to be used by other codegen backends.

Fixes https://github.com/bjorn3/rustc_codegen_cranelift/issues/1155

19 months agoPrefer doc comments over `//`-comments in compiler
Maybe Waffle [Sun, 27 Nov 2022 11:15:06 +0000 (11:15 +0000)]
Prefer doc comments over `//`-comments in compiler

19 months agoRewrite LLVM's archive writer in Rust
bjorn3 [Sat, 28 May 2022 10:43:51 +0000 (10:43 +0000)]
Rewrite LLVM's archive writer in Rust

This allows it to be used by other codegen backends

19 months agoRollup merge of #104786 - WaffleLapkin:amp-mut-help, r=compiler-errors
Guillaume Gomez [Sat, 26 Nov 2022 16:47:23 +0000 (17:47 +0100)]
Rollup merge of #104786 - WaffleLapkin:amp-mut-help, r=compiler-errors

Use the power of adding helper function to simplify code w/ `Mutability`

r? `@compiler-errors`

19 months agoAuto merge of #104507 - WaffleLapkin:asderefsyou, r=wesleywiser
bors [Thu, 24 Nov 2022 00:17:35 +0000 (00:17 +0000)]
Auto merge of #104507 - WaffleLapkin:asderefsyou, r=wesleywiser

Use `as_deref` in compiler (but only where it makes sense)

This simplifies some code :3

(there are some changes that are not exacly `as_deref`, but more like "clever `Option`/`Result` method use")

19 months agoAdd `Mutability::{is_mut,is_not}`
Maybe Waffle [Wed, 23 Nov 2022 18:22:51 +0000 (18:22 +0000)]
Add `Mutability::{is_mut,is_not}`

19 months agoRollup merge of #104605 - RalfJung:clf_consts, r=bjorn3
Matthias Krüger [Mon, 21 Nov 2022 13:11:12 +0000 (14:11 +0100)]
Rollup merge of #104605 - RalfJung:clf_consts, r=bjorn3

deduplicate constant evaluation in cranelift backend

The cranelift backend had two matches on `ConstantKind`, which can be avoided, and used this `eval_for_mir` that nothing else uses... this makes things more consistent with the (better-tested) LLVM backend.

I noticed this because cranelift was the only user of `eval_for_mir`. However `try_eval_for_mir` still has one other user in `eval`... the odd thing is that the interpreter has its own `eval_mir_constant` which seems to duplicate the same functionality and does not use `try_eval_for_mir`. No idea what is happening here.

r? ``@bjorn3``
Cc ``@lcnr``

19 months agodeduplicate constant evaluation in cranelift backend
Ralf Jung [Sat, 19 Nov 2022 12:41:21 +0000 (13:41 +0100)]
deduplicate constant evaluation in cranelift backend

also sync LLVM and cranelift structure a bit

19 months agoRollup merge of #104001 - Ayush1325:custom-entry, r=bjorn3
Dylan DPC [Sat, 19 Nov 2022 06:24:43 +0000 (11:54 +0530)]
Rollup merge of #104001 - Ayush1325:custom-entry, r=bjorn3

Improve generating Custom entry function

This commit is aimed at making compiler-generated entry functions (Basically just C `main` right now) more generic so other targets can do similar things for custom entry. This was initially implemented as part of https://github.com/rust-lang/rust/pull/100316.

Currently, this moves the entry function name and Call convention to the target spec.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
19 months agoUse custom entry name in cranelift
Ayush Singh [Thu, 17 Nov 2022 09:29:32 +0000 (14:59 +0530)]
Use custom entry name in cranelift

This is a continuation of 9f0a8620bd7d325e6d42417b08daff3e55cb88f6 for
cranelift.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
19 months agoUse `as_deref` in compiler (but only where it makes sense)
Maybe Waffle [Wed, 16 Nov 2022 21:58:58 +0000 (21:58 +0000)]
Use `as_deref` in compiler (but only where it makes sense)

19 months agocleanup and dedupe CTFE and Miri error reporting
Ralf Jung [Tue, 15 Nov 2022 11:06:20 +0000 (12:06 +0100)]
cleanup and dedupe CTFE and Miri error reporting

19 months agoAuto merge of #104054 - RalfJung:byte-provenance, r=oli-obk
bors [Tue, 15 Nov 2022 17:37:15 +0000 (17:37 +0000)]
Auto merge of #104054 - RalfJung:byte-provenance, r=oli-obk

interpret: support for per-byte provenance

Also factors the provenance map into its own module.

The third commit does the same for the init mask. I can move it in a separate PR if you prefer.

Fixes https://github.com/rust-lang/miri/issues/2181

r? `@oli-obk`

19 months agoadd is_sized method on Abi and Layout, and use it
Ralf Jung [Sun, 13 Nov 2022 11:14:59 +0000 (12:14 +0100)]
add is_sized method on Abi and Layout, and use it

19 months agoFix `rustdoc --version` when used with download-rustc
Joshua Nelson [Wed, 9 Nov 2022 08:52:59 +0000 (02:52 -0600)]
Fix `rustdoc --version` when used with download-rustc

Previously, rustdoc would unconditionally report the version that *rustc* was compiled with.
That showed things like `nightly-2022-10-30`, which wasn't right, since this was a `dev` build compiled from source.

Fix it by changing `rustc_driver::version` to a macro expanded at invocation time.

19 months agofix cranelift and gcc
Ralf Jung [Sun, 6 Nov 2022 13:15:20 +0000 (14:15 +0100)]
fix cranelift and gcc

20 months agoRewrite implementation of `#[alloc_error_handler]`
Amanieu d'Antras [Fri, 14 Oct 2022 01:24:58 +0000 (02:24 +0100)]
Rewrite implementation of `#[alloc_error_handler]`

The new implementation doesn't use weak lang items and instead changes
`#[alloc_error_handler]` to an attribute macro just like
`#[global_allocator]`.

The attribute will generate the `__rg_oom` function which is called by
the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom`
function is defined in any crate then the compiler shim will call
`__rdl_oom` in the alloc crate which will simply panic.

This also fixes link errors with `-C link-dead-code` with
`default_alloc_error_handler`: `__rg_oom` was previously defined in the
alloc crate and would attempt to reference the `oom` lang item, even if
it didn't exist. This worked as long as `__rg_oom` was excluded from
linking since it was not called.

This is a prerequisite for the stabilization of
`default_alloc_error_handler` (#102318).

20 months agoUpdate tooling
Maybe Waffle [Thu, 27 Oct 2022 14:32:17 +0000 (18:32 +0400)]
Update tooling

20 months agoAuto merge of #103392 - RalfJung:miri, r=oli-obk
bors [Tue, 25 Oct 2022 12:33:39 +0000 (12:33 +0000)]
Auto merge of #103392 - RalfJung:miri, r=oli-obk

update Miri

I had to use a hacked version of josh to create this, so let's be careful with merging this and maybe wait a bit to see if the josh issue becomes more clear. But the history looks good to me, we are not adding duplicates of rustc commits that were previously mirrored to Miri.

Also I want to add some cross-testing of Miri in x.py.

20 months agoSupport raw-dylib functions being used inside inlined functions
Daniel Paoliello [Wed, 12 Oct 2022 21:44:01 +0000 (14:44 -0700)]
Support raw-dylib functions being used inside inlined functions

20 months agoRustfmt cg_clif's build system
bjorn3 [Sun, 23 Oct 2022 14:43:48 +0000 (16:43 +0200)]
Rustfmt cg_clif's build system

20 months agoMerge commit '266e96785ab71834b917bf474f130a6d8fdecd4b' into sync_cg_clif-2022-10-23
bjorn3 [Sun, 23 Oct 2022 14:22:55 +0000 (16:22 +0200)]
Merge commit '266e96785ab71834b917bf474f130a6d8fdecd4b' into sync_cg_clif-2022-10-23

20 months agomerge rustc history
Ralf Jung [Fri, 21 Oct 2022 08:18:54 +0000 (10:18 +0200)]
merge rustc history

20 months agomore dupe word typos
Rageking8 [Thu, 13 Oct 2022 16:25:34 +0000 (00:25 +0800)]
more dupe word typos

20 months agomerge rustc history
Ralf Jung [Sun, 9 Oct 2022 10:42:24 +0000 (12:42 +0200)]
merge rustc history

20 months agoAuto merge of #2583 - RalfJung:rustup, r=oli-obk
bors [Sat, 8 Oct 2022 08:53:29 +0000 (08:53 +0000)]
Auto merge of #2583 - RalfJung:rustup, r=oli-obk

initial josh subtree sync

This demonstrates what a josh-based rustup would look like with my patched josh. To create it I did
```
git fetch http://localhost:8000/rust-lang/rust.git:start=75dd959a3a40eb5b4574f8d2e23aa6efbeb33573[:prefix=src/tools/miri]:/src/tools/miri.git master
git merge FETCH_HEAD
./rustup-toolchain HEAD && ./miri fmt
git commit -am rustup
```
Unlike the [previous attempt](https://github.com/rust-lang/miri/pull/2554), this does not add a new root commit to the repo.

Once we merge this, we committed to using josh for subtree syncing, and in particular a version of josh that includes https://github.com/josh-project/josh/pull/961 (or something compatible).

20 months agoRemove `mir::CastKind::Misc`
ouz-a [Tue, 4 Oct 2022 18:39:43 +0000 (21:39 +0300)]
Remove `mir::CastKind::Misc`

21 months agoStabilize bench_black_box
Urgau [Sat, 24 Sep 2022 10:34:56 +0000 (12:34 +0200)]
Stabilize bench_black_box

21 months agorename Unevaluated to UnevaluatedConst
b-naber [Thu, 22 Sep 2022 10:34:23 +0000 (12:34 +0200)]
rename Unevaluated to UnevaluatedConst

21 months agointroduce mir::Unevaluated
b-naber [Mon, 19 Sep 2022 17:46:53 +0000 (19:46 +0200)]
introduce mir::Unevaluated

21 months agoAuto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank
bors [Tue, 20 Sep 2022 12:09:52 +0000 (12:09 +0000)]
Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank

Allow patterns to constrain the hidden type of opaque types

fixes #96572

reverts a revert as original PR was a perf regression that was fixed by reverting it: https://github.com/rust-lang/rust/pull/99368#issuecomment-1186587864)

TODO:

* check if https://github.com/rust-lang/rust/issues/99685 is avoided

21 months agoAuto merge of #98588 - b-naber:valtrees-cleanup, r=lcnr
bors [Sat, 17 Sep 2022 03:04:22 +0000 (03:04 +0000)]
Auto merge of #98588 - b-naber:valtrees-cleanup, r=lcnr

Use only ty::Unevaluated<'tcx, ()> in type system

r? `@lcnr`

21 months agoRevert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank""
Oli Scherer [Wed, 27 Jul 2022 11:58:34 +0000 (11:58 +0000)]
Revert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank""

This reverts commit 4a742a691e7dd2522bad68b86fe2fd5a199d5561.

21 months agonits
b-naber [Thu, 15 Sep 2022 20:27:41 +0000 (22:27 +0200)]
nits

21 months agoAuto merge of #101212 - eholk:dyn-star, r=compiler-errors
bors [Wed, 14 Sep 2022 18:10:51 +0000 (18:10 +0000)]
Auto merge of #101212 - eholk:dyn-star, r=compiler-errors

Initial implementation of dyn*

This PR adds extremely basic and incomplete support for [dyn*](https://smallcultfollowing.com/babysteps//blog/2022/03/29/dyn-can-we-make-dyn-sized/). The goal is to get something in tree behind a flag to make collaboration easier, and also to make sure the implementation so far is not unreasonable. This PR does quite a few things:

* Introduce `dyn_star` feature flag
* Adds parsing for `dyn* Trait` types
* Defines `dyn* Trait` as a sized type
* Adds support for explicit casts, like `42usize as dyn* Debug`
  * Including const evaluation of such casts
* Adds codegen for drop glue so things are cleaned up properly when a `dyn* Trait` object goes out of scope
* Adds codegen for method calls, at least for methods that take `&self`

Quite a bit is still missing, but this gives us a starting point. Note that this is never intended to become stable surface syntax for Rust, but rather `dyn*` is planned to be used as an implementation detail for async functions in dyn traits.

Joint work with `@nikomatsakis` and `@compiler-errors.`

r? `@bjorn3`

21 months agoaddress review again
b-naber [Wed, 14 Sep 2022 13:35:24 +0000 (15:35 +0200)]
address review again

21 months agoAddress code review comments
Eric Holk [Tue, 30 Aug 2022 19:44:00 +0000 (12:44 -0700)]
Address code review comments

21 months agocranelift changes
b-naber [Thu, 30 Jun 2022 14:54:10 +0000 (16:54 +0200)]
cranelift changes

21 months agouse ty::Unevaluated<'tcx, ()> in type system
b-naber [Mon, 27 Jun 2022 14:32:47 +0000 (16:32 +0200)]
use ty::Unevaluated<'tcx, ()> in type system

21 months agoAuto merge of #99556 - davidtwco:collapse-debuginfo, r=wesleywiser
bors [Tue, 13 Sep 2022 01:19:05 +0000 (01:19 +0000)]
Auto merge of #99556 - davidtwco:collapse-debuginfo, r=wesleywiser

ssa: implement `#[collapse_debuginfo]`

cc #39153 rust-lang/compiler-team#386

Debuginfo line information for macro invocations are collapsed by default - line information are replaced by the line of the outermost expansion site. Using `-Zdebug-macros` disables this behaviour.

When the `collapse_debuginfo` feature is enabled, the default behaviour is reversed so that debuginfo is not collapsed by default. In addition, the `#[collapse_debuginfo]` attribute is available and can be applied to macro definitions which will then have their line information collapsed.

r? rust-lang/wg-debugging

21 months agoMake x.py check work
Eric Holk [Tue, 30 Aug 2022 19:39:28 +0000 (12:39 -0700)]
Make x.py check work

21 months agoAuto merge of #101483 - oli-obk:guaranteed_opt, r=fee1-dead
bors [Sat, 10 Sep 2022 09:50:21 +0000 (09:50 +0000)]
Auto merge of #101483 - oli-obk:guaranteed_opt, r=fee1-dead

The `<*const T>::guaranteed_*` methods now return an option for the unknown case

cc https://github.com/rust-lang/rust/issues/53020#issuecomment-1236932443

I chose `0` for "not equal" and `1` for "equal" and left `2` for the unknown case so backends can just forward to raw pointer equality and it works ✨

r? `@fee1-dead` or `@lcnr`

cc `@rust-lang/wg-const-eval`

21 months agoThe `<*const T>::guaranteed_*` methods now return an option for the unknown case
Oli Scherer [Tue, 6 Sep 2022 14:08:59 +0000 (14:08 +0000)]
The `<*const T>::guaranteed_*` methods now return an option for the unknown case

21 months agoChange name of "dataful" variant to "untagged"
Michael Benfield [Thu, 25 Aug 2022 01:14:23 +0000 (01:14 +0000)]
Change name of "dataful" variant to "untagged"

This is in anticipation of a new enum layout, in which the niche
optimization may be applied even when multiple variants have data.

21 months agossa: implement `#[collapse_debuginfo]`
David Wood [Thu, 21 Jul 2022 15:19:22 +0000 (16:19 +0100)]
ssa: implement `#[collapse_debuginfo]`

Debuginfo line information for macro invocations are collapsed by
default - line information are replaced by the line of the outermost
expansion site. Using `-Zdebug-macros` disables this behaviour.

When the `collapse_debuginfo` feature is enabled, the default behaviour
is reversed so that debuginfo is not collapsed by default. In addition,
the `#[collapse_debuginfo]` attribute is available and can be applied to
macro definitions which will then have their line information collapsed.

Signed-off-by: David Wood <david.wood@huawei.com>
21 months agoGeneralize the Assume intrinsic statement to a general Intrinsic statement
Oli Scherer [Tue, 12 Jul 2022 10:05:00 +0000 (10:05 +0000)]
Generalize the Assume intrinsic statement to a general Intrinsic statement

21 months agoLower the assume intrinsic to a MIR statement
Oli Scherer [Thu, 30 Jun 2022 08:16:05 +0000 (08:16 +0000)]
Lower the assume intrinsic to a MIR statement

21 months agoAuto merge of #97802 - Enselic:add-no_ignore_sigkill-feature, r=joshtriplett
bors [Fri, 2 Sep 2022 21:08:08 +0000 (21:08 +0000)]
Auto merge of #97802 - Enselic:add-no_ignore_sigkill-feature, r=joshtriplett

Support `#[unix_sigpipe = "inherit|sig_dfl"]` on `fn main()` to prevent ignoring `SIGPIPE`

When enabled, programs don't have to explicitly handle `ErrorKind::BrokenPipe` any longer. Currently, the program

```rust
fn main() { loop { println!("hello world"); } }
```

will print an error if used with a short-lived pipe, e.g.

    % ./main | head -n 1
    hello world
    thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1016:9
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

by enabling `#[unix_sigpipe = "sig_dfl"]` like this

```rust
#![feature(unix_sigpipe)]
#[unix_sigpipe = "sig_dfl"]
fn main() { loop { println!("hello world"); } }
```

there is no error, because `SIGPIPE` will not be ignored and thus the program will be killed appropriately:

    % ./main | head -n 1
    hello world

The current libstd behaviour of ignoring `SIGPIPE` before `fn main()` can be explicitly requested by using `#[unix_sigpipe = "sig_ign"]`.

With `#[unix_sigpipe = "inherit"]`, no change at all is made to `SIGPIPE`, which typically means the behaviour will be the same as `#[unix_sigpipe = "sig_dfl"]`.

See https://github.com/rust-lang/rust/issues/62569 and referenced issues for discussions regarding the `SIGPIPE` problem itself

See the [this](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Proposal.3A.20First.20step.20towards.20solving.20the.20SIGPIPE.20problem) Zulip topic for more discussions, including about this PR.

Tracking issue: https://github.com/rust-lang/rust/issues/97889

22 months agoAuto merge of #100707 - dzvon:fix-typo, r=davidtwco
bors [Thu, 1 Sep 2022 05:39:58 +0000 (05:39 +0000)]
Auto merge of #100707 - dzvon:fix-typo, r=davidtwco

Fix a bunch of typo

This PR will fix some typos detected by [typos].

I only picked the ones I was sure were spelling errors to fix, mostly in
the comments.

[typos]: https://github.com/crate-ci/typos

22 months agoRollup merge of #100730 - CleanCut:diagnostics-rustc_monomorphize, r=davidtwco
Ralf Jung [Wed, 31 Aug 2022 12:29:51 +0000 (14:29 +0200)]
Rollup merge of #100730 - CleanCut:diagnostics-rustc_monomorphize, r=davidtwco

Migrate rustc_monomorphize to use SessionDiagnostic

### Description

- Migrates diagnostics in `rustc_monomorphize` to use `SessionDiagnostic`
- Adds an `impl IntoDiagnosticArg for PathBuf`

### TODO / Help!
- [x] I'm having trouble figuring out how to apply an optional note. 😕  Help!?
  - Resolved. It was bad docs. Fixed in https://github.com/rust-lang/rustc-dev-guide/pull/1437/files
- [x] `errors:RecursionLimit` should be `#[fatal ...]`, but that doesn't exist so it's `#[error ...]` at the moment.
  - Maybe I can switch after this is merged in? --> https://github.com/rust-lang/rust/pull/100694
  - Or maybe I need to manually implement `SessionDiagnostic` instead of deriving it?
- [x] How does one go about converting an error inside of [a call to struct_span_lint_hir](https://github.com/rust-lang/rust/blob/8064a495086c2e63c0ef77e8e82fe3b9b5dc535f/compiler/rustc_monomorphize/src/collector.rs#L917-L927)?
- [x] ~What placeholder do you use in the fluent template to refer to the value in a vector? It seems like [this code](https://github.com/rust-lang/rust/blob/0b79f758c9aa6646606662a6d623a0752286cd17/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs#L83-L114) ought to have the answer (or something near it)...but I can't figure it out.~ You can't. Punted.

22 months agoCorrect typo
Dezhi Wu [Thu, 18 Aug 2022 08:36:49 +0000 (16:36 +0800)]
Correct typo

22 months agoFix a bunch of typo
Dezhi Wu [Thu, 18 Aug 2022 02:13:37 +0000 (10:13 +0800)]
Fix a bunch of typo

This PR will fix some typos detected by [typos].

I only picked the ones I was sure were spelling errors to fix, mostly in
the comments.

[typos]: https://github.com/crate-ci/typos

22 months agoRollup merge of #101101 - RalfJung:read-pointer-as-bytes, r=oli-obk
Dylan DPC [Tue, 30 Aug 2022 05:56:51 +0000 (11:26 +0530)]
Rollup merge of #101101 - RalfJung:read-pointer-as-bytes, r=oli-obk

interpret: make read-pointer-as-bytes a CTFE-only error with extra information

Next step in the reaction to https://github.com/rust-lang/rust/issues/99923. Also teaches Miri to implicitly strip provenance in more situations when transmuting pointers to integers, which fixes https://github.com/rust-lang/miri/issues/2456.

Pointer-to-int transmutation during CTFE now produces a message like this:
```
   = help: this code performed an operation that depends on the underlying bytes representing a pointer
   = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
```

r? ``@oli-obk``

22 months agoRollup merge of #99027 - tmiasko:basic-blocks, r=oli-obk
Matthias Krüger [Mon, 29 Aug 2022 04:34:43 +0000 (06:34 +0200)]
Rollup merge of #99027 - tmiasko:basic-blocks, r=oli-obk

Replace `Body::basic_blocks()` with field access

Since the refactoring in #98930, it is possible to borrow the basic blocks
independently from other parts of MIR by accessing the `basic_blocks` field
directly.

Replace unnecessary `Body::basic_blocks()` method with a direct field access,
which has an additional benefit of borrowing the basic blocks only.

22 months agoSupport `#[unix_sigpipe = "inherit|sig_dfl|sig_ign"]` on `fn main()`
Martin Nordholts [Tue, 5 Jul 2022 17:56:22 +0000 (19:56 +0200)]
Support `#[unix_sigpipe = "inherit|sig_dfl|sig_ign"]` on `fn main()`

This makes it possible to instruct libstd to never touch the signal
handler for `SIGPIPE`, which makes programs pipeable by default (e.g.
with `./your-program | head -n 1`) without `ErrorKind::BrokenPipe`
errors.

22 months agoAuto merge of #96946 - WaffleLapkin:ptr_mask, r=scottmcm
bors [Sun, 28 Aug 2022 01:34:47 +0000 (01:34 +0000)]
Auto merge of #96946 - WaffleLapkin:ptr_mask, r=scottmcm

Add pointer masking convenience functions

This PR adds the following public API:
```rust
impl<T: ?Sized> *const T {
    fn mask(self, mask: usize) -> *const T;
}

impl<T: ?Sized> *mut T {
    fn mask(self, mask: usize) -> *const T;
}

// mod intrinsics
fn mask<T>(ptr: *const T, mask: usize) -> *const T
```
This is equivalent to `ptr.map_addr(|a| a & mask)` but also uses a cool llvm intrinsic.

Proposed in https://github.com/rust-lang/rust/pull/95643#issuecomment-1121562352

cc `@Gankra` `@scottmcm` `@RalfJung`

r? rust-lang/libs-api

22 months agointerpret: make read-pointer-as-bytes *always* work in Miri
Ralf Jung [Sat, 27 Aug 2022 18:54:02 +0000 (14:54 -0400)]
interpret: make read-pointer-as-bytes *always* work in Miri

and show some extra information when it happens in CTFE

22 months agointerpret: rename relocation → provenance
Ralf Jung [Sat, 27 Aug 2022 18:11:19 +0000 (14:11 -0400)]
interpret: rename relocation → provenance

22 months agoAuto merge of #100999 - nnethercote:shrink-FnAbi, r=bjorn3
bors [Sat, 27 Aug 2022 14:00:53 +0000 (14:00 +0000)]
Auto merge of #100999 - nnethercote:shrink-FnAbi, r=bjorn3

Shrink `FnAbi`

Because they can take up a lot of memory in debug and release builds.

r? `@bjorn3`

22 months agoReplace `Body::basic_blocks()` with field access
Tomasz Miąsko [Tue, 5 Jul 2022 00:00:00 +0000 (00:00 +0000)]
Replace `Body::basic_blocks()` with field access

22 months agoMove `ArgAbi::pad_i32` into `PassMode::Cast`.
Nicholas Nethercote [Thu, 25 Aug 2022 12:19:38 +0000 (22:19 +1000)]
Move `ArgAbi::pad_i32` into `PassMode::Cast`.

Because it's only needed for that variant. This shrinks the types and
clarifies the logic.

22 months agoBox `CastTarget` within `PassMode`.
Nicholas Nethercote [Thu, 25 Aug 2022 07:52:37 +0000 (17:52 +1000)]
Box `CastTarget` within `PassMode`.

Because `PassMode::Cast` is by far the largest variant, but is
relatively rare.

This requires making `PassMode` not impl `Copy`, and `Clone` is no
longer necessary. This causes lots of sigil adjusting, but nothing very
notable.

22 months agoadjust to new error value
Nathan Stocks [Wed, 24 Aug 2022 22:52:46 +0000 (16:52 -0600)]
adjust to new error value

22 months agoRustfmt
bjorn3 [Wed, 24 Aug 2022 17:06:47 +0000 (17:06 +0000)]
Rustfmt

22 months agoMerge commit 'e9d1a0a7b0b28dd422f1a790ccde532acafbf193' into sync_cg_clif-2022-08-24
bjorn3 [Wed, 24 Aug 2022 16:40:58 +0000 (18:40 +0200)]
Merge commit 'e9d1a0a7b0b28dd422f1a790ccde532acafbf193' into sync_cg_clif-2022-08-24

22 months agoRollup merge of #100822 - WaffleLapkin:no_offset_question_mark, r=scottmcm
Matthias Krüger [Sun, 21 Aug 2022 14:54:07 +0000 (16:54 +0200)]
Rollup merge of #100822 - WaffleLapkin:no_offset_question_mark, r=scottmcm

Replace most uses of `pointer::offset` with `add` and `sub`

As PR title says, it replaces `pointer::offset` in compiler and standard library with `pointer::add` and `pointer::sub`. This generally makes code cleaner, easier to grasp and removes (or, well, hides) integer casts.

This is generally trivially correct, `.offset(-constant)` is just `.sub(constant)`, `.offset(usized as isize)` is just `.add(usized)`, etc. However in some cases we need to be careful with signs of things.

r? ````@scottmcm````

_split off from #100746_

22 months agofix cg cranelift
Waffle Maybe [Sun, 7 Aug 2022 18:32:26 +0000 (22:32 +0400)]
fix cg cranelift

Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
22 months agouse shorter `ptr_mask` impl in cg cranelift
Waffle Maybe [Wed, 11 May 2022 17:43:13 +0000 (21:43 +0400)]
use shorter `ptr_mask` impl in cg cranelift

Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
22 months agoAdd pointer masking convenience functions
Maybe Waffle [Wed, 11 May 2022 13:52:00 +0000 (17:52 +0400)]
Add pointer masking convenience functions

This commit adds the following functions all of which have a signature
`pointer, usize -> pointer`:
- `<*mut T>::mask`
- `<*const T>::mask`
- `intrinsics::ptr_mask`

These functions are equivalent to `.map_addr(|a| a & mask)` but they
utilize `llvm.ptrmask` llvm intrinsic.

*masks your pointers*

22 months agoReplace most uses of `pointer::offset` with `add` and `sub`
Maybe Waffle [Fri, 19 Aug 2022 09:33:06 +0000 (13:33 +0400)]
Replace most uses of `pointer::offset` with `add` and `sub`

22 months agoRollup merge of #100208 - RalfJung:dyn-upcast-nop, r=petrochenkov
Dylan DPC [Fri, 19 Aug 2022 06:56:41 +0000 (12:26 +0530)]
Rollup merge of #100208 - RalfJung:dyn-upcast-nop, r=petrochenkov

make NOP dyn casts not require anything about the vtable

As suggested [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/144729-t-types/topic/dyn-upcasting.20stabilization/near/292151439). This matches what the codegen backends already do, and what Miri did do until https://github.com/rust-lang/rust/pull/99420 when I made it super extra paranoid.

22 months agoalso update anyhow in codegen_cranelift
Ralf Jung [Mon, 8 Aug 2022 13:04:26 +0000 (09:04 -0400)]
also update anyhow in codegen_cranelift

22 months agomake NOP dyn casts not require anything about the vtable
Ralf Jung [Sat, 6 Aug 2022 21:18:59 +0000 (17:18 -0400)]
make NOP dyn casts not require anything about the vtable

23 months agoIntroduce an ArchiveBuilderBuilder
bjorn3 [Thu, 28 Jul 2022 09:07:49 +0000 (09:07 +0000)]
Introduce an ArchiveBuilderBuilder

This avoids monomorphizing all linker code for each codegen backend and
will allow passing in extra information to the archive builder from the
codegen backend.

23 months agoInline inject_dll_import_lib
bjorn3 [Thu, 28 Jul 2022 08:43:15 +0000 (08:43 +0000)]
Inline inject_dll_import_lib

23 months agoMove output argument from ArchiveBuilder::new to .build()
bjorn3 [Thu, 28 Jul 2022 08:39:19 +0000 (08:39 +0000)]
Move output argument from ArchiveBuilder::new to .build()

23 months agoMerge commit 'd3a2366ee877075c59b38bd8ced55f224fc7ef51' into sync_cg_clif-2022-07-26
bjorn3 [Tue, 26 Jul 2022 16:53:46 +0000 (18:53 +0200)]
Merge commit 'd3a2366ee877075c59b38bd8ced55f224fc7ef51' into sync_cg_clif-2022-07-26

23 months agoAuto merge of #99745 - JohnTitor:rollup-lvrie64, r=JohnTitor
bors [Tue, 26 Jul 2022 04:28:41 +0000 (04:28 +0000)]
Auto merge of #99745 - JohnTitor:rollup-lvrie64, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #98211 (Implement `fs::get_path` for FreeBSD.)
 - #99353 (Slightly improve mismatched GAT where clause error)
 - #99593 (Suggest removing the tuple struct field for the unwrapped value)
 - #99615 (Remove some explicit `self.infcx` for `FnCtxt`, which already derefs into `InferCtxt`)
 - #99711 (Remove reachable coverage without counters)
 - #99718 (Avoid `&str`/`Symbol` to `String` conversions)
 - #99720 (Sync rustc_codegen_cranelift)

Failed merges:

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

23 months agoAuto merge of #98989 - dpaoliello:rawdylibbin, r=michaelwoerister
bors [Tue, 26 Jul 2022 01:47:34 +0000 (01:47 +0000)]
Auto merge of #98989 - dpaoliello:rawdylibbin, r=michaelwoerister

Enable raw-dylib for bin crates

Fixes #93842

When `raw-dylib` is used in a `bin` crate, we need to collect all of the `raw-dylib` functions, generate the import library and add that to the linker command line.

I also changed the tests so that 1) the C++ dlls are created after the Rust dlls, thus there is no chance of accidentally using them in the Rust linking process and 2) disabled generating import libraries when building with MSVC.

23 months agoMerge commit 'c19edfd71a1d0ddef86c2c67fdb40718d40a72b4' into sync_cg_clif-2022-07-25
bjorn3 [Mon, 25 Jul 2022 14:07:57 +0000 (16:07 +0200)]
Merge commit 'c19edfd71a1d0ddef86c2c67fdb40718d40a72b4' into sync_cg_clif-2022-07-25

23 months agoAuto merge of #99251 - cuviper:hashbrown-0.12, r=Mark-Simulacrum
bors [Sun, 24 Jul 2022 04:03:29 +0000 (04:03 +0000)]
Auto merge of #99251 - cuviper:hashbrown-0.12, r=Mark-Simulacrum

Upgrade indexmap and thorin-dwp to use hashbrown 0.12

This removes the last dependencies on hashbrown 0.11.

This also upgrades to hashbrown 0.12.3 to fix a double-free (#99372).

23 months agoEnable raw-dylib for binaries
Daniel Paoliello [Fri, 1 Jul 2022 20:01:41 +0000 (13:01 -0700)]
Enable raw-dylib for binaries

23 months agovarious nits from review
Ralf Jung [Wed, 20 Jul 2022 14:47:49 +0000 (10:47 -0400)]
various nits from review

23 months agoImplement vtable_size and vtable_align intrinsics for cg_clif
bjorn3 [Wed, 20 Jul 2022 13:36:58 +0000 (13:36 +0000)]
Implement vtable_size and vtable_align intrinsics for cg_clif

23 months agoslightly cleaner, if more verbose, vtable handling in codegen backends
Ralf Jung [Wed, 20 Jul 2022 00:19:15 +0000 (20:19 -0400)]
slightly cleaner, if more verbose, vtable handling in codegen backends

23 months agoconsistently use VTable over Vtable (matching stable stdlib API RawWakerVTable)
Ralf Jung [Tue, 19 Jul 2022 23:57:44 +0000 (19:57 -0400)]
consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable)

23 months agorename get_global_alloc to try_get_global_alloc
Ralf Jung [Sun, 17 Jul 2022 15:40:34 +0000 (11:40 -0400)]
rename get_global_alloc to try_get_global_alloc

23 months agoadd a Vtable kind of symbolic allocations
Ralf Jung [Sun, 17 Jul 2022 15:36:37 +0000 (11:36 -0400)]
add a Vtable kind of symbolic allocations

23 months agoRevert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank"
Oli Scherer [Wed, 20 Jul 2022 07:55:58 +0000 (07:55 +0000)]
Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank"

This reverts commit 6f8fb911ad504b77549cf3256a09465621beab9d, reversing
changes made to 7210e46dc69a4b197a313d093fe145722c248b7d.

23 months agoAuto merge of #99033 - 5225225:interpreter-validity-checks, r=oli-obk
bors [Sun, 17 Jul 2022 19:28:01 +0000 (19:28 +0000)]
Auto merge of #99033 - 5225225:interpreter-validity-checks, r=oli-obk

Use constant eval to do strict mem::uninit/zeroed validity checks

I'm not sure about the code organisation here, I just dumped the check in rustc_const_eval at the root. Not hard to move it elsewhere, in any case.

Also, this means cranelift codegen intrinsics lose the strict checks, since they don't seem to depend on rustc_const_eval, and I didn't see a point in keeping around two copies.

I also left comments in the is_zero_valid methods about "uhhh help how do i do this", those apply to both methods equally.

Also rustc_codegen_ssa now depends on rustc_const_eval... is this okay?

Pinging `@RalfJung` since you were the one who mentioned this to me, so I'm assuming you're interested.

Haven't had a chance to run full tests on this since it's really warm, and it's 1AM, I'll check out any failures/comments in the morning :)

23 months agoUpgrade hashbrown to 0.12.3
Amanieu d'Antras [Sun, 17 Jul 2022 11:23:26 +0000 (13:23 +0200)]
Upgrade hashbrown to 0.12.3

This fixes a double-free in the `clone_from` function if dropping an
existing element in the table panics. See
https://github.com/rust-lang/hashbrown/pull/348 for more details.

23 months agoUpgrade indexmap and thorin-dwp to use hashbrown 0.12
Josh Stone [Thu, 14 Jul 2022 17:13:52 +0000 (10:13 -0700)]
Upgrade indexmap and thorin-dwp to use hashbrown 0.12

This removes the last dependencies on hashbrown 0.11.

23 months agoIntroduce opaque type to hidden type projection
Oli Scherer [Wed, 22 Jun 2022 15:28:28 +0000 (15:28 +0000)]
Introduce opaque type to hidden type projection

23 months agoUse constant eval to do strict validity checks
5225225 [Thu, 14 Jul 2022 21:42:47 +0000 (22:42 +0100)]
Use constant eval to do strict validity checks

23 months agoRename `debugging_opts` to `unstable_opts`
Joshua Nelson [Wed, 6 Jul 2022 12:44:47 +0000 (07:44 -0500)]
Rename `debugging_opts` to `unstable_opts`

This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.