]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #86926 - bjorn3:update_some_deps, r=Mark-Simulacrum
Yuki Okushi [Sun, 11 Jul 2021 19:31:59 +0000 (04:31 +0900)]
Rollup merge of #86926 - bjorn3:update_some_deps, r=Mark-Simulacrum

Update regex crates

This removes two dependencies of rustbuild

2 years agoRollup merge of #73936 - zachlute:rustdoc-optflagmulti, r=jyn514
Yuki Okushi [Sun, 11 Jul 2021 19:31:58 +0000 (04:31 +0900)]
Rollup merge of #73936 - zachlute:rustdoc-optflagmulti, r=jyn514

Rustdoc: Change all 'optflag' arguments to 'optflagmulti'

Because specifying these flags multiple times will never be discernibly different in functionality from specifying them a single time, there is no reason to fail and report an error to the user.

This might be a slightly controversial change. it's tough to say, but it's hard to imagine a case where somebody was depending on this behavior, and doing this seem actively better for the user.

This originally came up in discussion of a fix for  [Cargo #8373](https://github.com/rust-lang/cargo/issues/8373), in [Cargo PR #8422](https://github.com/rust-lang/cargo/pull/8422).

The issue is that Cargo will automatically add things like `--document-private-items` to binaries, because it's the only thing that makes sense there. Then some poor user comes along and adds `--document-private-items` to their `rustdoc` flags for the project and suddenly they're getting errors for specifying a flag twice and need to track down which targets to actually add it to without getting duplicates for reasons they won't understand without deep understanding of Cargo behavior.

We're apparently hesitant to inspect `rustdoc` flags provided by the user directly in Cargo, because they're supposed to be opaque, so looking to see if it's already provided before adding it is evidently a non-starter. In trying to resolve that, one suggestion I came up with was to just change `rustdoc` to support passing the flag multiple times, because the user's intent should be clear and it's not *really* an error, so maybe this is a case of 'be permissive in what you accept'.

This PR is an attempt to do that in a straightforward manner for purposes of discussion.

2 years agoAuto merge of #85941 - cjgillot:qresolve, r=Aaron1011
bors [Sun, 11 Jul 2021 16:09:17 +0000 (16:09 +0000)]
Auto merge of #85941 - cjgillot:qresolve, r=Aaron1011

Reduce the amount of untracked state in TyCtxt -- Take 2

Main part of #85153

The offending line (https://github.com/rust-lang/rust/pull/85153#discussion_r642866298) is replaced by a FIXME until the possible bug and the perf concern are both resolved.

r? `@Aaron1011`

2 years agoAuto merge of #87057 - RalfJung:miri, r=RalfJung
bors [Sun, 11 Jul 2021 13:45:37 +0000 (13:45 +0000)]
Auto merge of #87057 - RalfJung:miri, r=RalfJung

update Miri

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

2 years agoupdate Miri
Ralf Jung [Sun, 11 Jul 2021 12:04:58 +0000 (14:04 +0200)]
update Miri

2 years agoAuto merge of #86995 - sexxi-goose:rewrite, r=nikomatsakis
bors [Sun, 11 Jul 2021 11:25:31 +0000 (11:25 +0000)]
Auto merge of #86995 - sexxi-goose:rewrite, r=nikomatsakis

2229: Rewrite/Refactor Closure Capture Analaysis

While handling all the differnet edge cases the code for the captur analysis got pretty compicated. Looking at the overall picture of the edge cases the rules can still be layed out simply.

Alogithm: https://hackmd.io/D3I_gwvuT-SPnJ22tgJumw

r? `@nikomatsakis`

Closes https://github.com/rust-lang/project-rfc-2229/issues/52
Implementation part of https://github.com/rust-lang/project-rfc-2229/issues/53

3 years agoAuto merge of #87042 - petrochenkov:cleanquotspan, r=Aaron1011
bors [Sun, 11 Jul 2021 08:46:43 +0000 (08:46 +0000)]
Auto merge of #87042 - petrochenkov:cleanquotspan, r=Aaron1011

Cleanup span quoting

I finally got to reviewing https://github.com/rust-lang/rust/pull/84278.
See the individual commit messages.
r? `@Aaron1011`

3 years agoAuto merge of #83918 - workingjubilee:stable-rangefrom-pat, r=joshtriplett
bors [Sun, 11 Jul 2021 06:31:42 +0000 (06:31 +0000)]
Auto merge of #83918 - workingjubilee:stable-rangefrom-pat, r=joshtriplett

Stabilize "RangeFrom" patterns in 1.55

Implements a partial stabilization of #67264 and #37854.
Reference PR: https://github.com/rust-lang/reference/pull/900

# Stabilization Report

This stabilizes the `X..` pattern, shown as such, offering an exhaustive match for unsigned integers:
```rust
match x as u32 {
      0 => println!("zero!"),
      1.. => println!("positive number!"),
}
```

Currently if a Rust author wants to write such a match on an integer, they must use `1..={integer}::MAX` . By allowing a "RangeFrom" style pattern, this simplifies the match to not require the MAX path and thus not require specifically repeating the type inside the match, allowing for easier refactoring. This is particularly useful for instances like the above case, where different behavior on "0" vs. "1 or any positive number" is desired, and the actual MAX is unimportant.

Notably, this excepts slice patterns which include half-open ranges from stabilization, as the wisdom of those is still subject to some debate.

## Practical Applications

Instances of this specific usage have appeared in the compiler:
https://github.com/rust-lang/rust/blob/16143d10679537d3fde4247e15334e78ad9d55b9/compiler/rustc_middle/src/ty/inhabitedness/mod.rs#L219
https://github.com/rust-lang/rust/blob/673d0db5e393e9c64897005b470bfeb6d5aec61b/compiler/rustc_ty_utils/src/ty.rs#L524

And I have noticed there are also a handful of "in the wild" users who have deployed it to similar effect, especially in the case of rejecting any value of a certain number or greater. It simply makes it much more ergonomic to write an irrefutable match, as done in Katholieke Universiteit Leuven's [SCALE and MAMBA project](https://github.com/KULeuven-COSIC/SCALE-MAMBA/blob/05e5db00d553573534258585651c525d0da5f83f/WebAssembly/scale_std/src/fixed_point.rs#L685-L695).

## Tests
There were already many tests in [src/test/ui/half-open-range/patterns](https://github.com/rust-lang/rust/tree/90a2e5e3fe59a254d4d707aa291517b3791ea5a6/src/test/ui/half-open-range-patterns), as well as [generic pattern tests that test the `exclusive_range_pattern` feature](https://github.com/rust-lang/rust/blob/673d0db5e393e9c64897005b470bfeb6d5aec61b/src/test/ui/pattern/usefulness/integer-ranges/reachability.rs), many dating back to the feature's introduction and remaining standing to this day. However, this stabilization comes with some additional tests to explore the... sometimes interesting behavior of interactions with other patterns. e.g. There is, at least, a mild diagnostic improvement in some edge cases, because before now, the pattern `0..=(5+1)` encounters the `half_open_range_patterns` feature gate and can thus emit the request to enable the feature flag, while also emitting the "inclusive range with no end" diagnostic. There is no intent to allow an `X..=` pattern that I am aware of, so removing the flag request is a strict improvement. The arrival of the `J | K` "or" pattern also enables some odd formations.

Some of the behavior tested for here is derived from experiments in this [Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=58777b3c715c85165ac4a70d93efeefc) example, linked at https://github.com/rust-lang/rust/issues/67264#issuecomment-812770692, which may be useful to reference to observe the current behavior more closely.

In addition tests constituting an explanation of the "slicing range patterns" syntax issue are included in this PR.

## Desiderata

The exclusive range patterns and half-open range patterns are fairly strongly requested by many authors, as they make some patterns much more natural to write, but there is disagreement regarding the "closed" exclusive range pattern or the "RangeTo" pattern, especially where it creates "off by one" gaps in the presence of a "catch-all" wildcard case. Also, there are obviously no range analyses in place that will force diagnostics for e.g. highly overlapping matches. I believe these should be warned on, ideally, and I think it would be reasonable to consider such a blocker to stabilizing this feature, but there is no technical issue with the feature as-is from the purely syntactic perspective as such overlapping or missed matches can already be generated today with such a catch-all case. And part of the "point" of the feature, at least from my view, is to make it easier to omit wildcard matches: a pattern with such an "open" match produces an irrefutable match and does not need the wild card case, making it easier to benefit from exhaustiveness checking.

## History

- Implemented:
  - Partially via exclusive ranges: https://github.com/rust-lang/rust/pull/35712
  - Fully with half-open ranges: https://github.com/rust-lang/rust/pull/67258
- Unresolved Questions:
  - The precedence concerns of https://github.com/rust-lang/rust/pull/48501 were considered as likely requiring adjustment but probably wanting a uniform consistent change across all pattern styles, given https://github.com/rust-lang/rust/issues/67264#issuecomment-720711656, but it is still unknown what changes might be desired
  - How we want to handle slice patterns in ranges seems to be an open question still, as witnessed in the discussion of this PR!

I checked but I couldn't actually find an RFC for this, and given "approved provisionally by lang team without an RFC", I believe this might require an RFC before it can land? Unsure of procedure here, on account of this being stabilizing a subset of a feature of syntax.

r? `@scottmcm`

3 years agoAuto merge of #86965 - sexxi-goose:rfc2229-improve-lint, r=nikomatsakis,lqd
bors [Sun, 11 Jul 2021 03:50:28 +0000 (03:50 +0000)]
Auto merge of #86965 - sexxi-goose:rfc2229-improve-lint, r=nikomatsakis,lqd

Improves migrations lint for RFC2229

This PR improves the current disjoint capture migration lint by providing more information on why drop order or auto trait implementation for a closure is impacted by the use of the new feature.

The drop order migration lint will now look something like this:
```
error: changes to closure capture in Rust 2021 will affect drop order
  --> $DIR/significant_drop.rs:163:21
   |
LL |             let c = || {
   |                     ^^
...
LL |                 tuple.0;
   |                 ------- in Rust 2018, closure captures all of `tuple`, but in Rust 2021, it only captures `tuple.0`
...
LL |         }
   |         - in Rust 2018, `tuple` would be dropped here, but in Rust 2021, only `tuple.0` would be dropped here alongside the closure
```

The auto trait migration lint will now look something like this:
```
error: changes to closure capture in Rust 2021 will affect `Send` trait implementation for closure
  --> $DIR/auto_traits.rs:14:19
   |
LL |     thread::spawn(move || unsafe {
   |                   ^^^^^^^^^^^^^^ in Rust 2018, this closure would implement `Send` as `fptr` implements `Send`, but in Rust 2021, this closure would no longer implement `Send` as `fptr.0` does not implement `Send`
...
LL |         *fptr.0 = 20;
   |         ------- in Rust 2018, closure captures all of `fptr`, but in Rust 2021, it only captures `fptr.0`
```

r? `@nikomatsakis`

Closes https://github.com/rust-lang/project-rfc-2229/issues/54

3 years agoAuto merge of #86416 - Amanieu:asm_clobber_only, r=nagisa
bors [Sun, 11 Jul 2021 01:06:58 +0000 (01:06 +0000)]
Auto merge of #86416 - Amanieu:asm_clobber_only, r=nagisa

Add clobber-only register classes for asm!

These are needed to properly express a function call ABI using a clobber
list, even though we don't support passing actual values into/out of
these registers.

3 years agoAuto merge of #85953 - inquisitivecrystal:weak-linkat-in-fs-hardlink, r=joshtriplett
bors [Sat, 10 Jul 2021 21:42:40 +0000 (21:42 +0000)]
Auto merge of #85953 - inquisitivecrystal:weak-linkat-in-fs-hardlink, r=joshtriplett

Fix linker error

Currently, `fs::hard_link` determines whether platforms have `linkat` based on the OS, and uses `link` if they don't. However, this heuristic does not work well if a platform provides `linkat` on newer versions but not on older ones. On old MacOS, this currently causes a linking error.

This commit fixes `fs::hard_link` by telling it to use `weak!` on macOS. This means that, on  that operating system, we now check for `linkat` at runtime and use `link` if it is not available.

Fixes #80804.

`@rustbot` label T-libs-impl

3 years agorustc_span: Reorder some `ExpnData` fields in accordance with comments
Vadim Petrochenkov [Sat, 10 Jul 2021 21:40:25 +0000 (00:40 +0300)]
rustc_span: Reorder some `ExpnData` fields in accordance with comments

A drive-by change.

3 years agorustc_expand: Simplify span quoting in proc macro server
Vadim Petrochenkov [Sat, 10 Jul 2021 20:44:22 +0000 (23:44 +0300)]
rustc_expand: Simplify span quoting in proc macro server

- The `Rustc::expn_id` field kept redundant information
- `SyntaxContext` is no longer thrown away before `save_proc_macro_span` because it's thrown away during metadata encoding anyway

3 years agoChange all instance of optflag added since the original change to optflagmulti.
Zach Lute [Sat, 10 Jul 2021 21:32:14 +0000 (14:32 -0700)]
Change all instance of optflag added since the original change to optflagmulti.

3 years agoChange all 'optflag' arguments to 'optflagmulti'
Zach Lute [Wed, 1 Jul 2020 18:25:54 +0000 (11:25 -0700)]
Change all 'optflag' arguments to 'optflagmulti'

Because specifying these flags multiple times will never be discernibly different in functionality from specifying them a single time, there is no reason to fail and report an error to the user.

3 years agorustc_expand: Remove redundant field from proc macro expander structures
Vadim Petrochenkov [Sat, 10 Jul 2021 20:15:30 +0000 (23:15 +0300)]
rustc_expand: Remove redundant field from proc macro expander structures

This information is already available from `ExpnData`

3 years agorustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`
Vadim Petrochenkov [Sat, 10 Jul 2021 19:14:52 +0000 (22:14 +0300)]
rustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`

The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.

3 years agoMake tests pass on old macos
Aris Merchant [Tue, 6 Jul 2021 03:44:55 +0000 (20:44 -0700)]
Make tests pass on old macos

On old macos systems, `fs::hard_link()` will follow symlinks.
This changes the test `symlink_hard_link` to exit early on
these systems, so that tests can pass.

3 years agoChange `weak!` and `linkat!` to macros 2.0
Aris Merchant [Tue, 6 Jul 2021 03:28:10 +0000 (20:28 -0700)]
Change `weak!` and `linkat!` to macros 2.0

`weak!` is needed in a test in another module. With macros
1.0, importing `weak!` would require reordering module
declarations in `std/src/lib.rs`, which is a bit too
evil.

3 years agoAuto merge of #86873 - nikic:opaque-ptrs, r=nagisa
bors [Sat, 10 Jul 2021 19:01:41 +0000 (19:01 +0000)]
Auto merge of #86873 - nikic:opaque-ptrs, r=nagisa

Improve opaque pointers support

Opaque pointers are coming, and rustc is not ready.

This adds partial support by passing an explicit load type to LLVM. Two issues I've encountered:
 * The necessary type was not available at the point where non-temporal copies were generated. I've pushed the code for that upwards out of the memcpy implementation and moved the position of a cast to make do with the types we have available. (I'm not sure that cast is needed at all, but have retained it in the interest of conservativeness.)
 * The `PlaceRef::project_deref()` function used during debuginfo generation seems to be buggy in some way -- though I haven't figured out specifically what it does wrong. Replacing it with `load_operand().deref()` did the trick, but I don't really know what I'm doing here.

3 years agoAuto merge of #87029 - JohnTitor:rollup-0yapv7z, r=JohnTitor
bors [Sat, 10 Jul 2021 16:41:26 +0000 (16:41 +0000)]
Auto merge of #87029 - JohnTitor:rollup-0yapv7z, r=JohnTitor

Rollup of 5 pull requests

Successful merges:

 - #87006 (Revert the revert of renaming traits::VTable to ImplSource)
 - #87011 (avoid reentrant lock acquire when ThreadIds run out)
 - #87013 (Fix several ICEs related to malformed `#[repr(...)]` attributes)
 - #87020 (remove const_raw_ptr_to_usize_cast feature)
 - #87028 (Fix type: `'satic` -> `'static`)

Failed merges:

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

3 years agoRollup merge of #87028 - aDotInTheVoid:patch-1, r=petrochenkov
Yuki Okushi [Sat, 10 Jul 2021 16:15:43 +0000 (01:15 +0900)]
Rollup merge of #87028 - aDotInTheVoid:patch-1, r=petrochenkov

Fix type: `'satic` -> `'static`

Pointed out on discord: https://discord.com/channels/273534239310479360/490356824420122645/863434443170250793

~~The fact that this compiles is probably a bug.~~ Nope it's `#![feature(in_band_lifetimes)]` (Thanks to [floppy](https://discord.com/channels/273534239310479360/490356824420122645/863437381671059486)

~~[The docs](https://doc.rust-lang.org/stable/nightly-rustc/rustc_mir/transform/inline/struct.Inliner.html#method.check_codegen_attributes) seem to indicate rust thinks this function is generic over the lifetime `'satic`~~ This is because of `in_band_lifetimes`

3 years agoRollup merge of #87020 - RalfJung:const_raw_ptr_to_usize_cast, r=oli-obk
Yuki Okushi [Sat, 10 Jul 2021 16:15:42 +0000 (01:15 +0900)]
Rollup merge of #87020 - RalfJung:const_raw_ptr_to_usize_cast, r=oli-obk

remove const_raw_ptr_to_usize_cast feature

This feature currently has the strange status of "const-only `unsafe`", which was an experiment that we no longer think is a good idea. We need to find better ways to enable things like "messing with the low bits of a pointer" during CTFE.

r? `@oli-obk`

3 years agoRollup merge of #87013 - FabianWolff:issue-83921, r=estebank
Yuki Okushi [Sat, 10 Jul 2021 16:15:41 +0000 (01:15 +0900)]
Rollup merge of #87013 - FabianWolff:issue-83921, r=estebank

Fix several ICEs related to malformed `#[repr(...)]` attributes

This PR fixes #83921. #83921 actually contains two related but distinct issues (one of them incorrectly reported as a duplicate in https://github.com/rust-lang/rust/issues/83921#issuecomment-814640734):

In the first, a call to `delay_span_bug` leads to an ICE when compiling with `-Zunpretty=everybody_loops` (and some other pretty-printing modes), because the corresponding error is emitted in a later pass, which does not run when only pretty-printing is requested.

The second issue is about parsing `#[repr(...)]` attributes. Currently, all of the following cause an ICE when applied to a struct/enum:
```rust
#[repr(packed())]
#[repr(align)]
#[repr(align(2, 4))]
#[repr(align())]
#[repr(i8())]
#[repr(u32(42))]
#[repr(i64 = 2)]
```
I have fixed this by expanding the well-formedness checks in `find_repr_attrs()`.

3 years agoRollup merge of #87011 - RalfJung:thread-id-supply-shortage, r=nagisa
Yuki Okushi [Sat, 10 Jul 2021 16:15:40 +0000 (01:15 +0900)]
Rollup merge of #87011 - RalfJung:thread-id-supply-shortage, r=nagisa

avoid reentrant lock acquire when ThreadIds run out

Discovered by `@bjorn3`

3 years agoRollup merge of #87006 - ptrojahn:implsource_vtable, r=jonas-schievink
Yuki Okushi [Sat, 10 Jul 2021 16:15:39 +0000 (01:15 +0900)]
Rollup merge of #87006 - ptrojahn:implsource_vtable, r=jonas-schievink

Revert the revert of renaming traits::VTable to ImplSource

As #72114 and #73055 were merged so closely together I think this
accidentally happened while rebasing

3 years agoAdd AArch64 z* registers as aliases for v* registers
Amanieu d'Antras [Sat, 10 Jul 2021 15:29:07 +0000 (17:29 +0200)]
Add AArch64 z* registers as aliases for v* registers

3 years agoAdd clobber-only register classes for asm!
Amanieu d'Antras [Thu, 17 Jun 2021 20:00:52 +0000 (21:00 +0100)]
Add clobber-only register classes for asm!

These are needed to properly express a function call ABI using a clobber
list, even though we don't support passing actual values into/out of
these registers.

3 years agoFix typo: `satic` -> `static`
Nixon Enraght-Moony [Sat, 10 Jul 2021 15:06:24 +0000 (16:06 +0100)]
Fix typo: `satic` -> `static`

3 years agoAuto merge of #81360 - Aaron1011:trait-caller-loc, r=nagisa
bors [Sat, 10 Jul 2021 14:11:39 +0000 (14:11 +0000)]
Auto merge of #81360 - Aaron1011:trait-caller-loc, r=nagisa

Support forwarding caller location through trait object method call

Since PR #69251, the `#[track_caller]` attribute has been supported on
traits. However, it only has an effect on direct (monomorphized) method
calls. Calling a `#[track_caller]` method on a trait object will *not*
propagate caller location information - instead, `Location::caller()` will
return the location of the method definition.

This PR forwards caller location information when `#[track_caller]` is
present on the method definition in the trait. This is possible because
`#[track_caller]` in this position is 'inherited' by any impls of that
trait, so all implementations will have the same ABI.

This PR does *not* change the behavior in the case where
`#[track_caller]` is present only on the impl of a trait.
While all implementations of the method might have an explicit
`#[track_caller]`, we cannot know this at codegen time, since other
crates may have impls of the trait. Therefore, we keep the current
behavior of not forwarding the caller location, ensuring that all
implementations of the trait will have the correct ABI.

See the modified test for examples of how this works

3 years agorename variable
Ralf Jung [Sat, 10 Jul 2021 12:14:09 +0000 (14:14 +0200)]
rename variable

3 years agoremove duplicate test
Ralf Jung [Sat, 10 Jul 2021 11:48:44 +0000 (13:48 +0200)]
remove duplicate test

3 years agobless missing tests
Ralf Jung [Sat, 10 Jul 2021 11:03:35 +0000 (13:03 +0200)]
bless missing tests

3 years agoremove const_raw_ptr_to_usize_cast feature
Ralf Jung [Sat, 10 Jul 2021 09:33:42 +0000 (11:33 +0200)]
remove const_raw_ptr_to_usize_cast feature

3 years agoavoid reentrant lock acquire when ThreadIds run out
Ralf Jung [Fri, 9 Jul 2021 18:50:08 +0000 (20:50 +0200)]
avoid reentrant lock acquire when ThreadIds run out

3 years agoUpdate docs for `fs::hard_link`
Aris Merchant [Wed, 7 Jul 2021 07:23:29 +0000 (00:23 -0700)]
Update docs for `fs::hard_link`

3 years agoFix linker error
Aris Merchant [Thu, 3 Jun 2021 05:53:03 +0000 (22:53 -0700)]
Fix linker error

This makes `fs::hard_link` use weak! for some platforms,
thereby preventing a linker error.

3 years agoAuto merge of #86987 - lcnr:const-default-eval-bound, r=oli-obk
bors [Sat, 10 Jul 2021 06:01:04 +0000 (06:01 +0000)]
Auto merge of #86987 - lcnr:const-default-eval-bound, r=oli-obk

only check cg defaults wf once instantiated

the previous fixmes here didn't make too much sense as I didn't yet fully understand the code further below.
That code only runs if the predicates using our generic param default are fully concrete after substituting our default, which never happens if our default is generic.

r? `@oli-obk` `@BoxyUwU`

3 years agoAuto merge of #86968 - inquisitivecrystal:missing-docs-v2, r=oli-obk
bors [Sat, 10 Jul 2021 03:32:42 +0000 (03:32 +0000)]
Auto merge of #86968 - inquisitivecrystal:missing-docs-v2, r=oli-obk

Remove `missing_docs` lint on private 2.0 macros

https://github.com/rust-lang/rust/blob/798baebde1fe77e5a660490ec64e727a5d79970d/compiler/rustc_lint/src/builtin.rs#L573-L584

This code is the source of #57569. The problem is subtle, so let me point it out. This code makes the mistake of assuming that all of the macros in `krate.exported_macros` are exported.

...Yeah. For some historical reason, all `macro` macros are marked as exported, regardless of whether they actually are, which is dreadfully confusing. It would be more accurate to say that `exported_macros` currently contains only macros that have paths.

This PR renames `exported_macros` to `importable_macros`, since these macros can be imported with `use` while others cannot. It also fixes the code above to no longer lint on private `macro` macros, since the `missing_docs` lint should only appear on exported items.

Fixes #57569.

3 years agoAuto merge of #86419 - ricobbe:raw-dylib-stdcall, r=petrochenkov
bors [Fri, 9 Jul 2021 23:24:21 +0000 (23:24 +0000)]
Auto merge of #86419 - ricobbe:raw-dylib-stdcall, r=petrochenkov

Add support for raw-dylib with stdcall, fastcall functions

Next stage of work for #58713: allow `extern "stdcall"` and `extern "fastcall"` with `#[link(kind = "raw-dylib")]`.

I've deliberately omitted support for vectorcall, as that doesn't currently work, and I wanted to get this out for review.  (I haven't really investigated the vectorcall failure much yet, but at first (very cursory) glance it appears that the problem is elsewhere.)

3 years agoAuto merge of #85263 - Smittyvb:thir-unsafeck-union-field, r=oli-obk
bors [Fri, 9 Jul 2021 20:56:07 +0000 (20:56 +0000)]
Auto merge of #85263 - Smittyvb:thir-unsafeck-union-field, r=oli-obk

Check for union field accesses in THIR unsafeck

see also #85259, #83129, https://github.com/rust-lang/project-thir-unsafeck/issues/7

r? `@LeSeulArtichaut`

3 years agoDon't access pointer element type for nontemporal store
Nikita Popov [Tue, 6 Jul 2021 19:55:03 +0000 (21:55 +0200)]
Don't access pointer element type for nontemporal store

Simply shift the bitcast from the store to the load, so that
we can use the destination type. I'm not sure the bitcast is
really necessary, but keeping it for now.

3 years agoFix project_deref() implementation
Nikita Popov [Sun, 4 Jul 2021 21:07:37 +0000 (23:07 +0200)]
Fix project_deref() implementation

I'm not really sure what is wrong here, but I was getting load
type mismatches in the debuginfo code (which is the only place
using this function).

Replacing the project_deref() implementation with a generic
load_operand + deref did the trick.

3 years agoPass type when creating load
Nikita Popov [Sun, 4 Jul 2021 16:53:04 +0000 (18:53 +0200)]
Pass type when creating load

This makes load generation compatible with opaque pointers.

The generation of nontemporal copies still accesses the pointer
element type, as fixing this requires more movement.

3 years agoEnhance well-formedness checks for `#[repr(...)]` attributes
Fabian Wolff [Fri, 9 Jul 2021 20:03:48 +0000 (22:03 +0200)]
Enhance well-formedness checks for `#[repr(...)]` attributes

3 years agoPass type when creating atomic load
Nikita Popov [Sun, 4 Jul 2021 15:49:51 +0000 (17:49 +0200)]
Pass type when creating atomic load

Instead of determining it from the pointer type, explicitly pass
the type to load.

3 years agopanic when trying to destructure union as enum
Smitty [Fri, 9 Jul 2021 19:22:12 +0000 (15:22 -0400)]
panic when trying to destructure union as enum

3 years agoApply suggestions from code review
Aman Arora [Fri, 9 Jul 2021 17:45:26 +0000 (13:45 -0400)]
Apply suggestions from code review

Co-authored-by: Niko Matsakis <niko@alum.mit.edu>
3 years agoAdd support for raw-dylib with stdcall, fastcall functions on i686-pc-windows-msvc.
Richard Cobbe [Tue, 8 Jun 2021 20:56:06 +0000 (13:56 -0700)]
Add support for raw-dylib with stdcall, fastcall functions on i686-pc-windows-msvc.

3 years agoAuto merge of #85832 - kornelski:raw_arg, r=yaahc
bors [Fri, 9 Jul 2021 18:15:20 +0000 (18:15 +0000)]
Auto merge of #85832 - kornelski:raw_arg, r=yaahc

Unescaped command-line arguments for Windows

Some Windows commands, expecially `cmd.exe /c`, have unusual quoting requirements which are incompatible with default rules assumed for `.arg()`.

This adds `.unquoted_arg()` to `Command` via Windows `CommandExt` trait.

Fixes #29494

3 years agoDon't stub out part of test
Smitty [Tue, 25 May 2021 14:35:24 +0000 (10:35 -0400)]
Don't stub out part of test

3 years agoCheck for union field accesses in THIR unsafeck
Smitty [Thu, 13 May 2021 14:42:25 +0000 (10:42 -0400)]
Check for union field accesses in THIR unsafeck

3 years agoEnsure deterministic ordering for diagnostics
Roxane [Fri, 9 Jul 2021 17:32:30 +0000 (13:32 -0400)]
Ensure deterministic ordering for diagnostics

3 years agoRevert the revert of renaming traits::VTable to ImplSource
Paul Trojahn [Fri, 9 Jul 2021 16:26:28 +0000 (18:26 +0200)]
Revert the revert of renaming traits::VTable to ImplSource

As #72114 and #73055 were merged so closely together I think this
accidentally happened while rebasing

3 years agoAuto merge of #87003 - m-ou-se:rollup-x7mhv3v, r=m-ou-se
bors [Fri, 9 Jul 2021 15:34:16 +0000 (15:34 +0000)]
Auto merge of #87003 - m-ou-se:rollup-x7mhv3v, r=m-ou-se

Rollup of 5 pull requests

Successful merges:

 - #86855 (Fix comments about unique borrows)
 - #86881 (Inline implementation of lookup_line)
 - #86937 (Change linked tracking issue for more_qualified_paths)
 - #86994 (Update the comment on `lower_expr_try`)
 - #87000 (Use #[track_caller] in const panic diagnostics.)

Failed merges:

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

3 years agoRollup merge of #87000 - m-ou-se:const-panic-track-caller, r=oli-obk
Mara Bos [Fri, 9 Jul 2021 14:20:36 +0000 (16:20 +0200)]
Rollup merge of #87000 - m-ou-se:const-panic-track-caller, r=oli-obk

Use #[track_caller] in const panic diagnostics.

This change stops const panic diagnostics from reporting inside #[track_caller] functions by skipping over them.

3 years agoRollup merge of #86994 - scottmcm:fix_expr_try_comment, r=petrochenkov
Mara Bos [Fri, 9 Jul 2021 14:20:35 +0000 (16:20 +0200)]
Rollup merge of #86994 - scottmcm:fix_expr_try_comment, r=petrochenkov

Update the comment on `lower_expr_try`

I'd updated the ones inside the method, but not its doc comment.

3 years agoRollup merge of #86937 - rylev:tracking-more-qualified-paths, r=nagisa
Mara Bos [Fri, 9 Jul 2021 14:20:33 +0000 (16:20 +0200)]
Rollup merge of #86937 - rylev:tracking-more-qualified-paths, r=nagisa

Change linked tracking issue for more_qualified_paths

This updates the linked tracking issue for the `more_qualified_paths` feature from the implementation PR #80080 to an actual tracking issue #86935.

3 years agoRollup merge of #86881 - tmiasko:lookup-line, r=nagisa
Mara Bos [Fri, 9 Jul 2021 14:20:32 +0000 (16:20 +0200)]
Rollup merge of #86881 - tmiasko:lookup-line, r=nagisa

Inline implementation of lookup_line

to avoid unnecessary conversions from `Option<usize>` to `isize` and back.

3 years agoRollup merge of #86855 - LeSeulArtichaut:patch-1, r=davidtwco
Mara Bos [Fri, 9 Jul 2021 14:20:32 +0000 (16:20 +0200)]
Rollup merge of #86855 - LeSeulArtichaut:patch-1, r=davidtwco

Fix comments about unique borrows

3 years agoAddress comments
Roxane [Fri, 9 Jul 2021 14:18:55 +0000 (10:18 -0400)]
Address comments

3 years agoHandle multi diagnostics
Roxane [Thu, 8 Jul 2021 21:04:58 +0000 (17:04 -0400)]
Handle multi diagnostics

3 years agoUpdate comments
Roxane [Wed, 7 Jul 2021 23:08:04 +0000 (19:08 -0400)]
Update comments

3 years agoFix wording
Roxane [Wed, 7 Jul 2021 22:47:32 +0000 (18:47 -0400)]
Fix wording

3 years agoAdd note clarifying why a closure no longer implements a trait
Roxane [Wed, 7 Jul 2021 15:04:28 +0000 (11:04 -0400)]
Add note clarifying why a closure no longer implements a trait

3 years agoAdd note pointing to where a closure and it's captured variables are dropped
Roxane [Wed, 7 Jul 2021 14:29:06 +0000 (10:29 -0400)]
Add note pointing to where a closure and it's captured variables are dropped

3 years agoUpdate error message
Roxane [Tue, 6 Jul 2021 20:49:07 +0000 (16:49 -0400)]
Update error message

3 years agoAdd note on why the variable is not fully captured
Roxane [Tue, 6 Jul 2021 20:48:49 +0000 (16:48 -0400)]
Add note on why the variable is not fully captured

3 years agoDebug formatting of raw_arg()
Kornel [Fri, 9 Jul 2021 13:20:01 +0000 (14:20 +0100)]
Debug formatting of raw_arg()

3 years agoUse #[track_caller] in const panic diagnostics.
Mara Bos [Fri, 9 Jul 2021 13:21:58 +0000 (15:21 +0200)]
Use #[track_caller] in const panic diagnostics.

It was already used for the message. This also uses it for the spans
used for the error and backtrace.

3 years agoUse AsRef in CommandExt for raw_arg
Kornel [Sun, 4 Jul 2021 23:05:46 +0000 (00:05 +0100)]
Use AsRef in CommandExt for raw_arg

3 years agoUnescaped command-line arguments for Windows
Kornel [Sun, 30 May 2021 16:01:02 +0000 (17:01 +0100)]
Unescaped command-line arguments for Windows

Fixes #29494

3 years agoTest escaping of trialing slashes in Windows command-line args
Kornel [Sun, 4 Jul 2021 17:33:15 +0000 (18:33 +0100)]
Test escaping of trialing slashes in Windows command-line args

3 years agoAuto merge of #86888 - FabianWolff:issue-86600, r=davidtwco
bors [Fri, 9 Jul 2021 12:51:02 +0000 (12:51 +0000)]
Auto merge of #86888 - FabianWolff:issue-86600, r=davidtwco

Fix double warning about illegal floating-point literal pattern

This PR fixes #86600. The problem is that the `ConstToPat` struct contains a field `include_lint_checks`, which determines whether lints should be emitted or not, but this field is currently not obeyed at one point, leading to a warning being emitted more than once. I have fixed this behavior here.

3 years agoAuto merge of #85828 - scottmcm:raw-eq, r=oli-obk
bors [Fri, 9 Jul 2021 09:16:27 +0000 (09:16 +0000)]
Auto merge of #85828 - scottmcm:raw-eq, r=oli-obk

Stop generating `alloca`s & `memcmp` for simple short array equality

Example:
```rust
pub fn demo(x: [u16; 6], y: [u16; 6]) -> bool { x == y }
```

Before:
```llvm
define zeroext i1 `@_ZN10playground4demo17h48537f7eac23948fE(i96` %0, i96 %1) unnamed_addr #0 {
start:
  %y = alloca [6 x i16], align 8
  %x = alloca [6 x i16], align 8
  %.0..sroa_cast = bitcast [6 x i16]* %x to i96*
  store i96 %0, i96* %.0..sroa_cast, align 8
  %.0..sroa_cast3 = bitcast [6 x i16]* %y to i96*
  store i96 %1, i96* %.0..sroa_cast3, align 8
  %_11.i.i.i = bitcast [6 x i16]* %x to i8*
  %_14.i.i.i = bitcast [6 x i16]* %y to i8*
  %bcmp.i.i.i = call i32 `@bcmp(i8*` nonnull dereferenceable(12) %_11.i.i.i, i8* nonnull dereferenceable(12) %_14.i.i.i, i64 12) #2, !alias.scope !2
  %2 = icmp eq i32 %bcmp.i.i.i, 0
  ret i1 %2
}
```
```x86
playground::demo: # `@playground::demo`
sub rsp, 32
mov qword ptr [rsp], rdi
mov dword ptr [rsp + 8], esi
mov qword ptr [rsp + 16], rdx
mov dword ptr [rsp + 24], ecx
xor rdi, rdx
xor esi, ecx
or rsi, rdi
sete al
add rsp, 32
ret
```

After:
```llvm
define zeroext i1 `@_ZN4mini4demo17h7a8994aaa314c981E(i96` %0, i96 %1) unnamed_addr #0 {
start:
  %2 = icmp eq i96 %0, %1
  ret i1 %2
}
```
```x86
_ZN4mini4demo17h7a8994aaa314c981E:
xor rcx, r8
xor edx, r9d
or rdx, rcx
sete al
ret
```

3 years agoAdd more tests
Aman Arora [Fri, 9 Jul 2021 08:34:11 +0000 (04:34 -0400)]
Add more tests

3 years agoMove optimization to the central processing function
Aman Arora [Fri, 9 Jul 2021 07:55:03 +0000 (03:55 -0400)]
Move optimization to the central processing function

3 years agoCleanup and code comments
Aman Arora [Fri, 9 Jul 2021 06:37:37 +0000 (02:37 -0400)]
Cleanup and code comments

3 years agoRewrite closure capture analysis
Aman Arora [Fri, 9 Jul 2021 04:25:41 +0000 (00:25 -0400)]
Rewrite closure capture analysis

3 years agoUpdate the comment on `lower_expr_try`
Scott McMurray [Fri, 9 Jul 2021 07:13:44 +0000 (00:13 -0700)]
Update the comment on `lower_expr_try`

I'd updated the ones inside the method, but not its doc comment.

3 years agoAuto merge of #86904 - m-ou-se:prelude-collision-check-trait, r=nikomatsakis
bors [Fri, 9 Jul 2021 06:35:42 +0000 (06:35 +0000)]
Auto merge of #86904 - m-ou-se:prelude-collision-check-trait, r=nikomatsakis

Check FromIterator trait impl in prelude collision check.

Fixes #86902.

3 years agoImprove handing of `missing_docs` for macros
inquisitivecrystal [Fri, 9 Jul 2021 05:39:31 +0000 (22:39 -0700)]
Improve handing of `missing_docs` for macros

3 years agoAdd regression test
inquisitivecrystal [Thu, 8 Jul 2021 00:55:09 +0000 (17:55 -0700)]
Add regression test

3 years agoRemove `missing_docs` lint on private 2.0 macros
inquisitivecrystal [Thu, 8 Jul 2021 00:42:03 +0000 (17:42 -0700)]
Remove `missing_docs` lint on private 2.0 macros

3 years agoAuto merge of #86869 - sexxi-goose:rfc2229-migration-capture-kind, r=nikomatsakis
bors [Fri, 9 Jul 2021 03:54:41 +0000 (03:54 +0000)]
Auto merge of #86869 - sexxi-goose:rfc2229-migration-capture-kind, r=nikomatsakis

Account for capture kind in auto traits migration

Modifies the current auto traits migration for RFC2229 so it takes into account capture kind

Closes https://github.com/rust-lang/project-rfc-2229/issues/51

r? `@nikomatsakis`

3 years agoAuto merge of #86701 - sexxi-goose:optimization, r=nikomatsakis
bors [Fri, 9 Jul 2021 01:13:49 +0000 (01:13 +0000)]
Auto merge of #86701 - sexxi-goose:optimization, r=nikomatsakis

2229: Reduce the size of closures with `capture_disjoint_fields`

One key observation while going over the closure size profile of rustc
was that we are disjointly capturing one or more fields starting at an
immutable reference.

Disjoint capture over immutable reference doesn't add too much value
because the fields can either be borrowed immutably or copied.

One possible edge case of the optimization is when a fields of a struct
have a longer lifetime than the structure, therefore we can't completely
get rid of all the accesses on top of sharef refs, only the rightmost
one. Here is a possible example:

```rust
struct MyStruct<'a> {
   a: &'static A,
   b: B,
   c: C<'a>,
}

fn foo<'a, 'b>(m: &'a MyStruct<'b>) -> impl FnMut() + 'static {
    let c = || drop(&*m.a.field_of_a);
    // Here we really do want to capture `*m.a` because that outlives `'static`

    // If we capture `m`, then the closure no longer outlives `'static'
    // it is constrained to `'a`
}
```

r? `@nikomatsakis`

3 years agoBless a UI test
Scott McMurray [Thu, 8 Jul 2021 22:16:37 +0000 (15:16 -0700)]
Bless a UI test

3 years agoAdjust the threshold to look at the ABI, not just the size
Scott McMurray [Thu, 3 Jun 2021 06:35:30 +0000 (23:35 -0700)]
Adjust the threshold to look at the ABI, not just the size

3 years agoUse cranelift's `Type::int` instead of doing the match myself
Scott McMurray [Tue, 1 Jun 2021 13:19:49 +0000 (06:19 -0700)]
Use cranelift's `Type::int` instead of doing the match myself

<https://docs.rs/cranelift-codegen/0.74.0/cranelift_codegen/ir/types/struct.Type.html#method.int>

3 years agoPR Feedback: Don't put SSA-only types in `CValue`s
Scott McMurray [Mon, 31 May 2021 17:26:08 +0000 (10:26 -0700)]
PR Feedback: Don't put SSA-only types in `CValue`s

3 years agoAdd another codegen test, array_eq_zero
Scott McMurray [Mon, 31 May 2021 04:27:29 +0000 (21:27 -0700)]
Add another codegen test, array_eq_zero

Showing that this avoids an alloca and private constant.

3 years agoImplement the raw_eq intrinsic in codegen_cranelift
Scott McMurray [Mon, 31 May 2021 01:04:07 +0000 (18:04 -0700)]
Implement the raw_eq intrinsic in codegen_cranelift

3 years agoPR feedback
Scott McMurray [Sun, 30 May 2021 18:31:56 +0000 (11:31 -0700)]
PR feedback

- Add `:Sized` assertion in interpreter impl
- Use `Scalar::from_bool` instead of `ScalarInt: From<bool>`
- Remove unneeded comparison in intrinsic typeck
- Make this UB to call with undef, not just return undef in that case

3 years agoStop generating `alloca`s+`memcmp` for simple array equality
Scott McMurray [Sun, 30 May 2021 17:25:41 +0000 (10:25 -0700)]
Stop generating `alloca`s+`memcmp` for simple array equality

3 years agoMove the `PartialEq` and `Eq` impls for arrays to a separate file
Scott McMurray [Sun, 30 May 2021 17:23:50 +0000 (10:23 -0700)]
Move the `PartialEq` and `Eq` impls for arrays to a separate file

3 years agoInline implementation of lookup_line
Tomasz Miąsko [Mon, 5 Jul 2021 00:00:00 +0000 (00:00 +0000)]
Inline implementation of lookup_line

to simplify the implementation and avoid unnecessary
conversions from `Option<usize>` to `isize` and back.

3 years agoConsider capture kind for auto traits migration
Roxane [Sat, 3 Jul 2021 19:29:09 +0000 (15:29 -0400)]
Consider capture kind for auto traits migration

3 years agoAdd new test case
Roxane [Sat, 3 Jul 2021 18:39:10 +0000 (14:39 -0400)]
Add new test case

3 years agoonly check cg defaults wf once instantiated
lcnr [Thu, 8 Jul 2021 20:57:10 +0000 (22:57 +0200)]
only check cg defaults wf once instantiated

3 years agoAuto merge of #86930 - tspiteri:int_log10, r=kennytm
bors [Thu, 8 Jul 2021 20:19:00 +0000 (20:19 +0000)]
Auto merge of #86930 - tspiteri:int_log10, r=kennytm

special case for integer log10

Now that #80918 has been merged, this PR provides a faster version of `log10`.

The PR also adds some tests for values close to all powers of 10.