Commit Graph

217488 Commits

Author SHA1 Message Date
Matthias Krüger
d40c13ae02
Rollup merge of #107972 - saethlin:fix-test-ub, r=michaelwoerister
Fix unintentional UB in ui tests

`@matthiaskrgr` found UB in a bunch of the ui tests. This PR fixes a batch of miscellaneous tests I didn't think needed reviewers from a particular part of the project.
2023-02-15 21:30:56 +01:00
Matthias Krüger
1fdf0e1334
Rollup merge of #107034 - IntQuant:issue-100717-infer-5, r=oli-obk
Migrating rustc_infer to session diagnostics (part 4)

`@rustbot` label +A-translation
r? rust-lang/diagnostics
cc https://github.com/rust-lang/rust/issues/100717
2023-02-15 21:30:55 +01:00
bors
2d14db321b Auto merge of #108006 - cjgillot:def-impl, r=oli-obk
Avoid accessing HIR when it can be avoided

Experiment to see if it helps some incremental cases.

Will be rebased once https://github.com/rust-lang/rust/pull/107942 gets merged.

r? `@ghost`
2023-02-15 16:14:10 +00:00
Ben Kimock
de01ea26c9 Fix unintentional UB in ui tests 2023-02-15 09:05:05 -05:00
bors
999ac5f777 Auto merge of #108070 - Dylan-DPC:rollup-v6xw7vk, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #105300 (rework min_choice algorithm of member constraints)
 - #107163 (Remove some superfluous type parameters from layout.rs.)
 - #107173 (Suggest the correct array length on mismatch)
 - #107411 (Handle discriminant in DataflowConstProp)
 - #107968 (Enable `#[thread_local]` on armv6k-nintendo-3ds)
 - #108032 (Un📦ing the Resolver)
 - #108060 (Revert to using `RtlGenRandom` as a fallback)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-15 08:48:44 +00:00
Dylan DPC
ef6de70c77
Rollup merge of #108060 - ChrisDenton:rtlgenrandom, r=thomcc
Revert to using `RtlGenRandom` as a fallback

This is required due to `BCryptGenRandom` failing to load a dll it depends on.

Fixes #108059
2023-02-15 12:24:56 +05:30
Dylan DPC
504225c0a7
Rollup merge of #108032 - oli-obk:un📦ing_resolver, r=petrochenkov
Un📦ing the Resolver

r? `@petrochenkov`

pulled out of https://github.com/rust-lang/rust/pull/105462
2023-02-15 12:24:56 +05:30
Dylan DPC
587e3dfa80
Rollup merge of #107968 - ian-h-chamberlain:feature/3ds-enable-thread-local, r=Nilstrieb
Enable `#[thread_local]` on armv6k-nintendo-3ds

Since [libctru 2.1.2](https://github.com/devkitPro/libctru/releases/tag/v2.1.2)  was released we should now be able to use real `#[thread_local]` without corruption issues on the 3DS target.

CC `@Meziu` `@AzureMarker` `@Techie-Pi`
https://github.com/rust3ds/ctru-rs/issues/91#issuecomment-1426821450
2023-02-15 12:24:55 +05:30
Dylan DPC
c78e3c735a
Rollup merge of #107411 - cjgillot:dataflow-discriminant, r=oli-obk
Handle discriminant in DataflowConstProp

cc ``@jachris``
r? ``@JakobDegen``

This PR attempts to extend the DataflowConstProp pass to handle propagation of discriminants. We handle this by adding 2 new variants to `TrackElem`: `TrackElem::Variant` for enum variants and `TrackElem::Discriminant` for the enum discriminant pseudo-place.

The difficulty is that the enum discriminant and enum variants may alias each another. This is the issue of the `Option<NonZeroUsize>` test, which is the equivalent of https://github.com/rust-lang/unsafe-code-guidelines/issues/84 with a direct write.

To handle that, we generalize the flood process to flood all the potentially aliasing places. In particular:
- any write to `(PLACE as Variant)`, either direct or through a projection, floods `(PLACE as OtherVariant)` for all other variants and `discriminant(PLACE)`;
- `SetDiscriminant(PLACE)` floods `(PLACE as Variant)` for each variant.

This implies that flooding is not hierarchical any more, and that an assignment to a non-tracked place may need to flood a tracked place. This is handled by `for_each_aliasing_place` which generalizes `preorder_invoke`.

As we deaggregate enums by putting `SetDiscriminant` last, this allows to propagate the value of the discriminant.

This refactor will allow to make https://github.com/rust-lang/rust/pull/107009 able to handle discriminants too.
2023-02-15 12:24:55 +05:30
Dylan DPC
a110cf5d16
Rollup merge of #107173 - clubby789:suggest-array-length, r=compiler-errors
Suggest the correct array length on mismatch

Fixes #107156

I wasn't able to find a way to get the `Span` for the actual array size unfortunately, so this suggestion can't be applied automatically.

``@rustbot`` label +A-diagnostics
2023-02-15 12:24:54 +05:30
Dylan DPC
9800dbe883
Rollup merge of #107163 - mikebenfield:parameters-pr, r=TaKO8Ki
Remove some superfluous type parameters from layout.rs.

Specifically remove V, which can always be VariantIdx, and F, which can always be Layout.
2023-02-15 12:24:54 +05:30
Dylan DPC
83f10ea5b7
Rollup merge of #105300 - aliemjay:member-lower, r=oli-obk
rework min_choice algorithm of member constraints

See [this comment](https://github.com/rust-lang/rust/pull/105300#issuecomment-1384312743) for the description of the new algorithm.

Fixes #63033
Fixes #104639

This uses a more general algorithm than #89056 that doesn't treat `'static` as a special case. It thus accepts more code. For example:
```rust
async fn test2<'s>(_: &'s u8, _: &'_ &'s u8, _: &'_ &'s u8) {}
```
I claim it's more correct as well because it fixes #104639.

cc ``@nikomatsakis`` ``@lqd`` ``@tmandry`` ``@eholk`` ``@chenyukang`` ``@oli-obk``

r? types
2023-02-15 12:24:53 +05:30
bors
068161ea48 Auto merge of #107940 - BoxyUwU:const_ty_assertion_use_semantic_equality, r=compiler-errors
use semantic equality for const param type equality assertion

Fixes #107898

See added test for what caused this ICE

---

The current in assertion in `relate.rs` is rather inadequate when keeping in mind future expansions to const generics:
- it will ICE when there are infer vars in a projection in a const param ty
- it will spurriously return false when either ty has infer vars because of using `==` instead of `infcx.at(..).eq`
- i am also unsure if it would be possible with `adt_const_params` to craft a situation where the const param type is not wf causing `normalize_erasing_regions` to `bug!` when we would have emitted a diagnostic.

This impl feels pretty Not Great to me  although i am not sure what a better idea would be.

- We have to have the logic behind a query because neither `relate.rs` or `combine.rs` have access to trait solving machinery (without evaluating nested obligations this assert will become _far_ less useful under lazy norm, which consts are already doing)
- `relate.rs` does not have access to canonicalization machinery which is necessary in order to have types potentially containing infer vars in query arguments.

We could possible add a method to `TypeRelation` to do this assertion rather than a query but to avoid implementing the same logic over and over we'd probably end up with the logic in a free function somewhere in `rustc_trait_selection` _anyway_ so I don't think that would be much better.

We could also just remove this assertion, it should not actually be necessary for it to be present. It has caught some bugs in the past though so if possible I would like to keep it.

r? `@compiler-errors`
2023-02-15 05:17:58 +00:00
bors
0416b1a6f6 Auto merge of #108056 - matthiaskrgr:rollup-oa6bxvh, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #107573 (Update the minimum external LLVM to 14)
 - #107626 (Fix `x fix` on the standard library itself)
 - #107673 (update ICU4X to 1.1.0)
 - #107733 (Store metrics from `metrics.json` to CI PGO timer)
 - #108007 (Use `is_str` instead of string kind comparison)
 - #108033 (add an unstable `#[rustc_coinductive]` attribute)
 - #108039 (Refactor refcounted structural_impls via functors)
 - #108040 (Use derive attributes for uninteresting traversals)
 - #108044 (interpret: rename Pointer::from_addr → from_addr_invalid)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-14 21:07:04 +00:00
Camille GILLOT
065f0b222d Move query out of path. 2023-02-14 20:27:38 +00:00
Camille GILLOT
40cb4d1bc7 Even less HIR. 2023-02-14 20:27:38 +00:00
Camille GILLOT
68fb752035 Do not fetch HIR to check target features. 2023-02-14 20:27:38 +00:00
Camille GILLOT
e49e7f6a2e Do not fetch HIR to compute symbols. 2023-02-14 20:27:36 +00:00
Camille GILLOT
0d39f9d94d Do not fetch HIR to monomorphize impls. 2023-02-14 20:26:04 +00:00
Camille GILLOT
facecf6e1b Fetch less HIR in signature check. 2023-02-14 20:26:03 +00:00
Camille GILLOT
e9e12266ce Do not fetch HIR for reachable. 2023-02-14 20:26:01 +00:00
IQuant
58939b9520 Specify correct spans in suggest_await_on_expect_found 2023-02-14 23:16:29 +03:00
Camille GILLOT
2a51e73ac9 Do not fetch HIR for inherent impls. 2023-02-14 19:55:45 +00:00
Camille GILLOT
03dff82d59 Add of_trait to DefKind::Impl. 2023-02-14 19:55:44 +00:00
Chris Denton
dfd0afb991
Revert to using RtlGenRandom
This is required due to `BCryptGenRandom` failing to load the necessary dll on some systems.
2023-02-14 19:37:05 +00:00
Matthias Krüger
8e82c8c9d0
Rollup merge of #108044 - RalfJung:from-addr-invalid, r=oli-obk
interpret: rename Pointer::from_addr → from_addr_invalid

This function corresponds to `ptr::invalid` in the standard library; the previous name was not clear enough IMO.
2023-02-14 18:24:44 +01:00
Matthias Krüger
9b39568e64
Rollup merge of #108040 - eggyal:attributes_for_uninteresting_traversals, r=oli-obk
Use derive attributes for uninteresting traversals

It appears that visiting and folding was implemented on `BitMatrix` solely so that the derive macros could be used on `GeneratorLayout`, however such implementation would not necessarily be correct for other uses (if there were any).  Adding attributes to the derive macro is more correct and potentially more generally useful.

r? ``@oli-obk``
2023-02-14 18:24:43 +01:00
Matthias Krüger
207d6e177f
Rollup merge of #108039 - eggyal:traverse_refcounts_via_functors, r=oli-obk
Refactor refcounted structural_impls via functors

The mapping of values in refcounted types can be extracted as a functor, simplifying the implementations in the type library (whose structural folding impls now all use such functors).  This functor could also prove more generally useful elsewhere.
2023-02-14 18:24:43 +01:00
Matthias Krüger
edcdab08a4
Rollup merge of #108033 - lcnr:coinductive-attr, r=compiler-errors
add an unstable `#[rustc_coinductive]` attribute

useful to test coinduction, especially in the new solver.

as this attribute should remain permanently unstable I don't think this needs any official approval. cc ``@rust-lang/types``

had to weaken the check for stable query results in the solver to prevent an ICE if there's a coinductive cycle with constraints.

r? ``@compiler-errors``
2023-02-14 18:24:42 +01:00
Matthias Krüger
7e0127b2ae
Rollup merge of #108007 - compiler-errors:str-less-kind, r=Nilstrieb
Use `is_str` instead of string kind comparison

Split out from #107939
2023-02-14 18:24:42 +01:00
Matthias Krüger
74d018e317
Rollup merge of #107733 - Kobzol:opt-build-metrics, r=Mark-Simulacrum
Store metrics from `metrics.json` to CI PGO timer

With this change, we'll be able to easily see how long does it take to compile LLVM vs `rustc`.

r? ```@Mark-Simulacrum```
2023-02-14 18:24:41 +01:00
Matthias Krüger
3549e42580
Rollup merge of #107673 - lukas-code:update-icu4x, r=davidtwco
update ICU4X to 1.1.0

This patch updates the ICU4X crates to version 1.1.0 and regenerates the static data for `rustc_baked_icu_data`.

This is mostly an internal and bugfix update. It notably includes https://github.com/unicode-org/icu4x/pull/2834 to fix the future compatibility warning for [`BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE`](https://github.com/rust-lang/rust/issues/107457).

[full changelog](https://github.com/unicode-org/icu4x/blob/icu%401.1.0/CHANGELOG.md)
2023-02-14 18:24:41 +01:00
Matthias Krüger
2c1d3e92e0
Rollup merge of #107626 - jyn514:x-fix, r=Mark-Simulacrum
Fix `x fix` on the standard library itself

Fixes https://github.com/rust-lang/rust/issues/107501
2023-02-14 18:24:40 +01:00
Matthias Krüger
a1ba861190
Rollup merge of #107573 - cuviper:drop-llvm-13, r=nagisa
Update the minimum external LLVM to 14

With this change, we'll have stable support for LLVM 14 through 16 (pending release).
For reference, the previous increase to LLVM 13 was #100460.
2023-02-14 18:24:40 +01:00
bors
6e0115778b Auto merge of #108052 - matthiaskrgr:rollup-p6r6rnl, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #103478 ( Suggest fix for misplaced generic params on fn item #103366 )
 - #107739 (Check for overflow in evaluate_canonical_goal)
 - #108003 (Avoid ICE when the generic_span is empty)
 - #108016 ("Basic usage" is redundant for there is just one example)
 - #108023 (Shrink size of array benchmarks)
 - #108024 (add message to update Cargo.toml when x is changed)
 - #108025 (rustdoc: add more tooltips to intra-doc links)
 - #108029 (s/eval_usize/eval_target_usize/ for clarity)
 - #108035 (Avoid using a dead email address as the main email address)
 - #108038 (Remove needless supertrait constraints from Interner projections)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-14 17:24:31 +00:00
Matthias Krüger
ea679fb674
Rollup merge of #108038 - eggyal:remove_needless_supertrait_constraints, r=lcnr
Remove needless supertrait constraints from Interner projections

These associated types are already all constrained to implement `Ord`, so specifically requiring its supertraits `Eq`, `PartialEq` and `PartialOrd` is superfluous.
2023-02-14 18:02:55 +01:00
Matthias Krüger
7a9e6e8ccb
Rollup merge of #108035 - oli-obk:oli_new_contributor_funkiness, r=Mark-Simulacrum
Avoid using a dead email address as the main email address

This caused highfive to welcome me as a new contributor on every PR, because it couldn't find any commits of mine.
2023-02-14 18:02:54 +01:00
Matthias Krüger
f68864cbca
Rollup merge of #108029 - oli-obk:🞋_usize, r=RalfJung
s/eval_usize/eval_target_usize/ for clarity

r? `@nnethercote`

as discussed in https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.60Const.60.20and.20.60usize.60.2F.60u64.60 it is unclear what `usize` means and why we use a `u64` for something talking about `usize`. This renaming should make it clear that we're talking about `usize`s on the target platform, irrespective of the compiler host platform.
2023-02-14 18:02:54 +01:00
Matthias Krüger
8804e7f3dc
Rollup merge of #108025 - notriddle:notriddle/intra-doc-link-tooltips, r=GuillaumeGomez
rustdoc: add more tooltips to intra-doc links

This commit makes intra-doc link tooltips consistent with generated links in function signatures and item tables, with the format `itemtype foo::bar::baz`. This way, you can tell if a link points at a trait or a type (for example) by mousing over it.

See also https://github.com/rust-lang/rust/pull/39697

Partially solves https://internals.rust-lang.org/t/rustdoc-suggestion-highlight-links-fn-s-mod-s-type-s-etc-appropriately-within-and-documentation/17931 (though the Internals thread asks for color-coding, while this PR adds a tooltip instead, it's accomplishing the same thing).

Before:

<img width="950" alt="image" src="https://user-images.githubusercontent.com/1593513/218653059-911cea01-7231-438a-ad98-be98ab73783f.png">

After:

<img width="432" alt="image" src="https://user-images.githubusercontent.com/1593513/218653201-34ca3aa7-18f1-4cb1-be68-a1411bbe797e.png">
2023-02-14 18:02:53 +01:00
Matthias Krüger
43b42c5e78
Rollup merge of #108024 - zephaniahong:master, r=jyn514
add message to update Cargo.toml when x is changed

`@jyn514` Is this correct?

As mentioned in #108021
2023-02-14 18:02:53 +01:00
Matthias Krüger
d599be0af2
Rollup merge of #108023 - JulianKnodt:smaller_benchmark, r=workingjubilee
Shrink size of array benchmarks

Might've overdone it with the size of these benchmarks, as there's no need for them to be quite as large.

Fixes #108011
2023-02-14 18:02:52 +01:00
Matthias Krüger
3eb57319f2
Rollup merge of #108016 - tshepang:just-one-example, r=thomcc
"Basic usage" is redundant for there is just one example
2023-02-14 18:02:52 +01:00
Matthias Krüger
1f486f0a9b
Rollup merge of #108003 - chenyukang:yukang/fix-107998, r=compiler-errors
Avoid ICE when the generic_span is empty

Fixes #107998
r? ```@TaKO8Ki```
2023-02-14 18:02:51 +01:00
Matthias Krüger
9ee3c7ac4b
Rollup merge of #107739 - spastorino:check-overflow-evaluate_canonical_goal, r=lcnr
Check for overflow in evaluate_canonical_goal

r? `@lcnr`
2023-02-14 18:02:50 +01:00
Matthias Krüger
202c70666f
Rollup merge of #103478 - SpanishPear:spanishpear/issue_103366_fix, r=TaKO8Ki
Suggest fix for misplaced generic params on fn item #103366

fixes #103366

This still has some work to go, but works for 2/3 of the initial base cases described in #1033366

simple fn:
```
error: expected identifier, found `<`
 --> shreys/test_1.rs:1:3
  |
1 | fn<T> id(x: T) -> T { x }
  |   ^ expected identifier
  |
help: help: place the generic parameter list after the function name:
  |
1 | fn id<T>(x: T) -> T { x }
  |    ~~~~

```

Complicated bounds
```
error: expected identifier, found `<`
 --> spanishpear/test_2.rs:1:3
  |
1 | fn<'a, B: 'a + std::ops::Add<Output = u32>> f(_x: B) { }
  |   ^ expected identifier
  |
help: help: place the generic parameter list after the function name:
  |
1 | fn f<'a, B: 'a + std::ops::Add<Output = u32>>(_x: B) { }
  |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Opening a draft PR for comments on approach, particularly I have the following questions:
 -  [x]  Is it okay to be using `err.span_suggestion` over struct derives? I struggled to get the initial implementation (particularly the correct suggestion message) on struct derives, although I think given what I've learned since starting, I could attempt re-doing it with that approach.
  -  [x] in the case where the snippet cannot be obtained from a span, is the `help` but no suggestion okay? I think yes (also, when does this case occur?)
  -  [x] are there any red flags for the generalisation of this work for relevant item kinds (i.e. `struct`, `enum`, `trait`, and `union`). My basic testing indicates it does work for those types except the help tip is currently hardcoded to `after the function name` - which should change dependent on the item.
  - [x] I am planning to not show the suggestion if there is already a `<` after the item identifier, (i.e. if there are already generics, as after a function name per the original issue). Any major objections?
  - [x] Is the style of error okay? I wasn't sure if there was a way to make it display nicer, or if thats handled by span_suggestion

These aren't blocking questions, and I will keep working on:
  - check if there is a `<` after the ident (and if so, not showing the suggestion)
  - generalize the help message
  - figuring out how to write/run/etc ui tests (including reading the docs for them)
  - logic cleanups
2023-02-14 18:02:50 +01:00
IQuant
5c7afde6f2 Port PlaceholderRelationLfNotSatisfied diagnostic 2023-02-14 18:56:22 +03:00
IQuant
fdbec623c4 Port ConsiderAddingAwait 2023-02-14 18:55:54 +03:00
IQuant
9f06c3d87f Port SuggestRemoveSemiOrReturnBinding 2023-02-14 18:31:45 +03:00
Nikita Tomashevich
6fa4c7d89c Make sure tests pass 2023-02-14 18:31:45 +03:00
Nikita Tomashevich
b8feb63345 Port WhereClauseSuggestions 2023-02-14 18:31:45 +03:00