Commit graph

7188 commits

Author SHA1 Message Date
Esteban Kuber
3a515aec67 Use a more accurate span on assoc types WF checks 2021-08-12 10:02:36 +00:00
bors
eb2226b1f1 Auto merge of #85296 - bjorn3:plugin_cleanup, r=petrochenkov
Plugin interface cleanup

The first commit performs two uncontroversial cleanups. The second commit removes `#[plugin_registrar]` and instead requires you to export a `__rustc_plugin_registrar` function, this will require a change to servo's script_plugins (cc `@jdm)`
2021-08-12 04:30:41 +00:00
Esteban Küber
99f2977031 Modify structured suggestion output
* On suggestions that include deletions, use a diff inspired output format
* When suggesting addition, use `+` as underline
* Color highlight modified span
2021-08-11 09:46:24 +00:00
bors
d488de82f3 Auto merge of #87587 - oli-obk:lazy_tait, r=spastorino
Various refactorings of the TAIT infrastructure

Before this PR we used to store the opaque type knowledge outside the `InferCtxt`, so it got recomputed on every opaque type instantiation.

I also removed a feature gate check that makes no sense in the planned lazy TAIT resolution scheme

Each commit passes all tests, so this PR is best reviewed commit by commit.

r? `@spastorino`
2021-08-11 05:14:45 +00:00
bors
47b41b7788 Auto merge of #87254 - rusticstuff:rustc_codegen_llvm_dont_emit_zero_sized_padding, r=eddyb
LLVM codegen: Don't emit zero-sized padding for fields

Currently padding is emitted before fields of a struct and at the end of the struct regardless of the ABI. Even if no padding is required zero-sized padding fields are emitted. This is not useful and - more importantly - it make it impossible to generate the exact vector types that LLVM expects for certain ARM SIMD intrinsics. This change should unblock the implementation of many ARM intrinsics using the `unadjusted` ABI, see https://github.com/rust-lang/stdarch/issues/1143#issuecomment-827404092.

This is a proof of concept only because the field lookup now takes O(number of fields) time compared to O(1) before since it recalculates the mapping at every lookup. I would like to find out how big the performance impact actually is before implementing caching or restricting this behavior to the `unadjusted` ABI.

cc `@SparrowLii` `@bjorn3`

([Discussion on internals](https://internals.rust-lang.org/t/feature-request-add-a-way-in-rustc-for-generating-struct-type-llvm-ir-without-paddings/15007))
2021-08-11 01:36:23 +00:00
Yuki Okushi
4be63b2b5c
Rollup merge of #87895 - TheWastl:issue-87872, r=estebank
typeck: don't suggest inaccessible fields in struct literals and suggest ignoring inaccessible fields in struct patterns

Fixes #87872.

This PR adjusts the missing field diagnostic logic in typeck so that when any of the missing fields in a struct literal or pattern is inaccessible then the error is less confusing, even if some of the missing fields are accessible.

See also #76524.
2021-08-11 04:18:47 +09:00
Yuki Okushi
4d4915ae48
Rollup merge of #87889 - estebank:method-call-disambiguate, r=oli-obk
Use smaller spans when suggesting method call disambiguation

Use smaller spans when suggesting method call disambiguation.
2021-08-11 04:18:46 +09:00
Yuki Okushi
e72754dc59
Rollup merge of #87880 - pierwill:graph-duplicate-trait-bound, r=LeSeulArtichaut
Remove duplicate trait bounds in `rustc_data_structures::graph`

Remove duplicate trait bounds in `rustc_data_structures::graph`.
2021-08-11 04:18:44 +09:00
Yuki Okushi
6c92656624
Rollup merge of #87854 - BoxyUwU:var-None, r=oli-obk
correctly handle enum variants in `opt_const_param_of`

Fixes #87542

`opt_const_param_of` was returning `None` for args on an enum variant `Enum::Variant::<10>` because we called `generics_of` on the enum variant which has no generics.

r? `@oli-obk`
2021-08-11 04:18:39 +09:00
Yuki Okushi
bcef40e5fb
Rollup merge of #87811 - estebank:issue-87549, r=oli-obk
Do not ICE on HIR based WF check when involving lifetimes

Fix #87549.
2021-08-11 04:18:37 +09:00
Yuki Okushi
4442806626
Rollup merge of #87700 - kornelski:e530text, r=oli-obk
Expand explanation of E0530

The explanation didn't cover a puzzling case of enum variants missing fields.
2021-08-11 04:18:36 +09:00
Yuki Okushi
43b7cad3e5
Rollup merge of #87582 - tmiasko:symbol-printer, r=michaelwoerister
Implement `Printer` for `&mut SymbolPrinter`

to avoid passing `SymbolPrinter` by value.
2021-08-11 04:18:33 +09:00
TheWastl
cda6ecfc3d typeck: better diagnostics for missing inaccessible fields in struct literals/patterns
- typeck/expr: don't suggest adding fields in struct literals with inaccessible fields
- typeck/pat: suggest ignoring inaccessible fields in struct patterns
2021-08-10 16:18:37 +02:00
bjorn3
a501308ec1 Replace #[plugin_registrar] with exporting __rustc_plugin_registrar 2021-08-10 14:20:48 +02:00
Oli Scherer
93c4aa80b8 Don't collect into a Vec that is immediately being iterated on again. 2021-08-10 11:03:10 +00:00
Esteban Kuber
f3021b3561 Use smaller spans when suggesting method call disambiguation 2021-08-09 16:47:09 +00:00
Hans Kratz
02295f464a Test: Use smallvec directly instead of boxed. 2021-08-09 15:42:37 +00:00
pierwill
3e123e4150 Remove duplicate trait bounds in rustc_data_structures::graph 2021-08-09 08:52:04 -05:00
bors
ae90dcf020 Auto merge of #85357 - Andy-Python-Programmer:aarch64_uefi_target, r=petrochenkov
Add `aarch64-unknown-uefi` target

This pull request adds the `aarch64-unknown-uefi` target.
2021-08-09 13:16:51 +00:00
Hans Kratz
1d4972e0e9 Avoid unnecessary allocation. 2021-08-09 12:59:23 +00:00
Hans Kratz
c1d0f0a65c TEST: Use SmallVec<[u32; 4]> for field projection. 2021-08-09 12:25:33 +00:00
Hans Kratz
c627c0d88b Fix nits. 2021-08-09 12:08:18 +00:00
Esteban Küber
f93cbedade Do not ICE on HIR based WF check when involving lifetimes
Fix #87549.
2021-08-09 07:01:35 +00:00
unknown
44b81fb8fc
Add the aarch64-unknown-uefi target
* This commit adds the aarch64-unknown-uefi target and also adds it into
the supported targets list under the tier-3 target table.
* Uses the small code model by default

Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
2021-08-09 16:49:04 +10:00
bors
7b52ad00cb Auto merge of #87619 - 12101111:fix-native_link_modifiers_bundle, r=petrochenkov
Fix feature gate checking of static-nobundle and native_link_modifiers

Feature native_link_modifiers_bundle don't need feature static-nobundle
to work.

Also check the feature gates when using native_link_modifiers from command line options. Current nighly compiler don't check those feature gate.

```
> touch lib.rs
> rustc +nightly lib.rs -L /usr/lib -l static:+bundle=dl --crate-type=rlib
> rustc +nightly lib.rs -L /usr/lib -l dylib:+as-needed=dl --crate-type=dylib -Ctarget-feature=-crt-static
> rustc +nightly lib.rs -L /usr/lib -l static:-bundle=dl --crate-type=rlib
error[E0658]: kind="static-nobundle" is unstable
  |
  = note: see issue #37403 <https://github.com/rust-lang/rust/issues/37403> for more information
  = help: add `#![feature(static_nobundle)]` to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.

```

First found this in https://github.com/rust-lang/rust/pull/85600#discussion_r676612655
2021-08-09 03:59:30 +00:00
bors
d3928b183d Auto merge of #87465 - audunhalland:refactor_typeck_primary_body_of, r=eddyb
Simplify typeck/primary_body_of, fix comment to match return signature

Hi, new contributor here! I'm carefully reading through the various modules just to learn. I noticed this function, `primary_body_of`, which has gone through a couple of refactors over time, adding new `Option`s to its returned tuple. Observations:

1. the `fn`'s documentation was not all up to date with the the current return signature.
2. `FnHeader` and `FnDecl` are always both `Some` or `None`. So I figured it might just return a reference to the full `hir::FnSig`, for simplicity and more precise typing. It's a pure refactor.

I'm learning better by working with code than just reading it, so here goes! If you want to avoid pure refactor PRs that don't really fix anything, I can revert the code change to only update the comment instead.
2021-08-09 01:08:52 +00:00
bors
74a11c63f8 Auto merge of #87235 - poliorcetics:issue-87217-fn-quali-order, r=nagisa
Improve diagnostics for wrongly ordered keywords in function declaration

Fix #87217

`@rustbot` label A-diagnostics T-compiler
2021-08-08 22:28:01 +00:00
bors
442e627bee Auto merge of #87697 - GuillaumeGomez:add-e0784, r=nagisa
Assign E0784 error code for union expression errors
2021-08-08 16:40:14 +00:00
12101111
d935a14f4c
Fix feature gate checking of static-nobundle and native_link_modifiers 2021-08-08 21:46:40 +08:00
bors
c4c2986c49 Auto merge of #87815 - BoxyUwU:cec-generics-of-ice, r=eddyb
encode `generics_of` for fields and ty params

Fixes #87674
Fixes #87603

ICE was caused by calling `generics_of` on a `DefId` without any `generics_of` results. This was happening when we call `generics_of` on parent `DefId`s of an unevaluated const when we evaluate it.

r? `@lcnr`
2021-08-08 07:15:48 +00:00
bors
2d10c2a330 Auto merge of #87798 - durin42:llvm-14, r=nikic
PassWrapper: handle move of OptimizationLevel class out of PassBuilder

This is the first build break of the LLVM 14 cycle, and was caused by
https://reviews.llvm.org/D107025. Mercifully an easy fix.
2021-08-08 04:33:22 +00:00
bors
798446fe06 Auto merge of #87772 - npmccallum:naked_abi, r=Amanieu
Move naked function ABI check to its own lint

This check was previously categorized under the lint named
`UNSUPPORTED_NAKED_FUNCTIONS`. That lint is future incompatible and will
be turned into an error in a future release. However, as defined in the
Constrained Naked Functions RFC, this check should only be a warning.
This is because it is possible for a naked function to be implemented in
such a way that it does not break even the undefined ABI. For example, a
`jmp` to a `const`.

Therefore, this patch defines a new lint named
`UNDEFINED_NAKED_FUNCTION_ABI` which contains just this single check.
Unlike `UNSUPPORTED_NAKED_FUNCTIONS`, `UNDEFINED_NAKED_FUNCTION_ABI`
will not be converted to an error in the future.

rust-lang/rfcs#2774
rust-lang/rfcs#2972
2021-08-07 23:24:15 +00:00
bors
574d375680 Auto merge of #87743 - cuviper:opaque-calls, r=nikic
Prepare call/invoke for opaque pointers

Rather than relying on `getPointerElementType()` from LLVM function
pointers, we now pass the function type explicitly when building `call`
or `invoke` instructions.
2021-08-07 20:43:25 +00:00
Ellen
5f61271e38 fmt 2021-08-07 20:55:37 +01:00
Ellen
d777cb84e2 less opt in const param of 2021-08-07 18:44:36 +01:00
Nathaniel McCallum
4968537780 Fix naked function test run on non-x86_64 2021-08-07 11:17:03 -04:00
bors
996ff2e0a0 Auto merge of #87408 - kornelski:try_reserve_error, r=yaahc
Hide allocator details from TryReserveError

I think there's [no need for TryReserveError to carry detailed information](https://github.com/rust-lang/rust/issues/48043#issuecomment-825139280), but I wouldn't want that issue to delay stabilization of the `try_reserve` feature.

So I'm proposing to stabilize `try_reserve` with a `TryReserveError` as an opaque structure, and if needed, expose error details later.

This PR moves the `enum` to an unstable inner `TryReserveErrorKind` that lives under a separate feature flag. `TryReserveErrorKind` could possibly be left as an implementation detail forever, and the `TryReserveError` get methods such as `allocation_size() -> Option<usize>` or `layout() -> Option<Layout>` instead, or the details could be dropped completely to make try-reserve errors just a unit struct, and thus smaller and cheaper.
2021-08-07 01:26:15 +00:00
Augie Fackler
482f1901b0 PassWrapper: handle move of OptimizationLevel class out of PassBuilder
This is the first build break of the LLVM 14 cycle, and was caused by
https://reviews.llvm.org/D107025. Mercifully an easy fix.
2021-08-06 18:08:04 -04:00
Yuki Okushi
0de0b88fea
Rollup merge of #87816 - bjorn3:sync_cg_clif-2021-08-06, r=bjorn3
Sync rustc_codegen_cranelift

05677b6bd6 removes two assertions that should have been removed in https://github.com/rust-lang/rust/pull/87515. They are no longer correct and trigger while compiling the sysroot.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2021-08-07 01:46:37 +09:00
Yuki Okushi
a4262cc984
Rollup merge of #87779 - Aaron1011:stmt-ast-id, r=petrochenkov
Remove special case for statement `NodeId` assignment

We now let `noop_flat_map_stmt` assign `NodeId`s (via `visit_id`),
just as we do for other AST nodes.
2021-08-07 01:46:34 +09:00
Yuki Okushi
8ee962f88e
Rollup merge of #87775 - Kobzol:single-associated-item-hint, r=oli-obk
Add hint for unresolved associated trait items if the trait has a single item

This PR introduces a special-cased hint for unresolved trait items paths. It is shown if:
- the path was not resolved to any existing trait item
- and no existing trait item's name was reasonably close with regard to edit distance
- and the trait only has a single item in the corresponding namespace

I didn't know where I should put tests, therefore so far I just managed to bless two existing tests. I would be glad for hints where should tests for a hint like this be created, how should they be named (with reference to the original issue?) and what tests should I create (is it enough to test it just for types? or create separate tests also for functions and constants?).

It could also be turned into a machine applicable suggestion I suppose.

This is my first `rustc` PR, so please go easy on me :)

Fixes: https://github.com/rust-lang/rust/issues/87638
2021-08-07 01:46:33 +09:00
Yuki Okushi
3b0e797ee6
Rollup merge of #87761 - rusticstuff:rustc_error_overflow, r=Mark-Simulacrum
Fix overflow in rustc happening if the `err_count()` is reduced in a stage.

This can happen if stashed diagnostics are removed or replaced with fewer errors. The semantics stay the same if built without overflow checks. Fixes #84219.

Background: I came across this independently by running `RUSTFLAGS="-C overflow-checks=on" ./x.py test`. Fixing this will allow us to move on and find further overflow errors with testing or fuzzing.
2021-08-07 01:46:32 +09:00
Aaron Hill
a35d7f2bb3
Remove special case for statement NodeId assignment
We now let `noop_flat_map_stmt` assign `NodeId`s (via `visit_id`),
just as we do for other AST nodes.
2021-08-06 09:30:47 -05:00
bjorn3
279f486960 Merge commit '05677b6bd6c938ed760835d9b1f6514992654ae3' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
Ellen
2c004a2287 encode generics_of of fields and ty params 2021-08-06 14:20:59 +01:00
bors
4c29cc8fd0 Auto merge of #87777 - the8472:fix-mir-max-rss, r=oli-obk,joshtriplett
Use zeroed allocations in the mir interpreter instead eagerly touching the memory

#86255 introduced a 30% regression in [page faults](https://perf.rust-lang.org/compare.html?start=64ae15ddd3f3cca7036ab2b2f3a6b130b62af4da&end=39e20f1ae5f13451eb35247808d6a2527cb7d060&stat=faults
) and a 3% regression in [max-rss](https://perf.rust-lang.org/index.html?start=2021-07-01&end=&absolute=false&stat=max-rss) in the ctfe-stress benchmarks.
That's most likely happened because it separated allocation from initialization of the vec which defeats the zero-optimization.

Currently there's no allocation API that is fallible, zeroing and returns a slice, so this PR introduces one and then uses that to solve the problem. In principle `vec.resize(len, 0)` could be optimized to use `alloc::grow_zeroed` where appropriate but that would require new specializations and new plumbing in `RawVec`.
2021-08-06 12:11:30 +00:00
Oli Scherer
238d974fc6 Document with_opaque_type_inference's use cases. 2021-08-06 10:49:35 +00:00
Oli Scherer
1b9ad13941 Use existing type alias instead of manually writing it 2021-08-06 10:44:16 +00:00
Oli Scherer
092e9ccd8a Point to the value instead of the TAIT declaration for obligation failures 2021-08-06 10:42:05 +00:00
Oli Scherer
b2c1919a3d Store the DefId of the currently typechecked item in InferCtxt
This allows opaque type inference to check for defining uses without having to pass down that def id via function arguments to every method that could possibly cause an opaque type to be compared with a concrete type
2021-08-06 10:39:23 +00:00