Commit Graph

22579 Commits

Author SHA1 Message Date
Michael Goulet
4b23a224ab Label opaque type for 'captures lifetime' error message 2023-03-03 05:02:34 +00:00
Michael Goulet
a43b554259 Remove NormalizationError::ConstantKind 2023-03-03 02:25:31 +00:00
Nicholas Nethercote
3bcea5f979 Improve comments in needs_process_obligation.
And a couple of other places.
2023-03-03 09:59:33 +11:00
Matthias Krüger
e85df8d0fe
Rollup merge of #108672 - spastorino:new-rpitit-impl-side, r=compiler-errors
Feed queries on impl side for RPITITs when using lower_impl_trait_in_trait_to_assoc_ty

I've added a test for traits that were already working and what I think is probably the last bit of infrastructure work needed.
In following PRs I'm going to start adding things TDD style, tests and code that make it work.

r? `@compiler-errors`
2023-03-02 23:05:31 +01:00
Matthias Krüger
7c4e9dd63d
Rollup merge of #108624 - Nilstrieb:move-it-up, r=WaffleLapkin
Make `ExprKind` the first field in `thir::Expr`

This makes its `Debug` impl print it first which is useful, as it's the most important part when looking at an expr.
2023-03-02 23:05:30 +01:00
Matthias Krüger
13640e337a
Rollup merge of #108573 - kornelski:runtimeenvs, r=WaffleLapkin
Explain compile-time vs run-time difference in env!() error message

This PR is clarifying error message of `env!()` based on this user question: https://users.rust-lang.org/t/environment-variable-out-dir-is-undefined/90067

It makes it clear that `env!()` is for env variables defined at compile-time. There's special-case help text for common Cargo build script variables.

I've also rearranged the code to avoid allocating error message on the happy path when the env var is defined.
2023-03-02 23:05:29 +01:00
Matthias Krüger
564715a5b7
Rollup merge of #108557 - Nathan-Fenner:nathanf/adjust-error-span-fix-Some, r=WaffleLapkin
Point error span at Some constructor argument when trait resolution fails

This is a follow up to #108254 and #106477 which extends error span refinement to handle a case which I mistakenly believed was handled in #106477. The goal is to refine the error span depicted below:

```rs
trait Fancy {}
impl <T> Fancy for Option<T> where T: Iterator {}

fn want_fancy<F>(f: F) where F: Fancy {}

fn example() {
    want_fancy(Some(5));
//  (BEFORE)   ^^^^^^^ `{integer}` is not an iterator
//  (AFTER)         ^  `{integer}` is not an iterator
}
```

I had used a (slightly more complex) example as an illustrative example in #108254 , but hadn't actually turned it into a test, because I had (incorrectly) believed at the time it was covered by existing behavior. It turns out that `Some` is slightly "special" in that it resolves differently from the other `enum` constructors I had tried, and therefore this test was actually broken.

I've now updated the tests to include this example, and fixed the code to correctly resolve the `Some` constructor so that the span of the error is reduced.
2023-03-02 23:05:28 +01:00
Matthias Krüger
f75f440bbf
Rollup merge of #108022 - CraftSpider:align-bytes, r=oli-obk
Support allocations with non-Box<[u8]> bytes

This is prep work for allowing miri to support passing pointers to C code, which will require `Allocation`s to be correctly aligned. Currently, it just makes `Allocation` generic and plumbs the necessary changes through the right places.

The follow-up to this will be adding a type in the miri interpreter which correctly aligns the bytes, using that for the Miri engine, then allowing Miri to pass pointers into these allocations to C calls.

Based off of #100467, credit to ```@emarteca``` for the code
2023-03-02 23:05:27 +01:00
Andre Bogus
03334503b3 Use Option::as_slice where applicable 2023-03-02 22:36:37 +01:00
Santiago Pastorino
fa6bf2afdb
Feed queries on impl side for RPITITs when using lower_impl_trait_in_trait_to_assoc_ty 2023-03-02 16:48:49 -03:00
Vadim Petrochenkov
c83553da31 rustc_middle: Remove trait DefIdTree
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-02 23:46:44 +04:00
Nilstrieb
10a69de5fd Allow checking whether a type allows being uninitialized
This is useful for clippy and for the future `MaybeUninit::assume_init`
panics.
2023-03-02 18:33:48 +00:00
Michael Goulet
4b01a1a07a Fix another ICE in point_at_expr_source_of_inferred_type 2023-03-02 18:27:06 +00:00
Nilstrieb
e3d397a5f6 Make ExprKind the first field in thir::Expr
This makes its `Debug` impl print it first which is useful, as it's the
most important part when looking at an expr.
2023-03-02 18:21:44 +00:00
bors
13471d3b20 Auto merge of #108654 - LeSeulArtichaut:revert-99767, r=compiler-errors
Revert stabilization of `#![feature(target_feature_11)]`

This reverts #99767 due to the presence of bugs #108645 and #108646.

cc `@joshtriplett`
cc tracking issue #69098
r? `@ghost`
2023-03-02 17:38:31 +00:00
Léo Lanteri Thauvin
bfe5189904 Revert "Stabilize #![feature(target_feature_11)]"
This reverts commit b379d216ee.
2023-03-02 13:41:17 +01:00
Matthias Krüger
832987bb1e
Rollup merge of #108609 - clubby789:e0599-highlight, r=estebank
Highlight whole expression for E0599

Fixes #108603

This adds a secondary label to highlight the whole expression leading to the error. It also prevents empty labels being recognised as 'unexpected' by compiletest - otherwise, tests with NOTE annotations would pick up empty labels.

`@rustbot` label +A-diagnostics
2023-03-02 07:24:02 +01:00
Matthias Krüger
91dafebc91
Rollup merge of #108575 - compiler-errors:erase, r=estebank
Erase **all** regions when probing for associated types on ambiguity in astconv

Fixes #108562
2023-03-02 07:24:01 +01:00
Matthias Krüger
c9c9283c6a
Rollup merge of #108516 - clubby789:rustc-box-restrict, r=compiler-errors
Restrict `#[rustc_box]` to `Box::new` calls

Currently, `#[rustc_box]` can be applied to any call expression with a single argument. This PR only allows it to be applied to calls to `Box::new`
2023-03-02 07:24:00 +01:00
clubby789
d845769557 Restrict #[rustc_box] to Box::new calls 2023-03-02 02:42:19 +00:00
Rune Tynan
f26b0a2948
Format 2023-03-01 20:27:03 -05:00
bors
f77bfb7336 Auto merge of #108620 - Dylan-DPC:rollup-o5c4evy, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #108143 (rustdoc: search by macro when query ends with `!`)
 - #108394 (Make `x doc --open` work on every book)
 - #108427 (Recover from for-else and while-else)
 - #108462 (Fix `VecDeque::append` capacity overflow for ZSTs)
 - #108568 (Make associated_item_def_ids for traits use an unstable option to also return associated types for RPITITs)
 - #108604 (Add regression test for #107280)
 - #108605 (Add regression test for #105821)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-01 18:51:29 +00:00
Dylan DPC
9d132f77ae
Rollup merge of #108568 - spastorino:new-rpitit-flag, r=compiler-errors
Make associated_item_def_ids for traits use an unstable option to also return associated types for RPITITs

r? `@compiler-errors`
2023-03-01 23:40:21 +05:30
Santiago Pastorino
73e2fe0494
Properly implement should_encode_fn_impl_trait_in_trait using new unstable option 2023-03-01 14:13:41 -03:00
clubby789
6c2a952b56 Highlight whole expression for E0599 2023-03-01 16:57:11 +00:00
Santiago Pastorino
811a1cabda
Make associated_item_def_ids for traits use an unstable option to also return associated types for RPITITs 2023-03-01 12:56:39 -03:00
Santiago Pastorino
be72beca68
Fix typo in docs 2023-03-01 12:56:39 -03:00
Santiago Pastorino
e74f50ecc2
Add unstable option new_rpitit to be used for new RPITIT lowering system 2023-03-01 12:56:39 -03:00
Santiago Pastorino
5295de1694
Add opt_rpitit_info query 2023-03-01 12:56:38 -03:00
bors
609496eecf Auto merge of #108446 - Zoxc:named-allocs, r=oli-obk
Name LLVM anonymous constants by a hash of their contents

This makes the names stable between different versions of a crate unlike the `AllocId` naming, making LLVM IR comparisons with `llvm-diff` more practical.
2023-03-01 15:36:15 +00:00
y21
0758c05c97 recover from for-else and while-else 2023-03-01 13:26:59 +01:00
Michael Woerister
b79f0261f8 Do not implement HashStable for HashSet. 2023-03-01 10:20:45 +01:00
Michael Woerister
04e5fa3ce2 Remove last instances of HashSet in query result types. 2023-03-01 10:20:45 +01:00
Michael Woerister
422208ae52 Use UnordSet instead of FxHashSet for names_imported_by_glob_use query. 2023-03-01 10:20:43 +01:00
Michael Woerister
ee8bc5b0b2 Use FxIndexSet instead of FxHashSet for asm_target_features query. 2023-03-01 10:19:26 +01:00
Michael Woerister
b0202d9c2c Use LocalDefIdSet/Map instead of FxHashSet/Map for live_symbols_and_ignored_derived_traits query. 2023-03-01 10:19:26 +01:00
Michael Woerister
f0eadbafd4 Use LocalDefIdSet instead of FxHashSet for reachable_set query. 2023-03-01 10:19:25 +01:00
Michael Woerister
5ff00f96e6 Use DefIdMap instead of FxHashMap for impl_item_implementor_ids query. 2023-03-01 10:19:25 +01:00
Nikita Popov
655a810b66 Print NewPM passes
-C passes=list was printing passes for the legacy pass manager.
Use PassBuilder::printPassNames() to print NewPM passes instead.
2023-03-01 09:26:00 +01:00
Nikita Popov
45f694dbba Remove pass initialization code
This is no longer necessary with the new pass manager.
2023-03-01 09:24:13 +01:00
bors
bcb610da7f Auto merge of #108587 - matthiaskrgr:rollup-rw6po59, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #108376 (compiler/rustc_session: fix sysroot detection logic)
 - #108400 (add llvm cgu instructions stats to perf)
 - #108496 (fix #108495, postfix decrement and prefix decrement has no warning)
 - #108505 (Further unify validity intrinsics)
 - #108520 (Small cleanup to `one_bound_for_assoc_type`)
 - #108560 (Some `infer/mod.rs` cleanups)
 - #108563 (Make mailmap more correct)
 - #108564 (Fix `x clean` with specific paths)
 - #108571 (Add contains_key to SortedIndexMultiMap)
 - #108578 (Update Fuchsia platform team members)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-01 06:23:19 +00:00
Matthias Krüger
168589426c
Rollup merge of #108571 - Jesse-Bakker:sorted_index_multi_map_contains_key, r=Nilstrieb
Add contains_key to SortedIndexMultiMap
2023-03-01 01:21:59 +01:00
Matthias Krüger
3ff3011afb
Rollup merge of #108560 - Nilstrieb:infer-cleanup, r=compiler-errors
Some `infer/mod.rs` cleanups
2023-03-01 01:21:58 +01:00
Matthias Krüger
35ef8ea5e1
Rollup merge of #108520 - compiler-errors:one-bound-nit, r=jackh726
Small cleanup to `one_bound_for_assoc_type`

Use fewer closures :)
2023-03-01 01:21:57 +01:00
Matthias Krüger
5af16c1655
Rollup merge of #108505 - Nilstrieb:further-unify-validity-intrinsics, r=michaelwoerister
Further unify validity intrinsics

Also merges the inhabitedness check into the query to further unify the
code paths.

Depends on #108364
2023-03-01 01:21:57 +01:00
Matthias Krüger
1c3cc8bba5
Rollup merge of #108496 - nx2k3:issue-108495-dec, r=WaffleLapkin
fix #108495, postfix decrement and prefix decrement has no warning

Fixes #108495
2023-03-01 01:21:56 +01:00
Matthias Krüger
32d7024100
Rollup merge of #108400 - csmoe:cgu-instr-perf, r=bjorn3
add llvm cgu instructions stats to perf

r? ```@bjorn3```
2023-03-01 01:21:56 +01:00
Matthias Krüger
a51006b8d2
Rollup merge of #108555 - Zoxc:par-fix, r=cjgillot
Fix a race in the query system

This fixes an issue where in between the `job` removal and `complete` call the query neither has a job nor a result, allowing another thread to start executing it again.

r? ``@cjgillot``
2023-03-01 01:20:26 +01:00
Matthias Krüger
19604c2362
Rollup merge of #108554 - compiler-errors:late-bound-object-default, r=oli-obk
Only look for param in item's generics if it actually comes from generics

Record whether a `hir::GenericParam` comes from an item's generics, or from a `for<...>` binder. Then, only look for the param in `object_lifetime_default` if it actually comes from the item's generics.

Fixes #108177
2023-03-01 01:20:25 +01:00
Matthias Krüger
b2dc8c505c
Rollup merge of #108551 - compiler-errors:rpitit-bad-spec, r=oli-obk
Descriptive error when users try to combine RPITIT/AFIT with specialization

Previously we failed with some esoteric error like:

```
error[E0053]: method `foo` has an incompatible type for trait
  --> $DIR/dont-project-to-specializable-projection.rs:14:35
   |
LL |     default async fn foo(_: T) -> &'static str {
   |                                   ^^^^^^^^^^^^ expected associated type, found future
   |
note: type in trait
  --> $DIR/dont-project-to-specializable-projection.rs:10:27
   |
LL |     async fn foo(_: T) -> &'static str;
   |                           ^^^^^^^^^^^^
   = note: expected signature `fn(_) -> impl Future<Output = &'static str>`
              found signature `fn(_) -> impl Future<Output = &'static str>`
```

Now we error like:

```
error: async associated function in trait cannot be specialized
  --> $DIR/dont-project-to-specializable-projection.rs:14:5
   |
LL |     default async fn foo(_: T) -> &'static str {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: specialization behaves in inconsistent and surprising ways with `#![feature(async_fn_in_trait)]`, and for now is disallowed
```
2023-03-01 01:20:24 +01:00
Matthias Krüger
78f9bb11fe
Rollup merge of #108550 - clubby789:remove-disjoint, r=compiler-errors
Remove the `capture_disjoint_fields` feature

As best I can tell, this was stabilized for Edition 2021 in #88126 but the feature was never removed.
2023-03-01 01:20:24 +01:00
Matthias Krüger
371904bba6
Rollup merge of #108297 - chenyukang:yukang/delim-error-exit, r=petrochenkov
Exit when there are unmatched delims to avoid noisy diagnostics

From https://github.com/rust-lang/rust/pull/104012#issuecomment-1311764832
r? ``@petrochenkov``
2023-03-01 01:20:22 +01:00
Nathan Fenner
be15f174fa restore unaddressed FIXME 2023-02-28 14:59:32 -08:00
Nathan Fenner
f0212e6532 Fix error spans for arguments to tuple enum constructors 2023-02-28 14:58:14 -08:00
Michael Goulet
b7e0ca993d Shift vars for default RPITIT methods correctly 2023-02-28 21:34:59 +00:00
Rune Tynan
79f0021c16
Update header comment 2023-02-28 15:52:00 -05:00
Rune Tynan
3a87a18857
Make zeroed return an Option 2023-02-28 15:39:17 -05:00
Michael Goulet
cb9852b8e6 Erase **all** regions when probing for associated types in astconv 2023-02-28 17:29:46 +00:00
liushuyu
2186358e5a
compiler/rustc_session: fix sysroot detection logic ...
... on systems where /usr/lib contains a multi-arch structure
2023-02-28 10:02:38 -07:00
Kornel
2407b0c578 Explain compile-time vs run-time difference in env!() error message 2023-02-28 16:44:59 +00:00
Jesse Bakker
edf053036f Add contains_key to SortedIndexMultiMap 2023-02-28 17:15:00 +01:00
Maybe Waffle
031206bc1d micro fmt changes 2023-02-28 19:28:14 +04:00
Nilstrieb
e326777cca Some infer/mod.rs cleanups 2023-02-28 11:49:05 +00:00
Nathan Fenner
2566b4105d Point error span at Some constructor argument when trait resolution fails 2023-02-27 23:58:35 -08:00
yukang
f808877bbf refactor parse_token_trees to not return unmatched_delims 2023-02-28 07:57:17 +00:00
yukang
88de2e1115 no need to return unmatched_delims from tokentrees 2023-02-28 07:57:17 +00:00
yukang
9ce7472db4 rename unmatched_braces to unmatched_delims 2023-02-28 07:57:17 +00:00
yukang
65ad5f8de7 remove duplicated diagnostic for unclosed delimiter 2023-02-28 07:57:17 +00:00
yukang
f01d0c02e7 Exit when there are unmatched delims to avoid noisy diagnostics 2023-02-28 07:55:19 +00:00
bors
5157d938c4 Auto merge of #108098 - notriddle:notriddle/rustdoc-tooltip-alloc, r=GuillaumeGomez
rustdoc: reduce allocations when generating tooltips

An attempt to reduce the perf regression in
https://github.com/rust-lang/rust/pull/108052#issuecomment-1430631861
2023-02-28 07:27:32 +00:00
John Kåre Alsaker
10b08e3c9c Fix a race in the query system 2023-02-28 07:47:58 +01:00
Michael Goulet
f851a8aefa Only look for param in generics if it actually comes from generics 2023-02-28 06:27:56 +00:00
Michael Goulet
cbf4d4e3a5 Deny capturing late-bound non-lifetime param in anon const 2023-02-28 05:59:54 +00:00
bors
fd1f1fa0d1 Auto merge of #106774 - Nugine:master, r=Amanieu
Stabilize cmpxchg16b_target_feature

Tracking issue for target features
+ #44839

stdarch issue
+ https://github.com/rust-lang/stdarch/issues/827

stdarch PR
+ https://github.com/rust-lang/stdarch/pull/1358

reference PR
+ https://github.com/rust-lang/reference/pull/1331

It's my first time contributing to rust-lang/rust. Please tell me if I missed something.
2023-02-28 04:12:34 +00:00
Michael Goulet
ecac8fd5af Descriptive error when users try to combine RPITIT/AFIT with specialization 2023-02-28 02:03:43 +00:00
clubby789
f83ce99c32 Remove the capture_disjoint_fields feature 2023-02-28 01:21:15 +00:00
bors
b583ede652 Auto merge of #99767 - LeSeulArtichaut:stable-target-feature-11, r=estebank
Stabilize `#![feature(target_feature_11)]`

## Stabilization report

### Summary

Allows for safe functions to be marked with `#[target_feature]` attributes.

Functions marked with `#[target_feature]` are generally considered as unsafe functions: they are unsafe to call, cannot be assigned to safe function pointers, and don't implement the `Fn*` traits.

However, calling them from other `#[target_feature]` functions with a superset of features is safe.

```rust
// Demonstration function
#[target_feature(enable = "avx2")]
fn avx2() {}

fn foo() {
    // Calling `avx2` here is unsafe, as we must ensure
    // that AVX is available first.
    unsafe {
        avx2();
    }
}

#[target_feature(enable = "avx2")]
fn bar() {
    // Calling `avx2` here is safe.
    avx2();
}
```

### Test cases

Tests for this feature can be found in [`src/test/ui/rfcs/rfc-2396-target_feature-11/`](b67ba9ba20/src/test/ui/rfcs/rfc-2396-target_feature-11/).

### Edge cases

- https://github.com/rust-lang/rust/issues/73631

Closures defined inside functions marked with `#[target_feature]` inherit the target features of their parent function. They can still be assigned to safe function pointers and implement the appropriate `Fn*` traits.

```rust
#[target_feature(enable = "avx2")]
fn qux() {
    let my_closure = || avx2(); // this call to `avx2` is safe
    let f: fn() = my_closure;
}
```

This means that in order to call a function with `#[target_feature]`, you must show that the target-feature is available while the function executes *and* for as long as whatever may escape from that function lives.

### Documentation

- Reference: https://github.com/rust-lang/reference/pull/1181

---
cc tracking issue #69098
r? `@ghost`
2023-02-28 01:14:56 +00:00
bors
6290ae92b2 Auto merge of #108487 - cjgillot:no-typeck-mir, r=oli-obk
Avoid invoking typeck from borrowck

This PR attempts to reduce direct dependencies between typeck and MIR-related queries. The goal is to have all the information transit either through THIR or through dedicated queries that avoid depending on the whole `TypeckResults`.

In a first commit, we store the type information that MIR building requires into THIR. This avoids edges between mir_built and typeck.

In the second and third commit, we wrap informations around closures (upvars, kind origin and user-provided signature) to avoid borrowck depending on typeck information.

There should be a single remaining borrowck -> typeck edge in the good path, due to inline consts.
2023-02-27 21:48:10 +00:00
bors
7281249a19 Auto merge of #108538 - matthiaskrgr:rollup-vw6h5ea, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #104265 (Move IpAddr, SocketAddr and V4+V6 related types to `core`)
 - #107110 ([stdio][windows] Use MBTWC and WCTMB)
 - #108308 (Allow building serde and serde_derive in parallel)
 - #108363 (Move the unused extern crate check back to the resolver.)
 - #108519 (Bages for easy access links to Rust community)
 - #108522 (Commit some new solver tests)
 - #108523 (Avoid `&str` to `String` conversions)
 - #108533 (diagnostics: avoid querying `associated_item` in the resolver)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-27 18:02:10 +00:00
Matthias Krüger
a184150247
Rollup merge of #108533 - notriddle:notriddle/resolver-def-descr, r=compiler-errors
diagnostics: avoid querying `associated_item` in the resolver

Fixes #108529

CC #108324
2023-02-27 18:48:51 +01:00
Matthias Krüger
828b66e6de
Rollup merge of #108523 - TaKO8Ki:avoid-str-to-string-conversions, r=Nilstrieb
Avoid `&str` to `String` conversions

This patch removes some unnecessary `&str` to `String` conversions.
2023-02-27 18:48:50 +01:00
Matthias Krüger
660f184966
Rollup merge of #108363 - cjgillot:unused-crate, r=WaffleLapkin
Move the unused extern crate check back to the resolver.

It doesn't have anything to do in `rustc_hir_typeck`.
2023-02-27 18:48:49 +01:00
nx2k3
a4830266b0 handle only postfix decrement 2023-02-27 17:31:55 +00:00
Michael Howell
f058bb0fcf diagnostics: avoid querying associated_item in the resolver
Fixes #108529
2023-02-27 09:22:51 -07:00
bors
f540a25745 Auto merge of #108493 - cjgillot:thir-print, r=compiler-errors
Move THIR printing to rustc_mir_build.

https://github.com/rust-lang/rust/pull/107451 increased the compilation time of `rustc_middle` by 10% = 3s.

As https://github.com/rust-lang/rust/pull/107006 adds quite a lot of code to rustc_middle, I suspect it to be the cause.

This PR moves the THIR printing code to `rustc_mir_build`, where the query provider lives, in order to benefit from higher parallelism when compiling rustc.
2023-02-27 15:07:47 +00:00
Nilstrieb
5f593da4e6 Unify all validity check intrinsics
Also merges the inhabitedness check into the query to further unify the
code paths.
2023-02-27 13:30:44 +00:00
nx2k3
0883973d2a check double negation 2023-02-27 13:25:03 +00:00
clubby789
ef434f04e9 Allow using bool for optional diagnostics 2023-02-27 12:54:11 +00:00
bors
7d782b7ff4 Auto merge of #108175 - cjgillot:validate-storage, r=tmiasko
MIR-Validate StorageLive.

`StorageLive` statements on a local which already has storage is banned by miri.

This check is easy enough, and can detect bugs in MIR opts.
2023-02-27 11:41:41 +00:00
Takayuki Maeda
934c8c2299 avoid &str to String conversions 2023-02-27 14:27:13 +09:00
Matthias Krüger
bade5566da
Rollup merge of #108502 - lenko-d:cannot_relate_region, r=compiler-errors
Don't trigger error for ReError when other region is empty.

Fixes [#107988](https://github.com/rust-lang/rust/issues/107988)
2023-02-27 06:11:55 +01:00
Matthias Krüger
abc82484d4
Rollup merge of #108486 - cjgillot:owner-ditem, r=Nilstrieb
Merge diagnostic_items duplicate diagnostics

To deduplicate how we diagnose duplication.
2023-02-27 06:11:53 +01:00
Matthias Krüger
69b1b94d0c
Rollup merge of #108477 - y21:replace-semi-with-comma-sugg, r=compiler-errors
Make `match` arm comma suggestion more clear

Fixes #108472
2023-02-27 06:11:53 +01:00
Matthias Krüger
3fcc79f04a
Rollup merge of #108364 - Nilstrieb:validity-checks-refactor, r=compiler-errors
Unify validity checks into a single query

Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern.

I am planning on adding a further initness to check in #100423, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one.

I am not entirely happy with the naming and key type and open for improvements.

r? oli-obk
2023-02-27 06:11:52 +01:00
Matthias Krüger
3a6c5429c2
Rollup merge of #108319 - compiler-errors:dont-project-to-specializable-rpitits, r=lcnr
Don't project specializable RPITIT projection

This effective rejects specialization + RPITIT/AFIT (usages of `impl Trait` in traits) because the implementation is significantly complicated over making regular "default" trait method bodies work.

I have another PR that experimentally fixes all this, but the code may not be worth investing in.
2023-02-27 06:11:51 +01:00
Lenko Donchev
65e56616fc Don't trigger ICE for ReError when the other region is empty. 2023-02-26 20:47:18 -06:00
Michael Goulet
ff336aa6f9 Small cleanup to one_bound_for_assoc_type 2023-02-26 23:51:49 +00:00
John Kåre Alsaker
d1c8430a34 Derive Default for query structs 2023-02-26 23:45:29 +01:00
John Kåre Alsaker
3b26d71e04 Avoid implementing Debug for QueryConfig 2023-02-26 23:35:52 +01:00
John Kåre Alsaker
3fd7c4a17d Make rustc_query_system take QueryConfig by instance. 2023-02-26 23:35:47 +01:00
bors
58136ffa92 Auto merge of #108440 - Zoxc:encoder-enum, r=cjgillot
Emit the enum discriminant separately for the Encodable macro

This changes the `Encodable` proc macro to first emit the discriminant with a separate `match` statement, then emit the fields. LLVM can optimize down the first `match` to just a read of the enum discriminant. This avoids generating a `emit_usize` call per variant and enums with no fields now optimize down to just a single `emit_usize` call.

The no variant case is special cased to avoid warnings about unreachable code.

<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check:unchanged</td><td align="right">0.4676s</td><td align="right">0.4640s</td><td align="right"> -0.78%</td></tr><tr><td>🟣 <b>hyper</b>:check:unchanged</td><td align="right">0.1348s</td><td align="right">0.1338s</td><td align="right"> -0.75%</td></tr><tr><td>🟣 <b>regex</b>:check:unchanged</td><td align="right">0.3370s</td><td align="right">0.3352s</td><td align="right"> -0.54%</td></tr><tr><td>🟣 <b>syn</b>:check:unchanged</td><td align="right">0.6326s</td><td align="right">0.6281s</td><td align="right"> -0.71%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check:unchanged</td><td align="right">1.8561s</td><td align="right">1.8589s</td><td align="right"> 0.15%</td></tr><tr><td>Total</td><td align="right">3.4282s</td><td align="right">3.4200s</td><td align="right"> -0.24%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9947s</td><td align="right"> -0.53%</td></tr></table>
2023-02-26 21:41:17 +00:00
nx2k3
13a741afac fix some comments 2023-02-26 16:24:08 +00:00
nx2k3
46ea12a499 fix #108495, postfix decrement and prefix decrement has no warning 2023-02-26 16:17:23 +00:00
bors
dfa5643705 Auto merge of #108253 - nnethercote:ena-rm-VarValue-methods, r=joshtriplett
Upgrade to ena-0.14.1.

It avoids some inlining within its `inlined_probe_value` function, which seems to result in better codegen for the very large `process_obligations` function within rustc. It might also help with reducing the bimodal perf results we see for the `keccak` and `cranelift-codegen-0.82.1` benchmarks.

r? `@ghost`
2023-02-26 15:28:24 +00:00
Camille GILLOT
380ca0c9e6 Move THIR printing to rustc_mir_build. 2023-02-26 14:31:15 +00:00
bors
c4e0cd9660 Auto merge of #108488 - matthiaskrgr:rollup-i61epcw, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #107941 (Treat `str` as containing `[u8]` for auto trait purposes)
 - #108299 (Require `literal`s for some `(u)int_impl!` parameters)
 - #108337 (hir-analysis: make a helpful note)
 - #108379 (Add `ErrorGuaranteed` to `hir::{Expr,Ty}Kind::Err` variants)
 - #108418 (Replace parse_[sth]_expr with parse_expr_[sth] function names)
 - #108424 (rustc_infer: Consolidate obligation elaboration de-duplication)
 - #108475 (Fix `VecDeque::shrink_to` and add tests.)
 - #108482 (statically guarantee that current error codes are documented)
 - #108484 (Remove `from` lang item)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-26 12:40:05 +00:00
Matthias Krüger
9c27fc7d34
Rollup merge of #108484 - Nilstrieb:˂DiagnosticItem˂FromFn˃ as From˂˂LangItemFromFn˃˃˃꞉꞉from, r=cjgillot
Remove `from` lang item

It was probably a leftover from the old `?` desugaring but anyways, it's unused now except for clippy, which can just use a diagnostics item.
2023-02-26 12:05:01 +01:00
Matthias Krüger
edd27cf4ca
Rollup merge of #108482 - Ezrashaw:force-error-docs, r=GuillaumeGomez
statically guarantee that current error codes are documented

Closes #61137 (that's right!)

Pretty simple refactor (often just a change from `Result<Option<&str>>` to `Result<&str>`)

r? `@GuillaumeGomez` (could you specially look at 53044158eff0d64673a6100f701c57b484232aca? I believe you wrote that in the first place, just want to make sure you're happy with the change)
2023-02-26 12:05:00 +01:00
Matthias Krüger
c815e03447
Rollup merge of #108424 - megakorre:elaborator_refactor, r=compiler-errors
rustc_infer: Consolidate obligation elaboration de-duplication

# Explanation

The obligations `Elaborator` is doing de-duplication of obligations in 3 different locations. 1 off which has a comment.
This PR consolidates the functionality and comment to a single function.
2023-02-26 12:04:59 +01:00
Matthias Krüger
786a75a65f
Rollup merge of #108418 - est31:parser_function_names, r=Nilstrieb
Replace parse_[sth]_expr with parse_expr_[sth] function names

This resolves an inconsistency in naming style for functions on the parser, where:

* functions parsing specific kinds of items are named `parse_item_[sth]` and
* functions parsing specific kinds of *expressions* are named `parse_[sth]_expr`

favoring the style used by functions for items. There are multiple advantages of that style:

* functions of both categories are collected in the same place in the [rustdoc output](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/parser/struct.Parser.html).
* it helps with autocompletion, as you can narrow down your search for a function to those about expressions.
* it mirrors rust's path syntax where less specific things come first, then it gets more specific, i.e. `std::collections::hash_map::Entry`.

The disadvantage is that it doesn't "read like a sentence" any more. But I think the advantages weigh more greatly.

This change was mostly application of this command:

```
sed -i -E 's/(fn |\.)parse_([[:alnum:]_]+)_expr/\1parse_expr_\2/' compiler/rustc_parse/src/parser/*.rs
```

Plus very minor fixes outside of `rustc_parse`, and an invocation of `x fmt`.
2023-02-26 12:04:59 +01:00
Matthias Krüger
19b8685b06
Rollup merge of #108379 - compiler-errors:hir-error-guaranteed, r=cjgillot
Add `ErrorGuaranteed` to `hir::{Expr,Ty}Kind::Err` variants

First step in making the `Err` variants of `ExprKind` and `TyKind` require an `ErrorGuaranteed` during parsing. Making the corresponding AST versions require `ErrorGuaranteed` is a bit harder, whereas it was pretty easy to do this for HIR, so let's do that first.

The only weird thing about this PR is that `ErrorGuaranteed` is moved to `rustc_span`. This is *certainly* not the right place to put it, but `rustc_hir` cannot depend on `rustc_error` because the latter already depends on the former. Should I just pull out some of the error machinery from `rustc_error` into an even more minimal crate that `rustc_hir` can depend on? Advice would be appreciated.
2023-02-26 12:04:58 +01:00
Matthias Krüger
b27f37da07
Rollup merge of #108337 - tshepang:translatable-hir-analysis, r=cjgillot
hir-analysis: make a helpful note
2023-02-26 12:04:58 +01:00
Matthias Krüger
2bc553c6ea
Rollup merge of #107941 - compiler-errors:str-has-u8-slice-for-auto, r=lcnr
Treat `str` as containing `[u8]` for auto trait purposes

Wanted to gauge ``@rust-lang/lang`` and ``@rust-lang/types`` teams' thoughts on treating `str` as "containing" a `[u8]` slice for auto-trait purposes.

``@dtolnay`` brought this up in https://github.com/rust-lang/rust/issues/13231#issuecomment-1399386472 as a blocker for future `str` type librarification, and I think it's both a valid concern and very easy to fix. I'm interested in actually doing that `str` type librarification (#107939), but this probably should be considered in the mean time regardless of that PR.

r? types for the impl, though this definitely needs an FCP.
2023-02-26 12:04:57 +01:00
y21
32da026c35 generalize help message 2023-02-26 11:58:49 +01:00
Camille GILLOT
cb51d2da7a Avoid more calls to typeck. 2023-02-26 10:30:27 +00:00
Camille GILLOT
0915d55d87 Wrap more into into closure_typeinfo query. 2023-02-26 10:30:27 +00:00
Camille GILLOT
7dcc74eee5 Access upvars through a query. 2023-02-26 10:30:27 +00:00
Camille GILLOT
d35dbbdc8e Store the body type in THIR. 2023-02-26 10:30:27 +00:00
Camille GILLOT
752ddd028c Merge the two diagnostics. 2023-02-26 10:29:25 +00:00
Camille GILLOT
11fbb57395 Simplify diagnostic_items. 2023-02-26 10:06:03 +00:00
bors
43ee4d15bf Auto merge of #108375 - Zoxc:query-inline, r=cjgillot
Add inlining attributes for query system functions

These only have a single caller, but don't always get inlined.
2023-02-26 09:44:54 +00:00
Nilstrieb
312020ef6a Remove from_fn lang item
It was probably a leftover from the old `?` desugaring but anyways, it's
unused now except for clippy, which can just use a diagnostics item.
2023-02-26 09:15:54 +00:00
Ezra Shaw
90677edcba
refactor: statically guarantee that current error codes are documented 2023-02-26 20:12:36 +13:00
bors
70fd012439 Auto merge of #108473 - matthiaskrgr:rollup-qjyae58, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #107062 (Do some cleanup of doc/index.md)
 - #107890 (Lint against `Iterator::map` receiving a callable that returns `()`)
 - #108431 (Add regression test for #107918)
 - #108432 (test: drop unused deps)
 - #108436 (make "proc macro panicked" translatable)
 - #108444 (docs/test: add UI test and docs for `E0476`)
 - #108449 (Do not lint ineffective unstable trait impl for unresolved trait)
 - #108456 (Complete migrating `ast_passes` to derive diagnostics)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-26 02:04:23 +00:00
Matthias Krüger
767c865f07
Rollup merge of #108456 - clubby789:ast-passes-diag-migrate, r=compiler-errors
Complete migrating `ast_passes` to derive diagnostics

cc #100717

```@rustbot``` label +A-translation
2023-02-26 00:46:28 +01:00
Matthias Krüger
a223ff7cea
Rollup merge of #108449 - fee1-dead-contrib:do_not_lint_unresolved, r=compiler-errors
Do not lint ineffective unstable trait impl for unresolved trait
2023-02-26 00:46:28 +01:00
Matthias Krüger
65eecc6b59
Rollup merge of #108444 - Ezrashaw:add-test+docs-for-e0476, r=GuillaumeGomez
docs/test: add UI test and docs for `E0476`

Final undocumented error code. Not entirely sure about wording in the docs.

Part of https://github.com/rust-lang/rust/issues/61137.

r? ```@compiler-errors```

cc ```@compiler-errors```
2023-02-26 00:46:28 +01:00
Matthias Krüger
9631f4b5c9
Rollup merge of #108436 - tshepang:translatable-proc-macro-panicked, r=estebank
make "proc macro panicked" translatable
2023-02-26 00:46:27 +01:00
Matthias Krüger
fa10a21bd2
Rollup merge of #107890 - obeis:mapping-to-unit, r=cjgillot
Lint against `Iterator::map` receiving a callable that returns `()`

Close #106991
2023-02-26 00:46:25 +01:00
Tshepang Mbambo
e5d1fcd535 hir-analysis: make a helpful note 2023-02-26 00:01:44 +02:00
Michael Goulet
53fb433652 Special note for str in auto traits 2023-02-25 20:01:33 +00:00
Michael Goulet
3560e65c44 Treat str as containing [u8] for auto trait purposes 2023-02-25 20:01:33 +00:00
Michael Goulet
4723a9ad14
Rollup merge of #108333 - compiler-errors:new-solver-object-sound, r=lcnr
Make object bound candidates sound in the new trait solver

r? `@lcnr`
2023-02-25 11:53:11 -08:00
Michael Goulet
cf049ac2af
Rollup merge of #107911 - blyxyas:issue-107231-fix, r=compiler-errors
Add check for invalid #[macro_export] arguments

Resolves #107231
Sorry if I made something wrong, this is my first contribution to the repo.
2023-02-25 11:53:10 -08:00
Michael Goulet
1a599d7d97
Rollup merge of #107675 - jsgf:link-directives, r=davidtwco
Implement -Zlink-directives=yes/no

`-Zlink-directives=no` will ignored `#[link]` directives while compiling a crate, so nothing is emitted into the crate's metadata.  The assumption is that the build system already knows about the crate's native dependencies and can provide them at link time without these directives.

This is another way to address issue # #70093, which is currently addressed by `-Zlink-native-libraries` (implemented in #70095). The latter is implemented at link time, which has the effect of ignoring `#[link]` in *every* crate. This makes it a very large hammer as it requires all native dependencies to be known to the build system to be at all usable, including those in sysroot libraries. I think this means its effectively unused, and definitely under-used.

Being able to control this on a crate-by-crate basis should make it much easier to apply when needed.

I'm not sure if we need both mechanisms, but we can decide that later.

cc `@pcwalton` `@cramertj`
2023-02-25 11:53:09 -08:00
Michael Goulet
a4119ba0ae
Rollup merge of #107291 - oli-obk:rustdoc_breaking_change, r=estebank
[breaking change] Remove a rustdoc back compat warning

This warning was introduced in https://github.com/rust-lang/rust/pull/62855 for users who use `rustdoc` directly on proc macro crates (instead of using `cargo doc`) without passing `--crate-type proc-macro` (which `cargo doc` passed automatically).
2023-02-25 11:53:08 -08:00
Michael Goulet
c0e58c3420 Add ErrorGuaranteed to HIR ExprKind::Err 2023-02-25 19:46:36 +00:00
Michael Goulet
a772a6fc2a Add ErrorGuaranteed to HIR TyKind::Err 2023-02-25 19:46:36 +00:00
bors
31448badfd Auto merge of #108450 - matthiaskrgr:rollup-rqvfgu3, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #108354 (Update `fuchsia-test-runner.py` and docs)
 - #108404 (support `x fmt` for sub and outside of rust directories)
 - #108407 (docs: use intra-doc links for `Vec::get(_mut)`)
 - #108410 (rustdoc: avoid including `<li>` tags in item table short desc)
 - #108412 (Fix GUI test navigation bug)
 - #108433 (Wrap missing provider message correctly)
 - #108434 (Migrate `rustc_hir_analysis` to session diagnostic [Part One])

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-25 16:48:04 +00:00
Camille GILLOT
bf46b9cb28 Explain that this is UB catching instead of malformed MIR. 2023-02-25 16:29:06 +00:00
Camille GILLOT
9aa4f6acb2 MIR-Validate StorageLive. 2023-02-25 16:27:10 +00:00
clubby789
885f9e72d7 Complete migrating ast_passes to derive diagnostics 2023-02-25 15:19:13 +00:00
bors
dcca6a375b Auto merge of #108250 - nnethercote:rename-interner-funcs, r=compiler-errors
Rename interner funcs

This PR cleans up some inconsistencies in interner naming.

Best reviewed one commit at a time.

r? `@compiler-errors`
2023-02-25 13:55:26 +00:00
Camille GILLOT
40bde9902c Address review. 2023-02-25 13:43:21 +00:00
Matthias Krüger
2aad179b4e
Rollup merge of #108434 - obeis:hir-analysis-migrate-diagnostics, r=Nilstrieb
Migrate `rustc_hir_analysis` to session diagnostic [Part One]

Finishing `lib.rs` file
Updates #100717
r? ``@davidtwco``
2023-02-25 11:31:35 +01:00
Matthias Krüger
a4740a1922
Rollup merge of #108433 - compiler-errors:missing-provider-nit, r=Nilstrieb
Wrap missing provider message correctly

Fixes #108429

```
error: internal compiler error: compiler/rustc_middle/src/ty/query.rs:441:1: `tcx.trigger_delay_span_bug(DefId(0:3 ~ test[78c5]::main))` is not supported for local crate;
                                hint: Queries can be either made to the local crate, or the external crate. This error means you tried to use it for one that's not supported.
                                If that's not the case, trigger_delay_span_bug was likely never assigned to a provider function.

thread 'rustc' panicked at 'Box<dyn Any>', /home/ec2-user/rust3/compiler/rustc_errors/src/lib.rs:1651:9
stack backtrace:
   0:     0x7f51870926d7 - std::backtrace_rs::backtrace::libunwind::trace::hb0876bb39e7adf0d
                               at /home/ec2-user/rust3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f51870926d7 - std::backtrace_rs::backtrace::trace_unsynchronized::h1bcab1313827007b
                               at /home/ec2-user/rust3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5187077e07 - std::sys_common::backtrace::_print_fmt::h262d2a62279fa102
                               at /home/ec2-user/rust3/library/std/src/sys_common/backtrace.rs:65:5
```
2023-02-25 11:31:34 +01:00
Deadbeef
ed34354bfa Do not lint unresolved trait for ineffective unstable trait impl 2023-02-25 10:12:20 +00:00
csmoe
a30de6e7cb record llvm cgu instruction stats 2023-02-25 16:18:56 +08:00
John Kåre Alsaker
a913a2bca9 Name LLVM anonymous constants by a hash of their contents 2023-02-25 08:53:41 +01:00
Ezra Shaw
9f876cc900
docs/test: add UI test and docs for E0476 2023-02-25 19:31:02 +13:00