Commit Graph

2053 Commits

Author SHA1 Message Date
bors
5e1872598c 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.
2022-10-25 12:33:39 +00:00
Daniel Paoliello
e3311e4717 Support raw-dylib functions being used inside inlined functions 2022-10-24 16:17:38 -07:00
bjorn3
63d1bf9920 Rustfmt cg_clif's build system 2022-10-23 16:43:48 +02:00
bjorn3
9950bd1dc5 Merge commit '266e96785ab71834b917bf474f130a6d8fdecd4b' into sync_cg_clif-2022-10-23 2022-10-23 16:22:55 +02:00
Ralf Jung
1e720cdb46 merge rustc history 2022-10-21 10:18:54 +02:00
Rageking8
54ee5ac073 more dupe word typos 2022-10-14 12:57:56 +08:00
Ralf Jung
55fe2b3fbf merge rustc history 2022-10-09 12:42:24 +02:00
bors
31792f141b 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).
2022-10-08 08:53:29 +00:00
ouz-a
187b76965a Remove mir::CastKind::Misc 2022-10-06 15:32:41 +03:00
Urgau
102a577bb3 Stabilize bench_black_box 2022-09-27 17:38:51 +02:00
b-naber
7e250da20f rename Unevaluated to UnevaluatedConst 2022-09-23 14:27:34 +02:00
b-naber
3c5882018f introduce mir::Unevaluated 2022-09-22 12:35:28 +02:00
bors
6eeefe2ce6 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
2022-09-20 12:09:52 +00:00
bors
6214e085ed Auto merge of #98588 - b-naber:valtrees-cleanup, r=lcnr
Use only ty::Unevaluated<'tcx, ()> in type system

r? `@lcnr`
2022-09-17 03:04:22 +00:00
Oli Scherer
93af5f5999 Revert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank""
This reverts commit 4a742a691e.
2022-09-16 11:36:39 +00:00
b-naber
d7c77313cb nits 2022-09-15 22:27:41 +02:00
bors
e4d2f94a83 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`
2022-09-14 18:10:51 +00:00
b-naber
a10dd1f340 address review again 2022-09-14 17:30:25 +02:00
Eric Holk
6d544a8a4c Address code review comments 2022-09-13 14:50:12 -07:00
b-naber
fa35afe8dc cranelift changes 2022-09-13 17:44:49 +02:00
b-naber
da373e3ea8 use ty::Unevaluated<'tcx, ()> in type system 2022-09-13 17:40:59 +02:00
bors
11c831d696 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
2022-09-13 01:19:05 +00:00
Eric Holk
0221923952 Make x.py check work 2022-09-12 17:29:11 -07:00
bors
16ed191362 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`
2022-09-10 09:50:21 +00:00
Oli Scherer
931c07c94f The <*const T>::guaranteed_* methods now return an option for the unknown case 2022-09-09 15:16:04 +00:00
Michael Benfield
944a142bfa 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.
2022-09-07 20:12:45 +00:00
David Wood
1cf9be98cd 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>
2022-09-07 13:54:51 +01:00
Oli Scherer
104168a0f8 Generalize the Assume intrinsic statement to a general Intrinsic statement 2022-09-06 14:18:32 +00:00
Oli Scherer
088e03fe22 Lower the assume intrinsic to a MIR statement 2022-09-06 14:18:32 +00:00
bors
b8169a6da0 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
2022-09-02 21:08:08 +00:00
bors
bfb2016a7e 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
2022-09-01 05:39:58 +00:00
Ralf Jung
d60e93035f 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](8064a49508/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](0b79f758c9/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.
2022-08-31 14:29:51 +02:00
Dezhi Wu
3d9cee13dd Correct typo 2022-08-31 18:25:00 +08:00
Dezhi Wu
8d76b2ffb9 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
2022-08-31 18:24:55 +08:00
Dylan DPC
5e494b4243 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``
2022-08-30 11:26:51 +05:30
Matthias Krüger
663b8949b7 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.
2022-08-29 06:34:43 +02:00
Martin Nordholts
4b3aa91b03 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.
2022-08-28 19:46:45 +02:00
bors
f48af912ea 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
2022-08-28 01:34:47 +00:00
Ralf Jung
94f2fef4cc interpret: make read-pointer-as-bytes *always* work in Miri
and show some extra information when it happens in CTFE
2022-08-27 18:37:44 -04:00
Ralf Jung
0644a8c858 interpret: rename relocation → provenance 2022-08-27 14:11:19 -04:00
bors
1239a022ca 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`
2022-08-27 14:00:53 +00:00
Tomasz Miąsko
1071c4c10b Replace Body::basic_blocks() with field access 2022-08-26 14:27:08 +02:00
Nicholas Nethercote
2d2a3be651 Move ArgAbi::pad_i32 into PassMode::Cast.
Because it's only needed for that variant. This shrinks the types and
clarifies the logic.
2022-08-26 11:12:36 +10:00
Nicholas Nethercote
1c989472e4 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.
2022-08-26 09:35:28 +10:00
Nathan Stocks
8c93170965 adjust to new error value 2022-08-25 11:06:45 -06:00
bjorn3
d9bbac069b Rustfmt 2022-08-24 17:06:47 +00:00
bjorn3
cfef0a4f8d Merge commit 'e9d1a0a7b0b28dd422f1a790ccde532acafbf193' into sync_cg_clif-2022-08-24 2022-08-24 18:40:58 +02:00
Matthias Krüger
5a9b11648f 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_
2022-08-21 16:54:07 +02:00
Waffle Maybe
5f357c2c51 fix cg cranelift
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2022-08-21 05:27:14 +04:00
Waffle Maybe
63a137605f use shorter ptr_mask impl in cg cranelift
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2022-08-21 05:27:14 +04:00