]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #85534 - csmoe:demagnle-assert, r=michaelwoerister
Guillaume Gomez [Sun, 29 Aug 2021 14:25:28 +0000 (16:25 +0200)]
Rollup merge of #85534 - csmoe:demagnle-assert, r=michaelwoerister

add rustc-demangle assertion on mangled symbol

cc https://github.com/rust-lang/rust/issues/60705#issuecomment-844880365
r? `@michaelwoerister`

2 years agoRollup merge of #83251 - estebank:issue-83241, r=oli-obk
Guillaume Gomez [Sun, 29 Aug 2021 14:25:26 +0000 (16:25 +0200)]
Rollup merge of #83251 - estebank:issue-83241, r=oli-obk

Suggestion for call on immutable binding of mutable type

When calling a method requiring a mutable self borrow on an inmutable
to a mutable borrow of the type, suggest making the binding mutable.

Fix #83241.

2 years agoRollup merge of #80543 - LeSeulArtichaut:notify-close, r=spastorino
Guillaume Gomez [Sun, 29 Aug 2021 14:25:26 +0000 (16:25 +0200)]
Rollup merge of #80543 - LeSeulArtichaut:notify-close, r=spastorino

Notify when an `I-prioritize` issue is closed or reopened

Companion PR to rust-lang/triagebot#1078, blocked on that PR.
r? ``@spastorino`` cc ``@rust-lang/wg-prioritization``

2 years agoAuto merge of #88312 - jackh726:issue-87748, r=nikomatsakis
bors [Sun, 29 Aug 2021 10:12:54 +0000 (10:12 +0000)]
Auto merge of #88312 - jackh726:issue-87748, r=nikomatsakis

Treat types in unnormalized function signatures as well-formed

Fixes #87748

r? `@nikomatsakis`

2 years agorebase: fix test output
Esteban Kuber [Sun, 29 Aug 2021 08:48:36 +0000 (08:48 +0000)]
rebase: fix test output

2 years agoProvide structured suggestion for removal of `&mut`
Esteban Kuber [Mon, 9 Aug 2021 11:05:50 +0000 (11:05 +0000)]
Provide structured suggestion for removal of `&mut`

2 years agoSuggestion for call on immutable binding of mutable type
Esteban Küber [Thu, 18 Mar 2021 01:45:49 +0000 (18:45 -0700)]
Suggestion for call on immutable binding of mutable type

When calling a method requiring a mutable self borrow on an inmutable
to a mutable borrow of the type, suggest making the binding mutable.

Fix #83241.

2 years agoAuto merge of #88295 - alexcrichton:update-stdarch, r=kennytm
bors [Sun, 29 Aug 2021 07:32:04 +0000 (07:32 +0000)]
Auto merge of #88295 - alexcrichton:update-stdarch, r=kennytm

Update the stdarch submodule

This notably brings in a number of codegen updates to ensure that wasm
simd intrinsics generate the expected instruction with LLVM 13

2 years agoAuto merge of #88250 - rusticstuff:macos-lld, r=nagisa
bors [Sun, 29 Aug 2021 04:51:14 +0000 (04:51 +0000)]
Auto merge of #88250 - rusticstuff:macos-lld, r=nagisa

Make `-Z gcc-ld=lld` work for Apple targets

`-Z gcc-ld=lld` was introduced in #85961. It does not work on Macos because lld needs be either named `ld64` or passed `-flavor darwin` as the first two arguments in order to select the Mach-O flavor. Rust invokes cc (=clang) on Macos for linking which calls `ld` as linker binary and not `ld64`, so just creating an `ld64` binary and modifying the search path with `-B` does not work.

In order to solve this patch does:
* Set the `lld_flavor` for all Apple-derived targets to `LldFlavor::Ld64`. As far as I can see this actually works towards fixing `-Xlinker=rust-lld` as all those targets use the Mach-O object format.
* Copy/hardlink rust-lld to the gcc-ld subdirectory as ld64 next to ld.
* If `-Z gcc-ld=lld` is used and the target lld flavor is Ld64 add `-fuse-ld=/path/to/ld64` to the linker invocation.

Fixes #86945.

2 years agoAuto merge of #88088 - nbdd0121:const2, r=nagisa
bors [Sun, 29 Aug 2021 02:21:07 +0000 (02:21 +0000)]
Auto merge of #88088 - nbdd0121:const2, r=nagisa

Forbid inline const block referencing params from being used in patterns

Fix #82518

2 years agoAuto merge of #87921 - kellerkindt:master, r=kennytm
bors [Sat, 28 Aug 2021 23:39:02 +0000 (23:39 +0000)]
Auto merge of #87921 - kellerkindt:master, r=kennytm

Add Saturating type (based on Wrapping type)

Tracking #87920

### Unresolved Questions
<!--
Include any open questions that need to be answered before the feature can be
stabilised.
-->

 - [x] ~`impl Div for Saturating<T>` falls back on inner integer division - which seems alright?~
    - [x] add `saturating_div`? (to respect division by `-1`)
 - [x] There is no `::saturating_shl` and `::saturating_shr`. (How to) implement `Shl`, `ShlAssign`, `Shr` and `ShrAssign`?
   - [naively](3f7d2ce28f8cf4dec56bf65fa2e6da0cf329ec55)
 - [x] ~`saturating_neg` is only implemented on [signed integer types](https://doc.rust-lang.org/std/?search=saturating_n)~
 - [x] Is the implementation copied over from the `Wrapping`-type correct for `Saturating`?
   - [x] `Saturating::rotate_left`
   - [x] `Saturating::rotate_right`
   - [x] `Not`
   - [x] `BitXorOr` and `BitXorOrAssign`
   - [x] `BitOr` and `BitOrAssign`
   - [x] `BitAnd` and `BitAndAssign`
   - [x] `Saturating::swap_bytes`
   - [x] `Saturating::reverse_bits`

2 years agoAuto merge of #85690 - bstrie:m2_arena, r=jackh726,nagisa
bors [Sat, 28 Aug 2021 20:58:12 +0000 (20:58 +0000)]
Auto merge of #85690 - bstrie:m2_arena, r=jackh726,nagisa

Macros 2.0-ify rustc_arena

For the purpose of battle-testing macros 2.0 I'm looking to dogfood it in rustc, one crate at a time.

(Note that there are only 12 changed lines if you ignore whitespace.)

2 years agoAuto merge of #85600 - 12101111:rustbuild-libunwind, r=petrochenkov
bors [Sat, 28 Aug 2021 18:17:29 +0000 (18:17 +0000)]
Auto merge of #85600 - 12101111:rustbuild-libunwind, r=petrochenkov

build llvm libunwind.a in rustbuild

This PR move the building of llvm-libunwind from build script of libunwind to rustbuild, so user don't need a C compiler and recompile this C/C++ library when using build-std, and user can use codegen flags `link-self-contained` and cargo flag `build-std-features` to control the behavior of libunwind linking.

2 years agoAuto merge of #88390 - sexxi-goose:missing-case, r=nikomatsakis
bors [Sat, 28 Aug 2021 15:36:38 +0000 (15:36 +0000)]
Auto merge of #88390 - sexxi-goose:missing-case, r=nikomatsakis

Add missing const edge case

We don't "process" const so we need to check for additional cases when the PatKind is a Path. We need to make sure that if there is only one variant that there is no field. If there is one or more field, we will want to borrow the match scrutinee

Closes https://github.com/rust-lang/rust/issues/88331
r? `@nikomatsakis`

2 years agoAuto merge of #88388 - ldm0:outliner, r=nikic
bors [Sat, 28 Aug 2021 13:10:26 +0000 (13:10 +0000)]
Auto merge of #88388 - ldm0:outliner, r=nikic

Revert "Disable the machine outliner by default"

The fix commit is already in the fork: https://github.com/rust-lang/llvm-project/commit/6c78dbd4ca1f
Linked:
- https://github.com/rust-lang/rust/issues/85351
- https://github.com/rust-lang/rust/pull/86020

2 years agoUnimpl Shl{Assign} for signed Saturating types until the correct impl is clear
Michael Watzko [Sat, 28 Aug 2021 11:39:09 +0000 (13:39 +0200)]
Unimpl Shl{Assign} for signed Saturating types until the correct impl is clear

2 years agoFix mentions of wrapping operations
Michael Watzko [Sat, 28 Aug 2021 11:29:19 +0000 (13:29 +0200)]
Fix mentions of wrapping operations

2 years agoUse wrapping shift for unsigned types
Michael Watzko [Sat, 28 Aug 2021 11:28:35 +0000 (13:28 +0200)]
Use wrapping shift for unsigned types

2 years agoAuto merge of #88019 - inquisitivecrystal:macro-def, r=cjgillot
bors [Sat, 28 Aug 2021 10:45:28 +0000 (10:45 +0000)]
Auto merge of #88019 - inquisitivecrystal:macro-def, r=cjgillot

Treat macros as HIR items

Macros have historically been treated differently from other items at the HIR level. This PR makes them just like normal items. There are a few special cases left over, which I've attempted to lay out below. By normalizing the treatment of macro items, this PR simplifies a fair bit of code and fixes some bugs at the same time. For more information, see #87406.

r? `@cjgillot`

## Backwards incompatibility

This is backwards incompatible in one small way. Due to a mistake, it was previously possible to apply stability attributes to an exported macro, even without enabling the `staged_api` feature. This never should have worked. After this PR, it will error, as it should. We could make it a warning instead, but that would require a special case for a feature that shouldn't ever have worked and is likely used by no or very few crates, so I'm not thrilled about the idea.

## Notes for reviewers
### Commit seperation

I'd recommend reviewing this PR commit by commit. The commit chunking wasn't perfect, but it's better than looking at the combined diff, which is quite overwhelming. The compiler and standard library build after each commit, although tests do not necessarily pass and tools do not necessarily build till the end of the series.

### Special cases
There are a few special cases that remain after this change. Here are the notable ones I remember:

1. Visibility works a bit differently for `macro_rules!` macros than other items, since they aren't generally marked with `pub` but instead with `#[macro_export]`.
2. Since `#[macro_export]` macros always have paths at the top level of the crate, some additional handling needs to be done on the reexport to top level.
### Performance impact

I don't know for sure, but theses changes may slightly hurt performance. They create more work for the compiler in a few places. For instance, some operations that were previously run only for exported macros are now run for all macros. A perf run is probably advisable. For all I know we'll see performance improvements instead. :)

## Issues resolved

This resolves #87406 (the tracking issue for this change). It also fixes several bugs:

Fixes #59306.
Fixes #73754.
Fixes #87257.

2 years agoAuto merge of #88245 - Sl1mb0:s390-asm, r=Amanieu
bors [Sat, 28 Aug 2021 08:04:41 +0000 (08:04 +0000)]
Auto merge of #88245 - Sl1mb0:s390-asm, r=Amanieu

S390x inline asm

This adds register definitions and constraint codes for the s390x general and floating point registers necessary for fixing #85931; as well as a few tests.

Further testing is needed, but I am a little unsure of what specific tests should be added to `src/test/assembly/asm/s390x.rs` to address this.

2 years agoUpdate tests
inquisitivecrystal [Fri, 6 Aug 2021 05:09:25 +0000 (22:09 -0700)]
Update tests

2 years agoTeach tools that macros are now HIR items
inquisitivecrystal [Thu, 5 Aug 2021 23:58:46 +0000 (16:58 -0700)]
Teach tools that macros are now HIR items

2 years agoRemove obsolete `MacroDef` variant of `OwnerNode`
inquisitivecrystal [Sat, 31 Jul 2021 06:10:32 +0000 (23:10 -0700)]
Remove obsolete `MacroDef` variant of `OwnerNode`

2 years agoTreat macros as HIR items
inquisitivecrystal [Sat, 31 Jul 2021 06:50:57 +0000 (23:50 -0700)]
Treat macros as HIR items

2 years agoRevert machine outliner disabling on LLVM 13
liudingming [Sat, 28 Aug 2021 06:45:24 +0000 (14:45 +0800)]
Revert machine outliner disabling on LLVM 13

2 years agofix evaluation of target_feature = "crt-static"
12101111 [Sat, 28 Aug 2021 06:40:17 +0000 (14:40 +0800)]
fix evaluation of target_feature = "crt-static"

2 years agobuild llvm libunwind.a in rustbuild
12101111 [Mon, 26 Jul 2021 14:47:07 +0000 (22:47 +0800)]
build llvm libunwind.a in rustbuild

2 years agoAuto merge of #88328 - fee1-dead:not-quite-const, r=oli-obk
bors [Fri, 27 Aug 2021 21:35:08 +0000 (21:35 +0000)]
Auto merge of #88328 - fee1-dead:not-quite-const, r=oli-obk

Introduce `~const`

 - [x] Removed `?const` and change uses of `?const`
 - [x] Added `~const` to the AST. It is gated behind const_trait_impl.
 - [x] Validate `~const` in ast_validation.
 - [x] Update UI Tests
 - [x] Add enum `BoundConstness` (With variants `NotConst` and
 `ConstIfConst` allowing future extensions)
 - [x] Adjust trait selection and pre-existing code to use `BoundConstness`.
 - [ ] Optional steps for this PR
      - [x] Fix #88155
      - [x] ~~Do something with constness bounds in chalk~~ Must be done to rust-lang/chalk (just tried to refactor, there are a lot of errors to resolve :( )
      - [ ] Adjust Error messages for `~const` bounds that can't be satisfied.

r? `@oli-obk`

2 years agouse `|=`
Niko Matsakis [Fri, 27 Aug 2021 21:13:41 +0000 (17:13 -0400)]
use `|=`

2 years agosimplify the logic and document
Niko Matsakis [Fri, 27 Aug 2021 20:30:45 +0000 (16:30 -0400)]
simplify the logic and document

2 years agoAuto merge of #88397 - nagisa:nagisa/unsupported-calling-conventions, r=Mark-Simulacrum
bors [Fri, 27 Aug 2021 18:45:53 +0000 (18:45 +0000)]
Auto merge of #88397 - nagisa:nagisa/unsupported-calling-conventions, r=Mark-Simulacrum

Tracking issue for `UNSUPPORTED_CALLING_CONVENTIONS`

This was previously forgotten. Nominating for 1.55 as this lint will make it into stable in that release.

r? `@Mark-Simulacrum`

2 years agoTracking issue for UNSUPPORTED_CALLING_CONVENTIONS
Simonas Kazlauskas [Fri, 27 Aug 2021 16:27:45 +0000 (19:27 +0300)]
Tracking issue for UNSUPPORTED_CALLING_CONVENTIONS

2 years agoadd rustc-demangle assertion on mangled symbol
csmoe [Fri, 21 May 2021 02:11:40 +0000 (10:11 +0800)]
add rustc-demangle assertion on mangled symbol

2 years agoAdd comment and fix fmt issue
Roxane [Fri, 27 Aug 2021 13:00:50 +0000 (09:00 -0400)]
Add comment and fix fmt issue

2 years agoAdd missing const edge case
Roxane [Fri, 27 Aug 2021 00:56:45 +0000 (20:56 -0400)]
Add missing const edge case

2 years agoFix rustfmt test
Deadbeef [Fri, 27 Aug 2021 11:53:03 +0000 (11:53 +0000)]
Fix rustfmt test

2 years agoRevive tests
Deadbeef [Fri, 27 Aug 2021 08:26:35 +0000 (08:26 +0000)]
Revive tests

2 years agoAuto merge of #88227 - 12101111:nobundle-link-order, r=petrochenkov
bors [Fri, 27 Aug 2021 09:18:14 +0000 (09:18 +0000)]
Auto merge of #88227 - 12101111:nobundle-link-order, r=petrochenkov

Adjust linking order of static nobundle libraries

Link the static libraries with "-bundle" modifier from upstream rust crate right after linking this rust crate.
Some linker such as GNU linker `ld.bdf` treat order of linking as order of dependency.

After this change, static libraries with "-bundle" modifier is linked in the same order as "+bundle" modifier.
So we can change the value of "bundle" modifier without causing linking error.

fix: https://github.com/rust-lang/rust/issues/87541

r? `@petrochenkov`

2 years agofmt
Deadbeef [Fri, 27 Aug 2021 08:09:00 +0000 (08:09 +0000)]
fmt

2 years agoFix UI test
Deadbeef [Fri, 27 Aug 2021 07:12:40 +0000 (07:12 +0000)]
Fix UI test

2 years agoAdd `ty::BoundConstness`
Deadbeef [Fri, 27 Aug 2021 05:02:23 +0000 (05:02 +0000)]
Add `ty::BoundConstness`

2 years agoAuto merge of #88326 - eddyb:inline-ty-layout-methods, r=oli-obk
bors [Fri, 27 Aug 2021 06:37:21 +0000 (06:37 +0000)]
Auto merge of #88326 - eddyb:inline-ty-layout-methods, r=oli-obk

`#[inline]` non-generic `pub fn`s in `rustc_target::abi` and `ty::layout`.

Mostly doing this as a perf curiosity, having spotted that `#[inline]` usage is a bit spotty.

2 years agoFix #88155
Deadbeef [Thu, 26 Aug 2021 17:58:28 +0000 (17:58 +0000)]
Fix #88155

2 years agoFix more tests
Deadbeef [Wed, 25 Aug 2021 15:21:55 +0000 (15:21 +0000)]
Fix more tests

2 years agoTry fixing some tests
Deadbeef [Wed, 25 Aug 2021 14:30:09 +0000 (14:30 +0000)]
Try fixing some tests

2 years agoFix visiting twice
Deadbeef [Wed, 25 Aug 2021 13:38:14 +0000 (13:38 +0000)]
Fix visiting twice

2 years agoIntroduce `~const`
Deadbeef [Wed, 25 Aug 2021 11:53:16 +0000 (11:53 +0000)]
Introduce `~const`

 - [x] Removed `?const` and change uses of `?const`
 - [x] Added `~const` to the AST. It is gated behind const_trait_impl.
 - [x] Validate `~const` in ast_validation.
 - [ ] Add enum `BoundConstness` to the HIR. (With variants `NotConst` and
 `ConstIfConst` allowing future extensions)
 - [ ] Adjust trait selection and pre-existing code to use `BoundConstness`.
 - [ ] Optional steps (*for this PR, obviously*)
      - [ ] Fix #88155
      - [ ] Do something with constness bounds in chalk

2 years agoAuto merge of #88278 - ehuss:update-cargo, r=ehuss
bors [Fri, 27 Aug 2021 03:48:04 +0000 (03:48 +0000)]
Auto merge of #88278 - ehuss:update-cargo, r=ehuss

Update cargo

19 commits in e96bdb0c3d0a418e7fcd7fbd69be08abf830b4bc..f559c109cc79fe413a8535fb620a5a58b3823d94
2021-08-17 22:58:47 +0000 to 2021-08-26 22:54:55 +0000
- Fix test not to rely on `cargo` in PATH. (rust-lang/cargo#9843)
- Improve resolver message to include dependency requirements (rust-lang/cargo#9827)
- Add hint for cargo metadata in environment section (rust-lang/cargo#9836)
- Fix panic with build-std of a proc-macro. (rust-lang/cargo#9834)
- Fix typos “a”→“an” (rust-lang/cargo#9821)
- Fix typo in git-authentication.md (rust-lang/cargo#9832)
- Add some debug logging for `cargo fix` (rust-lang/cargo#9831)
- Add documentation about third-party registries. (rust-lang/cargo#9830)
- unset the FIX_ENV when executing the real rustc (rust-lang/cargo#9818)
- Allow crate download by checksum (rust-lang/cargo#9801)
- Emit warning for migrating to unstable edition in stable channel (rust-lang/cargo#9792)
- Warning for no lib dependencies (rust-lang/cargo#9771)
- Temporarily disable extern-html-root-url test. (rust-lang/cargo#9824)
- Move `tmp` test directory. (rust-lang/cargo#9814)
- Fix test incorrectly validating CARGO_PKG_LICENSE_FILE. (rust-lang/cargo#9813)
- Implement `[future-incompat-report]` config section (rust-lang/cargo#9774)
- Bump curl. (rust-lang/cargo#9809)
- Determine packages to install prior to installing (rust-lang/cargo#9793)
- Show feature resolver differences for dev-dependencies. (rust-lang/cargo#9803)

2 years agoUpdate cargo
Eric Huss [Tue, 24 Aug 2021 02:16:44 +0000 (19:16 -0700)]
Update cargo

2 years agoAuto merge of #88371 - Manishearth:rollup-pkkjsme, r=Manishearth
bors [Fri, 27 Aug 2021 01:07:17 +0000 (01:07 +0000)]
Auto merge of #88371 - Manishearth:rollup-pkkjsme, r=Manishearth

Rollup of 11 pull requests

Successful merges:

 - #87832 (Fix debugger stepping behavior with `match` expressions)
 - #88123 (Make spans for tuple patterns in E0023 more precise)
 - #88215 (Reland #83738: "rustdoc: Don't load all extern crates unconditionally")
 - #88216 (Don't stabilize creation of TryReserveError instances)
 - #88270 (Handle type ascription type ops in NLL HRTB diagnostics)
 - #88289 (Fixes for LLVM change 0f45c16f2caa7c035e5c3edd40af9e0d51ad6ba7)
 - #88320 (type_implements_trait consider obligation failure on overflow)
 - #88332 (Add argument types tait tests)
 - #88340 (Add `c_size_t` and `c_ssize_t` to `std::os::raw`.)
 - #88346 (Revert "Add type of a let tait test impl trait straight in let")
 - #88348 (Add field types tait tests)

Failed merges:

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

2 years agoAuto merge of #87280 - lcnr:lazy-anon-const-default-substs, r=nikomatsakis
bors [Thu, 26 Aug 2021 22:26:23 +0000 (22:26 +0000)]
Auto merge of #87280 - lcnr:lazy-anon-const-default-substs, r=nikomatsakis

lazily "compute" anon const default substs

Continuing the work of #83086, this implements the discussed solution for the [unused substs problem](https://github.com/rust-lang/project-const-generics/blob/master/design-docs/anon-const-substs.md#unused-substs). As of now, anonymous constants inherit all of their parents generics, even if they do not use them, e.g. in `fn foo<T, const N: usize>() -> [T; N + 1]`, the array length has `T` as a generic parameter even though it doesn't use it. These *unused substs* cause some backwards incompatible, and imo incorrect behavior, e.g. #78369.

---
We do not actually filter any generic parameters here and the `default_anon_const_substs` query still a dummy which only checks that
- we now prevent the previously existing query cycles and are able to call `predicates_of(parent)` when computing the substs of anonymous constants
- the default anon consts substs only include the typeflags we assume it does.

Implementing that filtering will be left as future work.

---

The idea of this PR is to delay the creation of the anon const substs until after we've computed `predicates_of` for the parent of the anon const. As the predicates of the parent can however contain the anon const we still have to create a `ty::Const` for it.

We do this by changing the substs field of `ty::Unevaluated` to an option and modifying accesses to instead call the method `unevaluated.substs(tcx)` which returns the substs as before. If the substs - now `substs_` -  of `ty::Unevaluated` are `None`, it means that the anon const currently has its default substs, i.e. the substs it has when first constructed, which are the generic parameters it has available. To be able to call `unevaluated.substs(tcx)` in a `TypeVisitor`, we add the non-defaulted method `fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>>`. In case `tcx_for_anon_const_substs` returns `None`, unknown anon const default substs are skipped entirely.

Even when `substs_` is `None` we still have to treat the constant as if it has its default substs. To do this, `TypeFlags` are modified so that it is clear whether they can still change when *exposing* any anon const default substs. A new flag, `HAS_UNKNOWN_DEFAULT_CONST_SUBSTS`, is added in case some default flags are missing.

The rest of this PR are some smaller changes to either not cause cycles by trying to access the default anon const substs too early or to be able to access the `tcx` in previously unused locations.

cc `@rust-lang/project-const-generics`
r? `@nikomatsakis`

2 years agoRollup merge of #88348 - spastorino:field-types-tait-test, r=oli-obk
Manish Goregaokar [Thu, 26 Aug 2021 19:38:15 +0000 (12:38 -0700)]
Rollup merge of #88348 - spastorino:field-types-tait-test, r=oli-obk

Add field types tait tests

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

Related to #86727

2 years agoRollup merge of #88346 - spastorino:revert-type-of-a-let2, r=jackh726
Manish Goregaokar [Thu, 26 Aug 2021 19:38:14 +0000 (12:38 -0700)]
Rollup merge of #88346 - spastorino:revert-type-of-a-let2, r=jackh726

Revert "Add type of a let tait test impl trait straight in let"

This reverts commit dbadab54df148b55b2e884440bfaeaa38517e6e8.
This is not part of TAITs, so, if tested should probably be done
elsewhere.

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

This is similar to what I was commenting here https://github.com/rust-lang/rust/pull/88332#discussion_r695939901
These is not part of TAITs so should not live in type-alias-impl-trait test directory.
I'm going to avoid adding this kind of tests in `type-alias-impl-trait` test directory and avoid thinking about them in this pass.

2 years agoRollup merge of #88340 - thomcc:c_size_t, r=joshtriplett
Manish Goregaokar [Thu, 26 Aug 2021 19:38:13 +0000 (12:38 -0700)]
Rollup merge of #88340 - thomcc:c_size_t, r=joshtriplett

Add `c_size_t` and `c_ssize_t` to `std::os::raw`.

Apparently these aren't guaranteed to be the same, and are merely "always the same in practice" (see https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/.60usize.60.20vs.20.60size_t.60).

This is a big footgun, but I suspect it can be alleviated if we expose this and start migrating people to it in advance of any platforms that ever have this as different.

I'll file a tracking issue after this gets some traction.

2 years agoRollup merge of #88332 - spastorino:argument-types-tait-test, r=oli-obk
Manish Goregaokar [Thu, 26 Aug 2021 19:38:12 +0000 (12:38 -0700)]
Rollup merge of #88332 - spastorino:argument-types-tait-test, r=oli-obk

Add argument types tait tests

r? ``@oli-obk``

Related to #86727

2 years agoRollup merge of #88320 - sexxi-goose:issue-88103, r=nikomatsakis
Manish Goregaokar [Thu, 26 Aug 2021 19:38:11 +0000 (12:38 -0700)]
Rollup merge of #88320 - sexxi-goose:issue-88103, r=nikomatsakis

type_implements_trait consider obligation failure on overflow

Fixes: #88103
2 years agoRollup merge of #88289 - durin42:llvm-14-attrs, r=nikic
Manish Goregaokar [Thu, 26 Aug 2021 19:38:10 +0000 (12:38 -0700)]
Rollup merge of #88289 - durin42:llvm-14-attrs, r=nikic

Fixes for LLVM change 0f45c16f2caa7c035e5c3edd40af9e0d51ad6ba7

More details in the individual commit messages, but the summary is: LLVM deleted an unused-to-them method that we used, we worked around it to avoid annoying cleanup/restructuring in the Rust-side code.

2 years agoRollup merge of #88270 - lqd:hrtb-type-ascription, r=nikomatsakis
Manish Goregaokar [Thu, 26 Aug 2021 19:38:09 +0000 (12:38 -0700)]
Rollup merge of #88270 - lqd:hrtb-type-ascription, r=nikomatsakis

Handle type ascription type ops in NLL HRTB diagnostics

Currently, there are still a few cases of the "higher-ranked subtype error" of yore, 4 of which are related to type ascription.

This PR is a follow-up to #86700, adding support for type ascription type ops, and makes 3 of these tests output the same diagnostics in NLL mode as the migrate mode (and 1 is now much closer, especially if you ignore that it already outputs an additional error in NLL mode -- which could be a duplicate caused by a lack of normalization like [these comments point out](https://github.com/rust-lang/rust/blob/9583fd1bdd0127328e25e5b8c24dff575ec2c86b/compiler/rustc_traits/src/type_op.rs#L122-L157), or an imprecision in some parts of normalization as [described here](https://github.com/rust-lang/rust/pull/86700#discussion_r689086688)).

Since we discussed these recently:
- [here](https://github.com/rust-lang/rust/pull/86700#discussion_r689158868), cc ````@matthewjasper,````
- and [here](https://github.com/rust-lang/rust/issues/57374#issuecomment-901500856), cc ````@Aaron1011.````

It should only leave [this TAIT test](https://github.com/rust-lang/rust/blob/9583fd1bdd0127328e25e5b8c24dff575ec2c86b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs) as still emitting [the terse error](https://github.com/rust-lang/rust/blob/9583fd1bdd0127328e25e5b8c24dff575ec2c86b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.nll.stderr).

r? ````@estebank```` (so that they shake their fist at NLL's general direction less often) or ````@nikomatsakis```` or matthew or aaron, the more the merrier.

2 years agoRollup merge of #88216 - kornelski:from_layout_err, r=kennytm
Manish Goregaokar [Thu, 26 Aug 2021 19:38:08 +0000 (12:38 -0700)]
Rollup merge of #88216 - kornelski:from_layout_err, r=kennytm

Don't stabilize creation of TryReserveError instances

#48043 + https://github.com/rust-lang/rust/pull/87993#issuecomment-903189016

2 years agoRollup merge of #88215 - jyn514:lazy-loading, r=petrochenkov
Manish Goregaokar [Thu, 26 Aug 2021 19:38:07 +0000 (12:38 -0700)]
Rollup merge of #88215 - jyn514:lazy-loading, r=petrochenkov

Reland #83738: "rustdoc: Don't load all extern crates unconditionally"

I hopefully found all the bugs :crossed_fingers: time for a take two. See the last commit for details on what went wrong before.

r? `@petrochenkov` (but feel free to reassign to Guillaume if you don't have time.)

Closes https://github.com/rust-lang/rust/issues/68427. Includes a fix for https://github.com/rust-lang/rust/issues/84738.

2 years agoRollup merge of #88123 - camelid:tup-pat-precise-spans, r=estebank
Manish Goregaokar [Thu, 26 Aug 2021 19:38:06 +0000 (12:38 -0700)]
Rollup merge of #88123 - camelid:tup-pat-precise-spans, r=estebank

Make spans for tuple patterns in E0023 more precise

As suggested in #86307. Closes #86307.

r? ````@estebank````

2 years agoRollup merge of #87832 - wesleywiser:fix_match_step, r=davidtwco
Manish Goregaokar [Thu, 26 Aug 2021 19:38:05 +0000 (12:38 -0700)]
Rollup merge of #87832 - wesleywiser:fix_match_step, r=davidtwco

Fix debugger stepping behavior with `match` expressions

Previously, we would set up the source lines for `match` expressions so
that the code generated to perform the test of the scrutinee was matched
to the line of the arm that required the test and then jump from the arm
block to the "next" block was matched to all of the lines in the `match`
expression.

While that makes sense, it has the side effect of causing strange
stepping behavior in debuggers.

I've changed the source information so that all of the generated tests
are sourced to `match {scrutinee}` and the jumps are sourced to the last
line of the block they are inside. This resolves the weird stepping
behavior in all debuggers and resolves some instances of "ambiguous
symbol" errors in WinDbg preventing the user from setting breakpoints at
`match` expressions.

Before:

https://user-images.githubusercontent.com/831192/128577421-ee0c9c03-da28-4d16-997a-d57988a7bb7f.mp4

After:

https://user-images.githubusercontent.com/831192/128577433-2ceab04d-953e-4e31-9387-93f049c71ff3.mp4

Fixes #87817

2 years agoAuto merge of #87194 - eddyb:const-value-mangling, r=michaelwoerister,oli-obk
bors [Thu, 26 Aug 2021 19:15:09 +0000 (19:15 +0000)]
Auto merge of #87194 - eddyb:const-value-mangling, r=michaelwoerister,oli-obk

rustc_symbol_mangling: support structural constants and &str in v0.

This PR should unblock #85530 (except for float `const` generics, which AFAIK should've never worked).
(cc `@tmiasko` could the https://github.com/rust-lang/rust/pull/85530#issuecomment-857855379 failures be retried with a quick crater "subset" run of this PR + changing the default to `v0`? Just to make sure I didn't miss anything other than the floats)

The encoding is the one suggested before in e.g. https://github.com/rust-lang/rust/issues/61486#issuecomment-878932102, tho this PR won't by itself finish #61486, before closing that we'd likely want to move to `@oli-obk's` "valtrees" (i.e. #83234 and other associated work).

<hr>

**EDITs**:
1. switched unit/tuple/braced-with-named-fields `<const-fields>` prefixes from `"u"`/`"T"`/`""` to `"U"`/`"T"`/`"S"` to avoid the ambiguity reported by `@tmiasko` in https://github.com/rust-lang/rust/pull/87194#issuecomment-884279921.

2. `rustc-demangle` PR: https://github.com/alexcrichton/rustc-demangle/pull/55

3. RFC amendment PR: https://github.com/rust-lang/rfcs/pull/3161
    * also removed the grammar changes included in that PR, from this description

4. added tests (temporarily using my fork of `rustc-demangle`)

<hr>

r? `@michaelwoerister`

2 years ago`#[inline]` non-generic `pub fn`s in `rustc_target::abi` and `ty::layout`.
Eduard-Mihai Burtescu [Wed, 25 Aug 2021 12:53:08 +0000 (15:53 +0300)]
`#[inline]` non-generic `pub fn`s in `rustc_target::abi` and `ty::layout`.

2 years agocompiletest: allow `.` in remote test paths (can arise from revisions).
Eduard-Mihai Burtescu [Thu, 26 Aug 2021 17:20:08 +0000 (20:20 +0300)]
compiletest: allow `.` in remote test paths (can arise from revisions).

2 years agoFix the bugs and add a regression test
Joshua Nelson [Sat, 21 Aug 2021 20:14:56 +0000 (20:14 +0000)]
Fix the bugs and add a regression test

- All attributes for an item need to be considered at once, they can't
  be considered a line at a time.
- The top-level crate was not being visited. This bug was caught by
  `extern-crate-used-only-in-link`, which I'm very glad I added.
- Make the loader private to the module, so that only one function is
  exposed.

2 years agoAuto merge of #88308 - eddyb:cooked-layouts, r=nagisa
bors [Thu, 26 Aug 2021 15:24:01 +0000 (15:24 +0000)]
Auto merge of #88308 - eddyb:cooked-layouts, r=nagisa

Morph `layout_raw` query into `layout_of`.

Before this PR, `LayoutCx::layout_of` wrapped the `layout_raw` query, to:
* normalize the type, before attempting to compute the layout
* pass the layout to `record_layout_for_printing`, for `-Zprint-type-sizes`

Moving those two responsibilities into the query may reduce overhead (due to cached calls skipping those steps), but I want to do a perf run to know.

One of the changes I had to make was changing the return type of the query, to be able to both get out the type produced by normalizing inside the query *and* to match the signature of the old `TyCtxt::layout_of`. This change may be worse, perf-wise, so that's another reason I want to check.

r? `@nagisa` cc `@oli-obk`

2 years agoTreat types in unnormalized function signatures as well-formed
jackh726 [Wed, 25 Aug 2021 00:50:09 +0000 (20:50 -0400)]
Treat types in unnormalized function signatures as well-formed

2 years agoRustWrapper: adapt to LLVM change 0f45c16f2caa
Augie Fackler [Tue, 24 Aug 2021 13:44:17 +0000 (09:44 -0400)]
RustWrapper: adapt to LLVM change 0f45c16f2caa

The above-mentioned commit (part of the LLVM 14 development cycle)
removes a method that rustc uses somewhat extensively. We mostly switch
to lower-level methods that exist in all versions of LLVM we use, so no
new ifdef logic is required in most cases.

2 years agoAdd argument types tait tests
Santiago Pastorino [Wed, 25 Aug 2021 15:49:39 +0000 (12:49 -0300)]
Add argument types tait tests

2 years agoAdjust linking order of static nobundle libraries
12101111 [Sun, 22 Aug 2021 07:54:03 +0000 (15:54 +0800)]
Adjust linking order of static nobundle libraries

Link the static libraries with "-bundle" modifier from upstream rust crate
right after linking this rust crate. Some linker such as GNU linker
`ld.bdf` treat order of linking as order of dependency. After this change,
static libraries with "-bundle" modifier is linked in the same order as
"+bundle" modifier. So we can change the value of "bundle" modifier without
causing linking error.

2 years agoAdd test for stepping though `match` expressions
Wesley Wiser [Fri, 6 Aug 2021 18:13:10 +0000 (14:13 -0400)]
Add test for stepping though `match` expressions

2 years agoAuto merge of #83698 - erikdesjardins:undefconst, r=RalfJung,oli-obk
bors [Thu, 26 Aug 2021 10:49:25 +0000 (10:49 +0000)]
Auto merge of #83698 - erikdesjardins:undefconst, r=RalfJung,oli-obk

Use undef for uninitialized bytes in constants

Fixes #83657

This generates good code when the const is fully uninit, e.g.

```rust
#[no_mangle]
pub const fn fully_uninit() -> MaybeUninit<[u8; 10]> {
    const M: MaybeUninit<[u8; 10]> = MaybeUninit::uninit();
    M
}
```
generates
```asm
fully_uninit:
ret
```

as you would expect.

There is no improvement, however, when it's partially uninit, e.g.

```rust
pub struct PartiallyUninit {
    x: u64,
    y: MaybeUninit<[u8; 10]>
}

#[no_mangle]
pub const fn partially_uninit() -> PartiallyUninit {
    const X: PartiallyUninit = PartiallyUninit { x: 0xdeadbeefcafe, y: MaybeUninit::uninit() };
    X
}
```
generates
```asm
partially_uninit:
mov rax, rdi
mov rcx, qword ptr [rip + .L__unnamed_1+16]
mov qword ptr [rdi + 16], rcx
movups xmm0, xmmword ptr [rip + .L__unnamed_1]
movups xmmword ptr [rdi], xmm0
ret

.L__unnamed_1:
.asciz "\376\312\357\276\255\336\000"
.zero 16
.size .L__unnamed_1, 24
```
which copies a bunch of zeros in place of the undef bytes, the same as before this change.

Edit: generating partially-undef constants isn't viable at the moment anyways due to #84565, so it's disabled

2 years agorebase
lcnr [Thu, 26 Aug 2021 09:04:01 +0000 (11:04 +0200)]
rebase

2 years agooptimize `HasTypeFlagsVisitor`
lcnr [Tue, 17 Aug 2021 08:23:51 +0000 (10:23 +0200)]
optimize `HasTypeFlagsVisitor`

2 years agoinline stuff
lcnr [Mon, 9 Aug 2021 08:38:27 +0000 (10:38 +0200)]
inline stuff

2 years agoadd fixme
lcnr [Wed, 4 Aug 2021 08:17:06 +0000 (10:17 +0200)]
add fixme

2 years agotype flags
lcnr [Wed, 4 Aug 2021 07:34:46 +0000 (09:34 +0200)]
type flags

2 years agoreview
lcnr [Mon, 2 Aug 2021 07:56:05 +0000 (09:56 +0200)]
review

2 years agoshrink `ty::PredicateKind` again
lcnr [Mon, 2 Aug 2021 06:47:15 +0000 (08:47 +0200)]
shrink `ty::PredicateKind` again

2 years agois_polymorphic doesn't matter for tests
lcnr [Mon, 19 Jul 2021 15:20:24 +0000 (17:20 +0200)]
is_polymorphic doesn't matter for tests

2 years agoupdate mir diffs
lcnr [Mon, 19 Jul 2021 14:59:19 +0000 (16:59 +0200)]
update mir diffs

2 years agoignore const substs in `implicit_infer`
lcnr [Mon, 19 Jul 2021 12:05:13 +0000 (14:05 +0200)]
ignore const substs in `implicit_infer`

2 years agouse `ty::Unevaluated` instead of def substs pair
lcnr [Mon, 19 Jul 2021 11:52:43 +0000 (13:52 +0200)]
use `ty::Unevaluated` instead of def substs pair

2 years agocheck for cycles in `default_anon_const_substs`
lcnr [Mon, 19 Jul 2021 11:03:29 +0000 (13:03 +0200)]
check for cycles in `default_anon_const_substs`

2 years agodon't just compare `ty::Const`
lcnr [Mon, 19 Jul 2021 10:13:25 +0000 (12:13 +0200)]
don't just compare `ty::Const`

2 years agoupdate `TypeFlags` to deal with missing ct substs
lcnr [Sat, 17 Jul 2021 16:48:07 +0000 (18:48 +0200)]
update `TypeFlags` to deal with missing ct substs

2 years agoadd `tcx` to `fn walk`
lcnr [Sat, 17 Jul 2021 14:43:23 +0000 (16:43 +0200)]
add `tcx` to `fn walk`

2 years agomake unevaluated const substs optional
lcnr [Mon, 15 Mar 2021 23:05:45 +0000 (00:05 +0100)]
make unevaluated const substs optional

2 years agorequire a `tcx` for `TypeVisitor`
lcnr [Sat, 13 Mar 2021 15:05:15 +0000 (16:05 +0100)]
require a `tcx` for `TypeVisitor`

2 years agoAuto merge of #88222 - jyn514:shared-cache, r=GuillaumeGomez
bors [Thu, 26 Aug 2021 08:04:29 +0000 (08:04 +0000)]
Auto merge of #88222 - jyn514:shared-cache, r=GuillaumeGomez

rustdoc: Move Cache from Context to SharedContext

r? `@camelid`

2 years agoAuto merge of #88066 - LeSeulArtichaut:patterns-cleanups, r=nagisa
bors [Thu, 26 Aug 2021 05:23:35 +0000 (05:23 +0000)]
Auto merge of #88066 - LeSeulArtichaut:patterns-cleanups, r=nagisa

Use if-let guards in the codebase and various other pattern cleanups

Dogfooding if-let guards as experimentation for the feature.

Tracking issue #51114. Conflicts with #87937.

2 years agoAuto merge of #88069 - Mark-Simulacrum:llvm-pgo, r=pietroalbini
bors [Thu, 26 Aug 2021 01:14:16 +0000 (01:14 +0000)]
Auto merge of #88069 - Mark-Simulacrum:llvm-pgo, r=pietroalbini

PGO for LLVM builds on x86_64-unknown-linux-gnu in CI

This shows up to 6% less instruction counts with larger - up to 18% - wins on cycles
on multiple benchmarks, and up to 19% wins on the -j1 wall times for rustc self-compilation.

We can afford to spend the extra cycles building LLVM essentially once more for
the x86_64-unknown-linux-gnu CI build today. The builder finishes in around 50
minutes on average, and this adds just 10 more minutes. Given the sizeable
improvements in compiler performance, this is definitely worth it.

2 years agoAdd field types tait tests
Santiago Pastorino [Wed, 25 Aug 2021 23:07:12 +0000 (20:07 -0300)]
Add field types tait tests

2 years agoRevert "Add type of a let tait test impl trait straight in let"
Santiago Pastorino [Wed, 25 Aug 2021 22:14:50 +0000 (19:14 -0300)]
Revert "Add type of a let tait test impl trait straight in let"

This reverts commit dbadab54df148b55b2e884440bfaeaa38517e6e8.
This is not part of TAITs, so, if tested should probably be done
elsewhere.

2 years agoReference tracking issue
Thom Chiovoloni [Wed, 25 Aug 2021 21:58:17 +0000 (14:58 -0700)]
Reference tracking issue

2 years agouse a peekable iterator to check the first chunk
Erik Desjardins [Wed, 25 Aug 2021 21:44:27 +0000 (17:44 -0400)]
use a peekable iterator to check the first chunk

2 years agoyet more comment improvements
Erik Desjardins [Wed, 25 Aug 2021 21:40:57 +0000 (17:40 -0400)]
yet more comment improvements

2 years agoimprove comments
Erik Desjardins [Sun, 15 Aug 2021 16:24:58 +0000 (12:24 -0400)]
improve comments

2 years agoput code in a more logical order
Erik Desjardins [Sat, 14 Aug 2021 18:13:06 +0000 (14:13 -0400)]
put code in a more logical order