Commit graph

153857 commits

Author SHA1 Message Date
Manish Goregaokar
0f7dc5db45
Rollup merge of #88332 - spastorino:argument-types-tait-test, r=oli-obk
Add argument types tait tests

r? ``@oli-obk``

Related to #86727
2021-08-26 12:38:12 -07:00
Manish Goregaokar
c418a48737
Rollup merge of #88320 - sexxi-goose:issue-88103, r=nikomatsakis
type_implements_trait consider obligation failure on overflow

Fixes: #88103
2021-08-26 12:38:11 -07:00
Manish Goregaokar
dfca7b3331
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.
2021-08-26 12:38:10 -07:00
Manish Goregaokar
1e94fe1a45
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](9583fd1bdd/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](9583fd1bdd/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs) as still emitting [the terse error](9583fd1bdd/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.
2021-08-26 12:38:09 -07:00
Manish Goregaokar
cf5e362fd5
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
2021-08-26 12:38:08 -07:00
Manish Goregaokar
14fb87a409
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 🤞 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.
2021-08-26 12:38:07 -07:00
Manish Goregaokar
8aa46e51df
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````
2021-08-26 12:38:06 -07:00
Manish Goregaokar
fb7959774c
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
2021-08-26 12:38:05 -07:00
bors
ad02dc46ba 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`
2021-08-26 19:15:09 +00:00
Eduard-Mihai Burtescu
efb4148865 #[inline] non-generic pub fns in rustc_target::abi and ty::layout. 2021-08-26 21:47:42 +03:00
Eduard-Mihai Burtescu
24526bbe77 compiletest: allow . in remote test paths (can arise from revisions). 2021-08-26 20:20:08 +03:00
Joshua Nelson
c60a370dac 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.
2021-08-26 16:58:25 +00:00
bors
4b9f4b221b 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`
2021-08-26 15:24:01 +00:00
jackh726
97bf80dfda Treat types in unnormalized function signatures as well-formed 2021-08-26 10:59:20 -04:00
Augie Fackler
027db5d036 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.
2021-08-26 10:40:27 -04:00
Santiago Pastorino
4924e34526
Add argument types tait tests 2021-08-26 11:21:27 -03:00
12101111
118df1cd6b
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.
2021-08-26 21:48:33 +08:00
Wesley Wiser
84a266149b Add test for stepping though match expressions 2021-08-26 09:34:31 -04:00
lcnr
bee13d18af add unsized coercion test 2021-08-26 12:57:42 +02:00
bors
20997f6ad8 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
2021-08-26 10:49:25 +00:00
lcnr
7cbfa2ee33 rebase 2021-08-26 11:14:31 +02:00
lcnr
eb5bbab37b optimize HasTypeFlagsVisitor 2021-08-26 11:14:31 +02:00
lcnr
977124590e inline stuff 2021-08-26 11:14:31 +02:00
lcnr
bc0983df06 add fixme 2021-08-26 11:14:31 +02:00
lcnr
c58d749c80 type flags 2021-08-26 11:14:31 +02:00
lcnr
f3996f6a88 review 2021-08-26 11:14:31 +02:00
lcnr
bc0156bace shrink ty::PredicateKind again 2021-08-26 11:00:30 +02:00
lcnr
283e0e670b is_polymorphic doesn't matter for tests 2021-08-26 11:00:30 +02:00
lcnr
5ba8f4d258 update mir diffs 2021-08-26 11:00:30 +02:00
lcnr
6755b2da44 ignore const substs in implicit_infer 2021-08-26 11:00:30 +02:00
lcnr
caa975c89e use ty::Unevaluated instead of def substs pair 2021-08-26 11:00:30 +02:00
lcnr
031243898e check for cycles in default_anon_const_substs 2021-08-26 11:00:30 +02:00
lcnr
2140016d6c don't just compare ty::Const 2021-08-26 11:00:30 +02:00
lcnr
ab9108b70f update TypeFlags to deal with missing ct substs 2021-08-26 11:00:30 +02:00
lcnr
cc47998e28 add tcx to fn walk 2021-08-26 11:00:30 +02:00
lcnr
bfaf13af4e make unevaluated const substs optional 2021-08-26 11:00:30 +02:00
lcnr
f4b606fd17 require a tcx for TypeVisitor 2021-08-26 10:54:01 +02:00
bors
3b3ce374d2 Auto merge of #88222 - jyn514:shared-cache, r=GuillaumeGomez
rustdoc: Move Cache from Context to SharedContext

r? `@camelid`
2021-08-26 08:04:29 +00:00
bors
76e755cf4a 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.
2021-08-26 05:23:35 +00:00
Noah Lev
4478ecc352 Don't panic if close_tag() is called without tags to close
This can happen when a tag is opened after the length limit is reached;
the tag will not end up being added to `unclosed_tags` because the queue
will never be flushed. So, now, if the `unclosed_tags` stack is empty,
`close_tag()` does nothing.

This change fixes a panic in the `limit_0` unit test.
2021-08-25 20:09:17 -07:00
Noah Lev
d932e62dd9 Assert that tag_name is alphabetic 2021-08-25 20:03:27 -07:00
Noah Lev
f8ca5764c3 Add tests for HtmlWithLimit 2021-08-25 20:03:25 -07:00
bors
c4be230b4a 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.
2021-08-26 01:14:16 +00:00
Santiago Pastorino
4fcae2c891
Add const and static TAIT tests 2021-08-25 20:32:31 -03:00
Santiago Pastorino
bb583f72e3
Add field types tait tests 2021-08-25 20:10:08 -03:00
Santiago Pastorino
5df5659a6b
Revert "Add type of a let tait test impl trait straight in let"
This reverts commit dbadab54df.
This is not part of TAITs, so, if tested should probably be done
elsewhere.
2021-08-25 19:14:50 -03:00
Thom Chiovoloni
5b25de58d6 Reference tracking issue 2021-08-25 14:58:17 -07:00
Erik Desjardins
adf3b013c8 use a peekable iterator to check the first chunk 2021-08-25 17:49:29 -04:00
Erik Desjardins
c07a2eb5b4 yet more comment improvements 2021-08-25 17:49:29 -04:00
Erik Desjardins
75fecd5d40 improve comments 2021-08-25 17:49:28 -04:00