]> git.lizzy.rs Git - rust.git/log
rust.git
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 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 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 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 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 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 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.

3 years agoAuto merge of #86982 - GuillaumeGomez:rollup-7sbye3c, r=GuillaumeGomez
bors [Thu, 8 Jul 2021 17:51:10 +0000 (17:51 +0000)]
Auto merge of #86982 - GuillaumeGomez:rollup-7sbye3c, r=GuillaumeGomez

Rollup of 8 pull requests

Successful merges:

 - #84961 (Rework SESSION_GLOBALS API)
 - #86726 (Use diagnostic items instead of lang items for rfc2229 migrations)
 - #86789 (Update BTreeSet::drain_filter documentation)
 - #86838 (Checking that function is const if marked with rustc_const_unstable)
 - #86903 (Fix small headers display)
 - #86913 (Document rustdoc with `--document-private-items`)
 - #86957 (Update .mailmap file)
 - #86971 (mailmap: Add alternative addresses for myself)

Failed merges:

 - #86869 (Account for capture kind in auto traits migration)

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

3 years agoUpdate src/test/ui/rust-2021/future-prelude-collision-unneeded.rs
Niko Matsakis [Thu, 8 Jul 2021 16:31:56 +0000 (12:31 -0400)]
Update src/test/ui/rust-2021/future-prelude-collision-unneeded.rs

3 years agoRollup merge of #86971 - ijackson:mailmap, r=Mark-Simulacrum
Guillaume Gomez [Thu, 8 Jul 2021 16:30:41 +0000 (18:30 +0200)]
Rollup merge of #86971 - ijackson:mailmap, r=Mark-Simulacrum

mailmap: Add alternative addresses for myself

At least one of these is already in-tree; it seems plausible that the others might appear too.

3 years agoRollup merge of #86957 - jhpratt:update-mailmap, r=jyn514
Guillaume Gomez [Thu, 8 Jul 2021 16:30:40 +0000 (18:30 +0200)]
Rollup merge of #86957 - jhpratt:update-mailmap, r=jyn514

Update .mailmap file

3 years agoRollup merge of #86913 - Stupremee:document-rustdoc-private-items, r=jyn514
Guillaume Gomez [Thu, 8 Jul 2021 16:30:39 +0000 (18:30 +0200)]
Rollup merge of #86913 - Stupremee:document-rustdoc-private-items, r=jyn514

Document rustdoc with `--document-private-items`

The `tool_doc` macro introduced in #86737 did not use `false` as the default value for `binary` when it is not provided, so the `if` is not even expanded and thus the argument is never provided if the `binary` argument isn't.

Resolves #86900

r? ```@Mark-Simulacrum```

3 years agoRollup merge of #86903 - GuillaumeGomez:small-header-display, r=Nemo157
Guillaume Gomez [Thu, 8 Jul 2021 16:30:38 +0000 (18:30 +0200)]
Rollup merge of #86903 - GuillaumeGomez:small-header-display, r=Nemo157

Fix small headers display

You can see it on the `IoSlice` or on the `ErrorKind` pages.

Before:

![Screenshot from 2021-07-06 15-26-33](https://user-images.githubusercontent.com/3050060/124610344-b50a8100-de70-11eb-8ab4-ac5de8adf18f.png)
![Screenshot from 2021-07-08 17-51-43](https://user-images.githubusercontent.com/3050060/124953436-7235de00-e015-11eb-9f99-b361c7eb41a9.png)

After:

![Screenshot from 2021-07-08 17-48-42](https://user-images.githubusercontent.com/3050060/124953042-12d7ce00-e015-11eb-8132-1ae4552dd969.png)
![Screenshot from 2021-07-08 17-48-47](https://user-images.githubusercontent.com/3050060/124953052-13706480-e015-11eb-89f8-dab96c2f0f63.png)

r? `@Nemo157`

3 years agoRollup merge of #86838 - lambinoo:I-69630-rust_const_unstable_check_const, r=oli-obk
Guillaume Gomez [Thu, 8 Jul 2021 16:30:34 +0000 (18:30 +0200)]
Rollup merge of #86838 - lambinoo:I-69630-rust_const_unstable_check_const, r=oli-obk

Checking that function is const if marked with rustc_const_unstable

Fixes #69630

This one is still missing tests to check the behavior but I checked by hand and it seemed to work.
I would not mind some direction for writing those unit tests!

3 years agoRollup merge of #86789 - janikrabe:btreeset-drainfilter-doc, r=kennytm
Guillaume Gomez [Thu, 8 Jul 2021 16:30:34 +0000 (18:30 +0200)]
Rollup merge of #86789 - janikrabe:btreeset-drainfilter-doc, r=kennytm

Update BTreeSet::drain_filter documentation

This commit makes the documentation of `BTreeSet::drain_filter` more
consistent with that of `BTreeMap::drain_filter` after the changes in
f0b8166870bd73a872642f090ae6b88e2bef922a.

In particular, this explicitly documents the iteration order.

3 years agoRollup merge of #86726 - sexxi-goose:use-diagnostic-item-for-rfc2229-migration, r...
Guillaume Gomez [Thu, 8 Jul 2021 16:30:33 +0000 (18:30 +0200)]
Rollup merge of #86726 - sexxi-goose:use-diagnostic-item-for-rfc2229-migration, r=nikomatsakis

Use diagnostic items instead of lang items for rfc2229 migrations

This PR removes the `Send`, `UnwindSafe` and `RefUnwindSafe` lang items introduced in https://github.com/rust-lang/rust/pull/84730, and uses diagnostic items instead to check for `Send`, `UnwindSafe` and `RefUnwindSafe` traits for RFC2229 migrations.

r? ```@nikomatsakis```

3 years agoRollup merge of #84961 - GuillaumeGomez:rework-session-globals, r=oli-obk
Guillaume Gomez [Thu, 8 Jul 2021 16:30:32 +0000 (18:30 +0200)]
Rollup merge of #84961 - GuillaumeGomez:rework-session-globals, r=oli-obk

Rework SESSION_GLOBALS API

Fixes #84954.

<s>Needs #84953 to be merged first (I cherry-picked its commits to have CI pass).</s> (done)

r? ``@Aaron1011``

3 years agoFix display of small-section-header elements
Guillaume Gomez [Thu, 8 Jul 2021 15:49:06 +0000 (17:49 +0200)]
Fix display of small-section-header elements

3 years agoUpdate to last upstream version
Guillaume Gomez [Thu, 8 Jul 2021 15:14:28 +0000 (17:14 +0200)]
Update to last upstream version

3 years agoAuto merge of #86520 - ssomers:btree_iterators_checked_unwrap, r=Mark-Simulacrum
bors [Thu, 8 Jul 2021 15:06:43 +0000 (15:06 +0000)]
Auto merge of #86520 - ssomers:btree_iterators_checked_unwrap, r=Mark-Simulacrum

BTree: consistently avoid unwrap_unchecked in iterators

Some iterator support functions named `_unchecked` internally use `unwrap`, some use `unwrap_unchecked`. This PR tries settling on `unwrap`. #86195 went up the same road but travelled way further and doesn't seem successful.

r? `@Mark-Simulacrum`

3 years agoRework SESSION_GLOBALS API to prevent overwriting it
Guillaume Gomez [Wed, 5 May 2021 19:31:25 +0000 (21:31 +0200)]
Rework SESSION_GLOBALS API to prevent overwriting it

3 years agoAuto merge of #85363 - EFanZh:gdb-pretty-print-slices, r=michaelwoerister
bors [Thu, 8 Jul 2021 12:25:47 +0000 (12:25 +0000)]
Auto merge of #85363 - EFanZh:gdb-pretty-print-slices, r=michaelwoerister

Support pretty printing slices using GDB

Support pretty printing `&[T]`, `&mut [T]` and `&mut str` types using GDB.

Support pretty printing `&mut [T]` and `&mut str` types using LLDB.

Fixes #85219.

3 years agomailmap: Add alternative addresses for myself
Ian Jackson [Thu, 8 Jul 2021 11:44:25 +0000 (12:44 +0100)]
mailmap: Add alternative addresses for myself

At least one of these is already in-tree; it seems plausible that
others might appear too.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoAuto merge of #86823 - the8472:opt-chunk-tra, r=kennytm
bors [Thu, 8 Jul 2021 09:44:52 +0000 (09:44 +0000)]
Auto merge of #86823 - the8472:opt-chunk-tra, r=kennytm

Optimize unchecked indexing into chunks and chunks_mut

Fixes #53340

```
# BEFORE

$ rustc +nightly -Copt-level=3 -Ccodegen-units=1 -Clto=fat chunks.rs
$ perf stat ./chunks

 Performance counter stats for './chunks':

          3,177.03 msec task-clock                #    1.000 CPUs utilized
                 4      context-switches          #    0.001 K/sec
                 0      cpu-migrations            #    0.000 K/sec
           984,006      page-faults               #    0.310 M/sec
    13,092,199,322      cycles                    #    4.121 GHz                      (83.29%)
       384,543,475      stalled-cycles-frontend   #    2.94% frontend cycles idle     (83.35%)
     7,414,280,722      stalled-cycles-backend    #   56.63% backend cycles idle      (83.38%)
    50,493,980,662      instructions              #    3.86  insn per cycle
                                                  #    0.15  stalled cycles per insn  (83.29%)
     6,625,375,297      branches                  # 2085.396 M/sec                    (83.38%)
         3,087,652      branch-misses             #    0.05% of all branches          (83.31%)

       3.178079469 seconds time elapsed

       2.327156000 seconds user
       0.762041000 seconds sys

# AFTER

$ ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc -Copt-level=3 -Ccodegen-units=1 -Clto=fat chunks.rs
$ perf stat ./chunks

 Performance counter stats for './chunks':

          2,705.76 msec task-clock                #    1.000 CPUs utilized
                 4      context-switches          #    0.001 K/sec
                 0      cpu-migrations            #    0.000 K/sec
           984,005      page-faults               #    0.364 M/sec
    11,156,763,039      cycles                    #    4.123 GHz                      (83.26%)
       342,198,882      stalled-cycles-frontend   #    3.07% frontend cycles idle     (83.37%)
     6,486,263,637      stalled-cycles-backend    #   58.14% backend cycles idle      (83.37%)
    40,553,476,617      instructions              #    3.63  insn per cycle
                                                  #    0.16  stalled cycles per insn  (83.37%)
     6,668,429,113      branches                  # 2464.532 M/sec                    (83.37%)
         3,099,636      branch-misses             #    0.05% of all branches          (83.26%)

       2.706725288 seconds time elapsed

       1.782083000 seconds user
       0.848424000 seconds sys
```

3 years agoFix typo in comment.
Mara Bos [Thu, 8 Jul 2021 09:33:33 +0000 (11:33 +0200)]
Fix typo in comment.

3 years agoAuto merge of #86949 - RalfJung:miri, r=RalfJung
bors [Thu, 8 Jul 2021 06:46:41 +0000 (06:46 +0000)]
Auto merge of #86949 - RalfJung:miri, r=RalfJung

update Miri

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

3 years agofn must be const if marked with stability attribut
Lamb [Sat, 3 Jul 2021 10:07:06 +0000 (12:07 +0200)]
fn must be const if marked with stability attribut

remove trailing newline

fix: test with attribute but missing const

Update compiler/rustc_passes/src/stability.rs

Co-authored-by: Léo Lanteri Thauvin <leseulartichaut@gmail.com>
Add test for extern functions

fix: using span_help instead of span_suggestion

add test for some ABIs + fmt fix

Update compiler/rustc_passes/src/stability.rs

Co-authored-by: Léo Lanteri Thauvin <leseulartichaut@gmail.com>
Refractor and add test for `impl const`

Add test to make sure no output + cleanup condition

-----------------------------

remove stdcall test, failing CI test

C abi is already tested in this, so it is not that useful to test another one.
The tested code is blind to which specific ABI for now, as long as it's not an intrinsic one

3 years agoAuto merge of #86966 - JohnTitor:rollup-uiqj2vc, r=JohnTitor
bors [Thu, 8 Jul 2021 04:05:41 +0000 (04:05 +0000)]
Auto merge of #86966 - JohnTitor:rollup-uiqj2vc, r=JohnTitor

Rollup of 9 pull requests

Successful merges:

 - #86639 (Support lint tool names in rustc command line options)
 - #86812 (Recover from `&dyn mut ...` parse errors)
 - #86917 (Add doc comment for `impl From<LayoutError> for TryReserveError`)
 - #86925 (Add self to mailmap)
 - #86927 (Sync rustc_codegen_cranelift)
 - #86932 (Fix ICE when misplaced visibility cannot be properly parsed)
 - #86933 (Clean up rustdoc static files)
 - #86955 (Fix typo in `ops::Drop` docs)
 - #86956 (Revert "Add "every" as a doc alias for "all".")

Failed merges:

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

3 years agoRollup merge of #86956 - cuviper:unalias-every, r=m-ou-se
Yuki Okushi [Thu, 8 Jul 2021 01:44:37 +0000 (10:44 +0900)]
Rollup merge of #86956 - cuviper:unalias-every, r=m-ou-se

Revert "Add "every" as a doc alias for "all"."

This reverts commit 35450365ac2fda8b948fe6fd1a1123837a9554b0 (#81697) for "every" and closes #86554 in kind for "some".

The new [doc alias policy](https://std-dev-guide.rust-lang.org/documentation/doc-alias-policy.html) is that we don't want language-specific aliases like these JavaScript names, and we especially don't want to conflict with real names. While "every" is okay in the latter regard, its natural pair "some" makes a doc-search collision with `Option::Some`.

r? ```@m-ou-se```

3 years agoRollup merge of #86955 - Swordelf2:patch-1, r=cuviper
Yuki Okushi [Thu, 8 Jul 2021 01:44:36 +0000 (10:44 +0900)]
Rollup merge of #86955 - Swordelf2:patch-1, r=cuviper

Fix typo in `ops::Drop` docs

3 years agoRollup merge of #86933 - GuillaumeGomez:cleanup-rustdoc-static-files, r=Manishearth
Yuki Okushi [Thu, 8 Jul 2021 01:44:35 +0000 (10:44 +0900)]
Rollup merge of #86933 - GuillaumeGomez:cleanup-rustdoc-static-files, r=Manishearth

Clean up rustdoc static files

The `html/static` of rustdoc was starting to be quite a mess... So I moved files in sub-folders to make it easier to follow. Here what remains in `html/static` folder:

```
$ ls
COPYRIGHT.txt  css  fonts  images  js  LICENSE-APACHE.txt  LICENSE-MIT.txt
```

cc ```@jyn514```
r? ```@Manishearth```

3 years agoRollup merge of #86932 - rylev:fix-ice-86895, r=estebank
Yuki Okushi [Thu, 8 Jul 2021 01:44:34 +0000 (10:44 +0900)]
Rollup merge of #86932 - rylev:fix-ice-86895, r=estebank

Fix ICE when misplaced visibility cannot be properly parsed

Fixes #86895

The issue was that a failure to parse the visibility was causing the original error to be dropped before being emitted.

The resulting error isn't quite as nice as when the visibility is parsed properly, but I'm not sure which error to prioritize here. Displaying both errors might be too confusing.

r? ```@estebank```

3 years agoRollup merge of #86927 - bjorn3:sync_cg_clif-2021-07-07, r=bjorn3
Yuki Okushi [Thu, 8 Jul 2021 01:44:33 +0000 (10:44 +0900)]
Rollup merge of #86927 - bjorn3:sync_cg_clif-2021-07-07, r=bjorn3

Sync rustc_codegen_cranelift

The main hightlight this sync is basic support for AArch64. Most things should work on Linux, but there does seem to be an ABI incompatibility causing proc-macros to crash, see https://github.com/bjorn3/rustc_codegen_cranelift/issues/1184. Thanks to ```@afonso360``` for implementing all Cranelift features that were necessary to compile for AArch64 using cg_clif. Also thanks to ```@shamatar``` for implementing the `llvm.x86.addcarry.64` and `llvm.x86.subborrow.64` llvm intrinsics used by num-bigint (https://github.com/bjorn3/rustc_codegen_cranelift/pull/1178) and ```@eggyal``` for implementing multi-threading support for the lazy jit mode. (https://github.com/bjorn3/rustc_codegen_cranelift/pull/1166)

r? ```@ghost```

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

3 years agoRollup merge of #86925 - inquisitivecrystal:mailmap, r=Mark-Simulacrum
Yuki Okushi [Thu, 8 Jul 2021 01:44:32 +0000 (10:44 +0900)]
Rollup merge of #86925 - inquisitivecrystal:mailmap, r=Mark-Simulacrum

Add self to mailmap

For personal reasons, I would currently prefer to be known by this name.

3 years agoRollup merge of #86917 - notriddle:notriddle/from-try-reserve-error, r=JohnTitor
Yuki Okushi [Thu, 8 Jul 2021 01:44:31 +0000 (10:44 +0900)]
Rollup merge of #86917 - notriddle:notriddle/from-try-reserve-error, r=JohnTitor

Add doc comment for `impl From<LayoutError> for TryReserveError`

3 years agoRollup merge of #86812 - FabianWolff:recover-dyn-mut, r=petrochenkov
Yuki Okushi [Thu, 8 Jul 2021 01:44:30 +0000 (10:44 +0900)]
Rollup merge of #86812 - FabianWolff:recover-dyn-mut, r=petrochenkov

Recover from `&dyn mut ...` parse errors

Consider this example:
```rust
fn main() {
    let r: &dyn mut Trait;
}
```
This currently leads to:
```
error: expected one of `!`, `(`, `;`, `=`, `?`, `for`, lifetime, or path, found keyword `mut`
 --> src/main.rs:2:17
  |
2 |     let r: &dyn mut Trait;
  |                 ^^^ expected one of 8 possible tokens

error: aborting due to previous error
```
However, especially for beginners, I think it is easy to get `&dyn mut` and `&mut dyn` confused. With my changes, I get a help message, and the parser even recovers:
```
error: `mut` must precede `dyn`
 --> test.rs:2:12
  |
2 |     let r: &dyn mut Trait;
  |            ^^^^^^^^ help: place `mut` before `dyn`: `&mut dyn`

error[E0405]: cannot find trait `Trait` in this scope
 --> test.rs:2:21
  |
2 |     let r: &dyn mut Trait;
  |                     ^^^^^ not found in this scope

error: aborting due to 2 previous errors
```

3 years agoRollup merge of #86639 - eholk:lint-tool, r=petrochenkov
Yuki Okushi [Thu, 8 Jul 2021 01:44:29 +0000 (10:44 +0900)]
Rollup merge of #86639 - eholk:lint-tool, r=petrochenkov

Support lint tool names in rustc command line options

When rustc is running without a lint tool such as clippy enabled, options for lints such as `clippy::foo` are meant to be ignored. This was already working for those specified by attrs, such as `#![allow(clippy::foo)]`, but this did not work for command line arguments like `-A clippy::foo`. This PR fixes that issue.

Note that we discovered this issue while discussing https://github.com/rust-lang/cargo/issues/5034.

Fixes #86628.

3 years agoUpdate .mailmap file
Jacob Pratt [Wed, 7 Jul 2021 20:32:04 +0000 (16:32 -0400)]
Update .mailmap file

3 years agoRevert "Add "every" as a doc alias for "all"."
Josh Stone [Wed, 7 Jul 2021 20:13:26 +0000 (13:13 -0700)]
Revert "Add "every" as a doc alias for "all"."

This reverts commit 35450365ac2fda8b948fe6fd1a1123837a9554b0.