Commit Graph

22217 Commits

Author SHA1 Message Date
Kyle Matsuda
382ade6a60 fix ugly skip_binder 2023-02-16 10:52:57 -07:00
Kyle Matsuda
d659c7c343 make issue33140_self_ty return Option<EarlyBinder<Ty>> 2023-02-16 10:52:57 -07:00
Matthias Krüger
a1a6588162 don't into self
don't into()-convert types to themselves
2023-02-16 18:30:25 +01:00
Tshepang Mbambo
f9972313ae fix some lines, and do a consistency fix 2023-02-16 18:58:08 +02:00
Matthias Krüger
d77b0221f8
Rollup merge of #108115 - eggyal:unmet_trait_alias_bound, r=compiler-errors
Do not ICE on unmet trait alias bounds

Rework of #108093 following feedback on that PR.

Fixes #108072

r? `@compiler-errors`
2023-02-16 17:51:26 +01:00
Matthias Krüger
09a2267e1d
Rollup merge of #108099 - matthiaskrgr:str_to_char, r=GuillaumeGomez
use chars instead of strings where applicable
2023-02-16 17:51:26 +01:00
Matthias Krüger
2dc21c0a10
Rollup merge of #108092 - BelovDV:fix-feature-description-pbl, r=petrochenkov
note issue for feature(packed_bundled_libs)

Add to feature (introduced in #105601) gate description number of issue created for it.

r? `@petrochenkov`
2023-02-16 17:51:25 +01:00
Matthias Krüger
64a4f70c17
Rollup merge of #108090 - WaffleLapkin:if_not_now_then_when…, r=oli-obk
`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`

Resurrection of #108079
2023-02-16 17:51:25 +01:00
Matthias Krüger
f65c6e416c
Rollup merge of #106347 - estebank:removal-suggestion, r=TaKO8Ki
More accurate spans for arg removal suggestion

Partially address #106304.
2023-02-16 17:51:24 +01:00
bors
c5d1b3ea96 Auto merge of #108020 - nnethercote:opt-mk_region, r=compiler-errors
Optimize `mk_region`

PR #107869 avoiding some interning under `mk_ty` by special-casing `Ty` variants with simple (integer) bodies. This PR does something similar for regions.

r? `@compiler-errors`
2023-02-16 16:11:54 +00:00
Maybe Waffle
5bf6a46032 Replace some thens with some then_somes 2023-02-16 15:26:03 +00:00
Maybe Waffle
8751fa1a9a if $c:expr { Some($r:expr) } else { None } =>> $c.then(|| $r) 2023-02-16 15:26:00 +00:00
John Kåre Alsaker
caf29b2727 Remove parallel compiler fix 2023-02-16 14:55:05 +01:00
John Kåre Alsaker
1ae1eac7d2 Add some comments and use inline(always) on query_provided_to_value 2023-02-16 14:55:05 +01:00
John Kåre Alsaker
067bf2ac13 Move provider fields back to rustc_query_impl 2023-02-16 14:55:05 +01:00
John Kåre Alsaker
265e1e968d Use dropless arena when possible 2023-02-16 14:55:05 +01:00
John Kåre Alsaker
a51a20531d Factor query arena allocation out from query caches 2023-02-16 14:54:53 +01:00
Ben Kimock
1409cb59b2 Enable instcombine for mutable reborrows 2023-02-16 07:51:23 -05:00
Alan Egerton
540bd986aa
Do not ICE on unmet trait alias bounds 2023-02-16 11:18:08 +00:00
BelovDV
b488508c17 note issue for feature(packed_bundled_libs) 2023-02-16 14:09:55 +03:00
bors
af3c8b2726 Auto merge of #101841 - nnethercote:rm-save-analysis, r=Mark-Simulacrum
Remove save-analysis.

Most tests involving save-analysis were removed, but I kept a few where the `-Zsave-analysis` was an add-on to the main thing being tested, rather than the main thing being tested.

Closes https://github.com/rust-lang/rust/issues/43606
2023-02-16 10:35:44 +00:00
bors
4b34c7b766 Auto merge of #108116 - Dylan-DPC:rollup-h3n2vxl, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #106372 (Use id-based thread parking on SOLID)
 - #108050 (Fix index out of bounds ICE in `point_at_expr_source_of_inferred_type`)
 - #108084 (Constify `RangeBounds`, `RangeX::contains` and `RangeX::is_empty` (where applicable).)
 - #108101 (don't clone types that are copy)
 - #108102 (simplify some refs)
 - #108103 (be nice and don't slice)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-16 07:15:13 +00:00
Dylan DPC
bb1e9846b2
Rollup merge of #108103 - matthiaskrgr:lice, r=compiler-errors
be nice and don't slice

These are already slices, no need to slice them again
2023-02-16 11:40:22 +05:30
Dylan DPC
7bde7b73f1
Rollup merge of #108102 - matthiaskrgr:ref, r=compiler-errors
simplify some refs
2023-02-16 11:40:21 +05:30
Dylan DPC
ef0b12189e
Rollup merge of #108101 - matthiaskrgr:noclonecopy, r=compiler-errors
don't clone types that are copy
2023-02-16 11:40:21 +05:30
Dylan DPC
5fac20f87c
Rollup merge of #108050 - martingms:issue-108042-fix, r=compiler-errors
Fix index out of bounds ICE in `point_at_expr_source_of_inferred_type`

There might be more type params than args to a method call, which leads to an index out of bounds panic.
I'm not familiar with this code at all, so unsure whether this is the right fix, but at least this patch fixes #108042 for me (I hit the same issue with similar code)
2023-02-16 11:40:20 +05:30
Nicholas Nethercote
22a5125a36 Remove save-analysis.
Most tests involving save-analysis were removed, but I kept a few where
the `-Zsave-analysis` was an add-on to the main thing being tested,
rather than the main thing being tested.

For `x.py install`, the `rust-analysis` target has been removed.

For `x.py dist`, the `rust-analysis` target has been kept in a
degenerate form: it just produces a single file `reduced.json`
indicating that save-analysis has been removed. This is necessary for
rustup to keep working.

Closes #43606.
2023-02-16 15:14:45 +11:00
bors
639377ed73 Auto merge of #107449 - saethlin:enable-copyprop, r=oli-obk
Enable CopyProp

r? `@tmiasko`

`@rustbot` label +A-mir-opt
2023-02-16 03:44:37 +00:00
Michael Goulet
95f35fe443 Deny some late-bound ty/ct in some positions, add tests 2023-02-16 03:39:59 +00:00
Michael Goulet
915703ca7a A bit more work on late-bound consts 2023-02-16 03:39:59 +00:00
Michael Goulet
3f521b3542 Be better about bound vars 2023-02-16 03:39:59 +00:00
Michael Goulet
52f82354dc Make things actually work 2023-02-16 03:39:59 +00:00
Michael Goulet
eff2cb7760 Rename some region-specific stuff 2023-02-16 03:39:59 +00:00
Michael Goulet
262a344d72 Add feature gate for non_lifetime_binders 2023-02-16 03:39:58 +00:00
bors
dc7a676778 Auto merge of #108096 - matthiaskrgr:rollup-ncexzf6, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #107034 (Migrating rustc_infer to session diagnostics (part 4))
 - #107972 (Fix unintentional UB in ui tests)
 - #108010 (Make `InferCtxt::can_eq` and `InferCtxt::can_sub` return booleans)
 - #108021 (make x look for x.py if shell script does not exist)
 - #108047 (Use `target` instead of `machine` for mir interpreter integer handling.)
 - #108049 (Don't suggest `#[doc(hidden)]` trait methods with matching return type)
 - #108066 (Better names for illegal impl trait positions)
 - #108076 (rustdoc: Use more let chain)
 - #108088 (clarify correctness of `black_box`)
 - #108094 (Demonstrate I/O in File examples)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-16 00:12:54 +00:00
Matthias Krüger
e17cd0c019 be nice and don't slice
These are already slices, no need to slice them again
2023-02-16 00:06:51 +01:00
Matthias Krüger
46f895cadd simplify some refs 2023-02-15 23:48:01 +01:00
Matthias Krüger
e087f61075 don't clone types that are copy 2023-02-15 23:34:25 +01:00
Matthias Krüger
0400c68517 use chars instead of strings where applicable 2023-02-15 22:54:57 +01:00
b-naber
758cc95763 exhaustive matching in get_ambient_variance 2023-02-15 21:13:12 +00:00
bors
c5283576ec Auto merge of #108012 - compiler-errors:issue-107999, r=oli-obk
Don't ICE in `might_permit_raw_init` if reference is polymorphic

Emitting optimized MIR for a polymorphic function may require computing layout of a type that isn't (yet) known. This happens in the instcombine pass, for example. Let's fail gracefully in that condition.

cc `@saethlin`
fixes #107999
2023-02-15 20:56:07 +00:00
Matthias Krüger
8259755069
Rollup merge of #108066 - compiler-errors:better-labels-for-bad-impl-trait, r=petrochenkov
Better names for illegal impl trait positions

Just some wording tweaks, no behavior changes.
2023-02-15 21:30:58 +01:00
Matthias Krüger
897f56ed28
Rollup merge of #108049 - clubby789:dont-suggest-unstable, r=compiler-errors
Don't suggest `#[doc(hidden)]` trait methods with matching return type

Fixes #107983, addressing the bad suggestion.
The test can probably be made more specific to this  case, but I'm unsure how.

`@rustbot` label +A-diagnostics
2023-02-15 21:30:58 +01:00
Matthias Krüger
31d7e514ab
Rollup merge of #108047 - oli-obk:machine->🞋, r=RalfJung
Use `target` instead of `machine` for mir interpreter integer handling.

The naming of `machine` only makes sense from a mir interpreter internals perspective, but outside users talk about the `target` platform. As per https://github.com/rust-lang/rust/pull/108029#issuecomment-1429791015

r? `@RalfJung`
2023-02-15 21:30:57 +01:00
Matthias Krüger
8f65e25aec
Rollup merge of #108010 - compiler-errors:can_eq-returns-bool, r=lcnr
Make `InferCtxt::can_eq` and `InferCtxt::can_sub` return booleans

Nobody matches on the result, nor does the result return anything useful...
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
Maybe Waffle
a32d392741 Copy ty::AssocItem all other the place 2023-02-15 20:22:41 +00:00
Maybe Waffle
236ddf36b3 Remove arena_cache modifier from queries which return Copy types 2023-02-15 20:13:59 +00:00
Martin Gammelsæter
e159c1e0ec Skip method calls with arity mismatch 2023-02-15 18:52:23 +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
Alex Crichton
d90f7df674 wasm: Register the relaxed-simd target feature
This WebAssembly proposal is likely to reach stage 4 soon so this starts
the support in Rust for the proposal by adding a target feature that can
be enabled via attributes for the stdarch project to bind the
intrinsics.
2023-02-15 08:13:32 -08:00
clubby789
f4de121951 Don't suggest #[doc(hidden)] methods 2023-02-15 12:31:38 +00:00
Oli Scherer
38b7cdf393 Use target instead of machine for mir interpreter integer handling.
The naming of `machine` only makes sense from a mir interpreter internals perspective, but outside users talk about the `target` platform
2023-02-15 08:56:18 +00: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
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
Wesley Norris
19714385e0 Add kernel-address sanitizer support for freestanding targets 2023-02-14 20:54:25 -05:00
Michael Goulet
3f80017f03 Better label for illegal impl trait types 2023-02-14 23:12:27 +00:00
Michael Goulet
b096f0e0f0 Make permit_uninit/zero_init fallible 2023-02-14 22:37:30 +00:00
Nicholas Nethercote
9a53cee868 Replace an unnecessary mk_ty call with mk_array. 2023-02-15 09:04:21 +11:00
Nicholas Nethercote
a4d3c9a1a4 Pre-intern some ReVars and ReLateBounds. 2023-02-15 09:02:44 +11:00
Nicholas Nethercote
cef9004f5a Add specialized variants of mk_region.
Much like there are specialized variants of `mk_ty`. This will enable
some optimization in the next commit.

Also rename the existing `re_error*` functions as `mk_re_error*`, for
consistency.
2023-02-15 09:02:44 +11:00
Nicholas Nethercote
7439028374 Remove reuse_or_mk_region.
It's not used on any hot paths, and so has little perf benefit, and it
interferes with the optimizations in the following commits.
2023-02-15 09:02:44 +11: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
Esteban Küber
dff10d0668 Re-add replacement logic and add comment explaining it 2023-02-14 20:22:10 +00:00
Esteban Küber
755252bf51 Show the effects of weird code commented out 2023-02-14 20:22:10 +00:00
Esteban Küber
bd176ee591 Make removal suggestion not verbose 2023-02-14 20:22:10 +00:00
Esteban Küber
5d63e10318 rebase and review comments 2023-02-14 20:22:10 +00:00
Esteban Küber
287cd5974c Avoid trailing commas 2023-02-14 20:22:10 +00:00
Esteban Küber
fb61f5d781 Fix fmt 2023-02-14 20:22:09 +00:00
Esteban Küber
f02d8ec15e More accurate spans for arg removal suggestion 2023-02-14 20:22:09 +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
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
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
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
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
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
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
John Kåre Alsaker
b3a4fe7d4e Pass DepContext and QueryContext by value when practical 2023-02-14 17:21:18 +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
Nikita Tomashevich
8d590dc303 Resolve rebase 2023-02-14 18:31:45 +03:00
Nikita Tomashevich
35dbec338a Port another diagnostic 2023-02-14 18:31:45 +03:00
Nikita Tomashevich
cb8ea01096 Port RefLongerThanData 2023-02-14 18:31:45 +03:00
Nikita Tomashevich
58e901b6fd Port "BorrowedTooLong" diagnostic 2023-02-14 18:31:45 +03:00
Nikita Tomashevich
8fc5ba65e1 Port OutlivesContent, OutlivesBound, FUllfillReqLifetime, LfBoundNotSatisfied diagnostics 2023-02-14 18:31:45 +03:00
许杰友 Jieyou Xu (Joe)
e3f9db5fc3
Update lexer lifetime test 2023-02-14 23:25:01 +08:00
Martin Gammelsæter
22f853c620 Avoid looping past bounds of args
There might be more type params than args to a method call, which leads to an
index out of bounds panic.
2023-02-14 16:11:15 +01:00
Alan Egerton
3b510e88ef
Use derive attributes for uninteresting traversals 2023-02-14 15:09:40 +00:00
Ralf Jung
91d25168cd interpret: rename Pointer::from_addr → from_addr_invalid 2023-02-14 14:55:50 +01:00
Santiago Pastorino
26136c6224
Reduce visibility of some items 2023-02-14 10:17:07 -03:00
Santiago Pastorino
c8dae10f14
Check for overflow in evaluate_canonical_goal 2023-02-14 09:51:39 -03:00
Alan Egerton
26e3363c51
Refactor refcounted structural_impls via functors 2023-02-14 12:14:58 +00:00
Alan Egerton
9e2947a621
Ord entails its supertraits 2023-02-14 12:13:05 +00:00
lcnr
a2f03037b4 change the marker attribute to only_local 2023-02-14 12:18:33 +01:00
lcnr
51671cd435 add test for coinduction in new solver 2023-02-14 12:18:33 +01:00
lcnr
646e667200 add a #[rustc_coinductive] attribute 2023-02-14 11:53:22 +01:00
Oli Scherer
241c6a4a61 Simplify expansion logic 2023-02-14 10:01:49 +00:00
Oli Scherer
d15663814b Inline the expansion query 2023-02-14 10:01:40 +00:00
Oli Scherer
21f4c0723e Remove BoxedResolver 2023-02-14 10:01:30 +00:00
Oli Scherer
43a5cc383d Separate the lifetime of the session and the arena in the resolver 2023-02-14 10:01:25 +00:00
bors
9bb6e60d1f Auto merge of #103695 - LYF1999:yf/103563, r=lcnr
fix: Unexpected trait bound not satisfied in HRTB and Associated Type

fix https://github.com/rust-lang/rust/issues/103563
2023-02-14 10:01:19 +00:00
许杰友 Jieyou Xu (Joe)
380fa26413
Don't recover lifetimes/labels containing emojis as character literals
Note that at the time of this commit, `unic-emoji-char` seems to have
data tables only up to Unicode 5.0, but Unicode is already newer than
this.

A newer emoji such as `🥺` will not be recognized as an emoji
but older emojis such as `🐱` will.
2023-02-14 17:31:58 +08:00
Oli Scherer
936bf29d4c s/eval_usize/eval_target_usize/ for clarity 2023-02-14 08:51:19 +00:00
bors
e9ab7872fd Auto merge of #107765 - petrochenkov:nomoclone, r=oli-obk
rustc/rustdoc: Perform name resolver cleanups enabled by #94857

Unblocks https://github.com/rust-lang/rust/pull/105462.
r? `@oli-obk`
2023-02-14 05:59:44 +00:00
yukang
3180f1c828 Fix #107998, avoid ICE when the generic_span is empty 2023-02-14 03:46:43 +00:00
Michael Goulet
087a0136d0 Don't ICE in might_permit_raw_init if reference is polymorphic 2023-02-14 01:03:06 +00:00
Matthias Krüger
5f3d360844
Rollup merge of #107942 - compiler-errors:tighter-inherent-impl-bad-spans, r=Nilstrieb
Tighter spans for bad inherent `impl` self types

Self-explanatory
2023-02-13 23:25:12 +01:00
Matthias Krüger
73b022b8e1
Rollup merge of #107902 - vincenzopalazzo:macros/async_fn_suggestion, r=compiler-errors
fix: improve the suggestion on future not awaited

Considering the following code

```rust
fn foo() -> u8 {
    async fn async_fn() -> u8 {  22 }

    async_fn()
}

fn main() {}
```

the error generated before this commit from the compiler is

```
➜  rust git:(macros/async_fn_suggestion) ✗ rustc test.rs --edition 2021
error[E0308]: mismatched types
 --> test.rs:4:5
  |
1 | fn foo() -> u8 {
  |             -- expected `u8` because of return type
...
4 |     async_fn()
  |     ^^^^^^^^^^ expected `u8`, found opaque type
  |
  = note:     expected type `u8`
          found opaque type `impl Future<Output = u8>`
help: consider `await`ing on the `Future`
  |
4 |     async_fn().await
  |               ++++++

error: aborting due to previous error
```

In this case the error is nor perfect, and can confuse the user that do not know that the opaque type is the future.

So this commit will propose (and conclude the work start in https://github.com/rust-lang/rust/issues/80658)
to change the string `opaque type` to `future` when applicable and also remove the Expected vs Received note by adding a more specific one regarding the async function that return a future type.

So the new error emitted by the compiler is

```
error[E0308]: mismatched types
 --> test.rs:4:5
  |
1 | fn foo() -> u8 {
  |             -- expected `u8` because of return type
...
4 |     async_fn()
  |     ^^^^^^^^^^ expected `u8`, found future
  |
note: calling an async function returns a future
 --> test.rs:4:5
  |
4 |     async_fn()
  |     ^^^^^^^^^^
help: consider `await`ing on the `Future`
  |
4 |     async_fn().await
  |               ++++++

error: aborting due to previous error
```

Fixes https://github.com/rust-lang/rust/issues/80658

It remains to rework the case described in the following issue https://github.com/rust-lang/rust/issues/107899 but I think this deserves its own PR after we discuss a little bit how to handle these kinds of cases.

r? `@eholk`

`@rustbot` label +I-async-nominated

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-02-13 23:25:11 +01:00
Michael Goulet
eb286dd070 Make can_eq and can_sub return booleans 2023-02-13 19:29:02 +00:00
Michael Goulet
3504c408f0 Use is_str instead of string kind comparison 2023-02-13 19:06:22 +00:00
Michael Goulet
e20f6ff1dc Tighter spans for bad inherent impl types 2023-02-13 18:41:18 +00:00
Santiago Pastorino
826bee7085
Implement repeat_while_none for both SearchGraph and EvalCtxt 2023-02-13 14:45:39 -03:00
Santiago Pastorino
873c83ba56
Extract try_move_finished_goal_to_global_cache from try_finalize_goal 2023-02-13 14:45:37 -03:00
Santiago Pastorino
44a2388828
Make Ok value of repeat_while_none more general 2023-02-13 14:44:18 -03:00
Camille GILLOT
09797a463c Typo. 2023-02-13 17:01:03 +00:00
bors
a3c9eede5d Auto merge of #107924 - eggyal:move_fold_visit_traits_to_type_lib_with_trait_alias, r=oli-obk
Move folding & visiting traits into type library

This is a rework of #107712, following feedback on that PR.

In particular, this version uses trait aliases to reduce the API churn for trait consumers.  Doing so requires a workaround for #107747 until its fix in #107803 is merged into the stage0 compiler; this workaround, which uses conditional compilation based on the `bootstrap` configuration predicate, sits in dedicated commit b409329c for ease of reversion.

The possibility of the `rustc_middle` crate retaining its own distinct versions of each folding/visiting trait, blanket-implemented on all types that implement the respective trait in the type library, was also explored: however since this would necessitate making each `rustc_middle` trait a subtrait of the respective type library trait (so that such blanket implementations can delegate their generic methods), no benefit would be gained.

r? types
2023-02-13 16:50:33 +00:00
Vincenzo Palazzo
2bdc9a046a
fix: improve the suggestion on future not awaited
Considering the following code

```rust
fn foo() -> u8 {
    async fn async_fn() -> u8 {  22 }

    async_fn()
}

fn main() {}
```

the error generated before this commit from the compiler is

```
➜  rust git:(macros/async_fn_suggestion) ✗ rustc test.rs --edition 2021
error[E0308]: mismatched types
 --> test.rs:4:5
  |
1 | fn foo() -> u8 {
  |             -- expected `u8` because of return type
...
4 |     async_fn()
  |     ^^^^^^^^^^ expected `u8`, found opaque type
  |
  = note:     expected type `u8`
          found opaque type `impl Future<Output = u8>`
help: consider `await`ing on the `Future`
  |
4 |     async_fn().await
  |               ++++++

error: aborting due to previous error
```

In this case the error is nor perfect, and can confuse the user
that do not know that the opaque type is the future.

So this commit will propose (and conclude the work start in
https://github.com/rust-lang/rust/issues/80658)
to change the string `opaque type` to `future` when applicable
and also remove the Expected vs Received note by adding a more
specific one regarding the async function that return a future type.

So the new error emitted by the compiler is

```
error[E0308]: mismatched types
 --> test.rs:4:5
  |
1 | fn foo() -> u8 {
  |             -- expected `u8` because of return type
...
4 |     async_fn()
  |     ^^^^^^^^^^ expected `u8`, found future
  |
note: calling an async function returns a future
 --> test.rs:4:5
  |
4 |     async_fn()
  |     ^^^^^^^^^^
help: consider `await`ing on the `Future`
  |
4 |     async_fn().await
  |               ++++++

error: aborting due to previous error
```

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-02-13 16:23:23 +01:00
yifei
d164448038 fix: Unexpected trait bound not satisfied in HRTB 2023-02-13 19:39:44 +08:00
Matthias Krüger
8701e80722
Rollup merge of #107986 - lcnr:layout-placeholder, r=petrochenkov
layout: deal with placeholders, ICE on bound types

A placeholder type is the same as a param as they represent "this could be any type". A bound type represents a type inside of a `for<T>` or `exists<T>`. When entering a forall or exists `T` should be instantiated as a existential (inference var) or universal (placeholder). You should never observe a bound variable without its binder.
2023-02-13 11:34:59 +01:00
Matthias Krüger
99d36b137d
Rollup merge of #107935 - petrochenkov:attreorder, r=michaelwoerister
rustc_ast: Merge impls and reorder methods for attributes and meta items

Merge `impl` blocks for the same types, change order of methods to be more predictable and consistent between impls.
No functional changes.
Follow up to https://github.com/rust-lang/rust/pull/107569.
2023-02-13 11:34:58 +01:00
Matthias Krüger
3e5c11b855
Rollup merge of #107931 - cjgillot:issue-107353, r=WaffleLapkin
Intern span when length is MAX_LEN with parent.

Fixes https://github.com/rust-lang/rust/issues/107353
2023-02-13 11:34:58 +01:00
Matthias Krüger
780beae7bd
Rollup merge of #107838 - estebank:terminal_hyperlinks, r=nagisa
Introduce `-Zterminal-urls` to use OSC8 for error codes

Terminals supporting the OSC8 Hyperlink Extension can support inline anchors where the text is user defineable but clicking on it opens a browser to a specified URLs, just like `<a href="URL">` does in HTML.

https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
2023-02-13 11:34:57 +01:00
Alan Egerton
63ad5d0522
Rename folder traits' tcx method to interner 2023-02-13 10:24:51 +00:00
Alan Egerton
459e142413
Move folding and visiting traits into type library 2023-02-13 10:24:50 +00:00
Alan Egerton
9fa6bb2aa0
Make atomic structural impls generic over Interner 2023-02-13 10:24:50 +00:00
Alan Egerton
9783fcc13b
Make folding traits generic over the Interner 2023-02-13 10:24:49 +00:00
Alan Egerton
dea342d861
Make visiting traits generic over the Interner 2023-02-13 10:24:49 +00:00
Alan Egerton
0b7dda9afd
Constrain Interners to be Sized 2023-02-13 10:24:48 +00:00
Alan Egerton
38c522c693
Project Binder and Predicate from Interner trait 2023-02-13 10:24:48 +00:00
Alan Egerton
e8d152d2f4
Move TypeVisitableExt from ir module 2023-02-13 10:24:47 +00:00
Alan Egerton
b409329c62
Workaround issue #107747
Only required until fix #107803 is merged into stage0 compiler, expected
when beta 1.69.0 is released on 2023-03-09, then this commit can be
reverted.
2023-02-13 10:24:47 +00:00
Alan Egerton
36d09e3906
Split TypeVisitableExt from TypeVisitable 2023-02-13 10:24:47 +00:00
Alan Egerton
ba55a453eb
Alias folding/visiting traits instead of re-export 2023-02-13 10:24:46 +00:00
Alan Egerton
62846d7c99
Move folding & visiting traits to ir submodules 2023-02-13 10:24:45 +00:00
lcnr
9e84b00d44 layout: deal with placeholders, ICE on bound types
a placeholder type is the same as a param as they
represent "this could be any type". A bound type
represents a type inside of a `for<T>` or `exists<T>`.
When entering a forall or exists `T` should be
instantiated as a existential (inference var) or universal
(placeholder). You should never observe a bound variable
without its binder.
2023-02-13 10:47:12 +01:00
bors
7740f9a571 Auto merge of #107869 - nnethercote:reduce-interning, r=compiler-errors
Reduce interning

r? `@compiler-errors`
2023-02-13 00:35:26 +00:00
Keith Smiley
aacf3213b1
Add sanitizer support for modern iOS platforms
asan and tsan generally support iOS, but that previously wasn't
configured in rust. This only adds support for the simulator
architectures, and arm64 device architecture, not the older 32 bit
architectures.
2023-02-12 16:00:31 -08:00
Nicholas Nethercote
e261665b2c Avoid interning empty tuples. 2023-02-13 09:32:51 +11:00
Nicholas Nethercote
7a72560154 Reduce direct mk_ty usage.
We use more specific `mk_*` functions in most places, might as well use
them as much as possible.
2023-02-13 09:32:48 +11:00
Nicholas Nethercote
6248bbbf26 Pre-intern some commonly used type variables.
This requires some rearrangement of plumbing, such as adding
`mk_fresh_{,int_,float_}ty` and removing `mk_ty_infer`.
2023-02-13 09:25:36 +11:00
b-naber
6e1d228285 only require sub type relation on field projection types 2023-02-12 23:18:15 +01:00
Ian Chamberlain
e723e43590
Enable #[thread_local] on armv6k-nintendo-3ds
Since libctru 2.1.2 was released
(https://github.com/devkitPro/libctru/releases/tag/v2.1.2) we should be
able to use real #[thread_local] without corruption issues on the 3DS
target.
2023-02-12 16:57:05 -05:00
Matthias Krüger
d29aba19d0
Rollup merge of #107748 - tshepang:renamed, r=cuviper
refer to new home

The module has since been made its own crate...
see 2d75a339ca.
2023-02-12 22:29:47 +01:00
Vadim Petrochenkov
efbf6547cf resolve: Fix doc links referring to other crates when documenting proc macro crates directly 2023-02-13 00:51:29 +04:00
Vadim Petrochenkov
fd73d01c98 rustc_resolve: Remove Resolver::clone_output
And remove `Clone` impls and `Lrc`s that are no longer necessary
2023-02-13 00:10:15 +04:00
Vadim Petrochenkov
9080b79f2b rustdoc: Eliminate remaining uses of resolver 2023-02-13 00:10:15 +04:00
Boxy
57ad73aa27 rename query and use NoSolution 2023-02-12 19:32:07 +00:00
Ben Kimock
640ede7b0a Enable CopyProp by default, tune the impl a bit 2023-02-12 13:23:53 -05:00
bors
5b8f284536 Auto merge of #107643 - Zoxc:single-cache, r=cjgillot
Create a single value cache for the () query key

Since queries using `()` as the key can only store a single value, specialize for that case.

This looks like a minor performance improvement:
<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</td><td align="right">1.8477s</td><td align="right">1.8415s</td><td align="right"> -0.33%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2666s</td><td align="right">0.2655s</td><td align="right"> -0.40%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">6.3943s</td><td align="right">6.3686s</td><td align="right"> -0.40%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.6413s</td><td align="right">1.6345s</td><td align="right"> -0.42%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">1.0337s</td><td align="right">1.0313s</td><td align="right"> -0.24%</td></tr><tr><td>Total</td><td align="right">11.1836s</td><td align="right">11.1414s</td><td align="right"> -0.38%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9964s</td><td align="right"> -0.36%</td></tr></table>
2023-02-12 17:20:33 +00:00
bors
adb4bfd25d Auto merge of #105671 - lukas-code:depreciate-char, r=scottmcm
Use associated items of `char` instead of freestanding items in `core::char`

The associated functions and constants on `char` have been stable since 1.52 and the freestanding items have soft-deprecated since 1.62 (https://github.com/rust-lang/rust/pull/95566). This PR ~~marks them as "deprecated in future", similar to the integer and floating point modules (`core::{i32, f32}` etc)~~ replaces all uses of `core::char::*` with `char::*` to prepare for future deprecation of `core::char::*`.
2023-02-12 11:09:06 +00:00
bors
51cb5614dd Auto merge of #105601 - BelovDV:change-rlib-with-not-stable, r=petrochenkov
Enable new rlib in non stable cases

If bundled static library uses cfg (unstable) or whole-archive (wasn't supported) bundled libs are packed even without packed_bundled_libs.

r? `@petrochenkov`
2023-02-12 07:15:27 +00:00
clubby789
903ca873f7 Suggest the correct array length on mismatch 2023-02-12 02:15:41 +00:00
Boxy
a85b0101e6 make relate's const ty assertion use semantic equality 2023-02-11 23:05:16 +00:00
John Kåre Alsaker
80d265240b Create a single value cache for the () query key 2023-02-11 23:38:01 +01:00
bors
585f3eef26 Auto merge of #107851 - cjgillot:sroa-const, r=oli-obk
Put deaggregated statements after original constant.

Fixes https://github.com/rust-lang/rust/issues/107818
2023-02-11 20:59:18 +00:00
Vadim Petrochenkov
37a72a2e3e rustc_ast: Merge impls and reorder methods for attributes and meta items 2023-02-11 23:23:17 +04:00
Camille GILLOT
e80afa6501 Intern span when length is MAX_LEN with parent. 2023-02-11 17:46:22 +00:00
Matthias Krüger
4b7b5698a4
Rollup merge of #107895 - matthiaskrgr:cl, r=compiler-errors
remove redundant clones
2023-02-11 17:18:44 +01:00
bors
5b45024487 Auto merge of #94857 - petrochenkov:doclink2, r=oli-obk
Resolve documentation links in rustc and store the results in metadata

This PR implements MCP https://github.com/rust-lang/compiler-team/issues/584.

Doc links are now resolved in rustc and stored into metadata, so rustdoc simply retrieves them through a query (local or extern),

Code that is no longer used is removed, and some code that no longer needs to be public is privatized.
The removed code includes resolver cloning, so this PR fixes https://github.com/rust-lang/rust/issues/83761.
2023-02-11 12:10:16 +00:00
bors
71f6675de1 Auto merge of #107919 - Dylan-DPC:rollup-fkl9swa, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #105019 (Add parentheses properly for borrowing suggestion)
 - #106001 (Stop at the first `NULL` argument when iterating `argv`)
 - #107098 (Suggest function call on pattern type mismatch)
 - #107490 (rustdoc: remove inconsistently-present sidebar tooltips)
 - #107855 (Add a couple random projection tests for new solver)
 - #107857 (Add ui test for implementation on projection)
 - #107878 (Clarify `new_size` for realloc means bytes)
 - #107888 (revert #107074, add regression test)
 - #107900 (Zero the `REPARSE_MOUNTPOINT_DATA_BUFFER` header)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-11 09:19:07 +00:00
bors
1623ab0246 Auto merge of #107507 - BoxyUwU:deferred_projection_equality, r=lcnr
Implement `deferred_projection_equality` for erica solver

Somewhat of a revival of #96912. When relating projections now emit an `AliasEq` obligation instead of attempting to determine equality of projections that may not be as normalized as possible (i.e. because of lazy norm, or just containing inference variables that prevent us from resolving an impl). Only do this when the new solver is enabled
2023-02-11 05:46:24 +00:00
Dylan DPC
745361d17d
Rollup merge of #107888 - lcnr:opaque-ty-validate, r=wesleywiser
revert #107074, add regression test

fixes #107346
2023-02-11 11:15:57 +05:30
Dylan DPC
400b03ac3c
Rollup merge of #107098 - compiler-errors:pat-mismatch-fn-call, r=lcnr
Suggest function call on pattern type mismatch

Fixes #101208

This could definitely be generalized to support more suggestions in pattern matches. We can't use all of [`FnCtxt::emit_type_mismatch_suggestions`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_typeck/fn_ctxt/struct.FnCtxt.html#method.emit_type_mismatch_suggestions), but it's on my to-do list to play around with more suggestions that would be productive in this position.
2023-02-11 11:15:55 +05:30
Dylan DPC
0781d5dd8e
Rollup merge of #105019 - chenyukang:yukang/fix-104961-borrow, r=cjgillot
Add parentheses properly for borrowing suggestion

Fixes #104961
2023-02-11 11:15:54 +05:30
Josh Stone
ffdbd58d85 Drop llvm14-builtins-abi with compiler_builtins 0.1.87 2023-02-10 16:13:31 -08:00
Josh Stone
a06aaa4a9e Update the minimum external LLVM to 14 2023-02-10 16:06:25 -08:00
bors
5a8dfd933a Auto merge of #85158 - JulianKnodt:array_const_val, r=cjgillot
Mir-Opt for copying enums with large discrepancies

I have been meaning to make this for quite a while, based off of this [hackmd](https://hackmd.io/`@ft4bxUsFT5CEUBmRKYHr7w/rJM8BBPzD).`

I'm not sure where to put this opt now that I've made it, so I'd appreciate suggestions on that!
It's also one long chain of statements, not sure if there's a more friendly format to make it.

r? `@tmiasko`
I would `r` oli but he's on leave so he suggested I `r` tmiasko or wesleywiser.
2023-02-10 21:49:31 +00:00
Michael Goulet
0eba2f3c16 Suggest fn call on pattern type mismatch 2023-02-10 18:18:08 +00:00
Matthias Krüger
5201bb53bb remove redundant clones 2023-02-10 18:08:25 +01:00
Boxy
fa83c10e96 implement compute_alias_eq_goal 2023-02-10 14:56:28 +00:00
Boxy
1f89e2aef2 emit AliasEq when relating type and const aliases 2023-02-10 14:33:13 +00:00
Matthias Krüger
1e106c1cf8
Rollup merge of #107882 - workingjubilee:fix-en-borrowck-ftl-typos, r=compiler-errors
Cleanup typos in en_US/borrowck.ftl

Noticed these while opening https://github.com/rust-lang/rust/pull/107881.
2023-02-10 15:28:50 +01:00
Matthias Krüger
d8e4d99001
Rollup merge of #107839 - RalfJung:rustc-log, r=oli-obk
avoid duplicating the RUSTC_LOG env var name

We also have the env var name here:
c40919b7a7/compiler/rustc_driver_impl/src/lib.rs (L1247-L1251)
Redundantly having this name twice doesn't seem great. Looks like `rustc_log::init_rustc_env_logger` is dead code anyway.

r? `@oli-obk`
2023-02-10 15:28:48 +01:00
Matthias Krüger
d494cd3eab
Rollup merge of #107836 - chenyukang:yukang/fix-107822, r=oli-obk
Handle properly when there is no crate attrs

Fixes #107822

r? `@oli-obk`
2023-02-10 15:28:47 +01:00
Matthias Krüger
dc7559b599
Rollup merge of #107789 - jieyouxu:issue-107745, r=lcnr
Avoid exposing type parameters and implementation details sourced from macro expansions

Fixes #107745.

~~I would like to **request some guidance** for this issue, because I don't think this is a good fix (a band-aid at best).~~

### The Problem

The code

```rust
fn main() {
    println!("{:?}", []);
}
```

gets desugared into (`rustc +nightly --edition=2018 issue-107745.rs -Z unpretty=hir`):

```rust
#[prelude_import]
use std::prelude::rust_2018::*;
#[macro_use]
extern crate std;
fn main() {
        {
                ::std::io::_print(<#[lang = "format_arguments"]>::new_v1(&["",
                                    "\n"], &[<#[lang = "format_argument"]>::new_debug(&[])]));
            };
    }
```

so the diagnostics code tries to be as specific and helpful as possible, and I think it finds that `[]` needs a type parameter and so does `new_debug`. But since `[]` doesn't have an origin for the type parameter definition, it points to `new_debug` instead and leaks the internal implementation detail since all `[]` has is an type inference variable.

### ~~The Bad Fix~~

~~This PR currently tries to fix the problem by bypassing the generated function `<#[lang = "format_argument"]>::new_debug` to avoid its generic parameter (I think it is auto-generated from the argument `[_; 0]`?) from getting collected as an `InsertableGenericArg`. This is problematic because it also prevents the help from getting displayed.~~

~~I think this fix is not ideal and hard-codes the format generated code pattern, but I can't think of a better fix. I have tried asking on Zulip but no responses there yet.~~
2023-02-10 15:28:47 +01:00
lcnr
3a72238aa6 revert #107074 2023-02-10 15:24:39 +01:00
Ralf Jung
623ed8e481 fix rustc_log doctest 2023-02-10 15:07:55 +01:00
Boxy
23ab2464be add AliasEq to PredicateKind 2023-02-10 13:44:46 +00:00
Jubilee
1f76cea515 Cleanup typos in en_US/borrowck.ftl 2023-02-10 02:22:08 -08:00
bors
d1ac43a9b9 Auto merge of #107652 - estebank:re_error, r=oli-obk
Introduce `ReError`

CC #69314

r? `@nagisa`
2023-02-10 10:10:12 +00:00
Daniil Belov
601fc8b36b [link] enable packed bundled lib in non stable cases 2023-02-10 12:51:12 +03:00
yukang
257389882d add test for no input file 2023-02-10 08:02:56 +00:00
bors
9b8dbd558c Auto merge of #107870 - matthiaskrgr:rollup-3z1q4rm, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #107043 (Support `true` and `false` as boolean flag params)
 - #107831 (Query refactoring)
 - #107841 (Handled snap curl issue inside Rust)
 - #107852 (rustdoc: remove unused fn parameter `tab`)
 - #107861 (Sync release notes for 1.67.1)
 - #107863 (Allow multiple candidates with same response in new solver)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-10 06:20:01 +00:00
Vadim Petrochenkov
da4ce6b41e Skip doc link resolution for some crate types and non-exported items 2023-02-10 09:35:14 +04:00
Vadim Petrochenkov
3b0866272a Stop resolving doc links on mod items twice 2023-02-10 09:34:13 +04:00
Vadim Petrochenkov
b62b82aef4 Resolve documentation links in rustc and store the results in metadata
This commit implements MCP https://github.com/rust-lang/compiler-team/issues/584

It also removes code that is no longer used, and that includes code cloning resolver, so issue #83761 is fixed.
2023-02-10 09:34:13 +04:00
Matthias Krüger
9300617dab
Rollup merge of #107863 - compiler-errors:new-solver-multiple-candidates, r=jackh726
Allow multiple candidates with same response in new solver

Treat >1 candidates as *not* ambiguous if they return the same response.
2023-02-10 06:09:59 +01:00
Matthias Krüger
11e128025a
Rollup merge of #107831 - nnethercote:query-refactoring, r=oli-obk
Query refactoring

Just some cleanups I found when learning about the query system.

Best reviewed one commit at a time.

r? `@oli-obk`
2023-02-10 06:09:57 +01:00
Matthias Krüger
8fc9ed51f0
Rollup merge of #107043 - Nilstrieb:true-and-false-is-false, r=wesleywiser
Support `true` and `false` as boolean flag params

Implements [MCP 577](https://github.com/rust-lang/compiler-team/issues/577).
2023-02-10 06:09:56 +01:00
bors
a697573463 Auto merge of #101680 - jackh726:implied-cleanup, r=lcnr
Fix implied outlives bounds logic for projections

The logic here is subtly wrong. I put a bit of an explanation in a767d7b5165cea8ee5cbe494a4a636c50ef67c9c.

TL;DR: we register outlives predicates to be proved, because wf code normalizes projections (from the unnormalized types) to type variables. This causes us to register those as constraints instead of implied. This was "fine", because we later added that implied bound in the normalized type, and delayed registering constraints. When I went to cleanup `free_region_relations` to *not* delay adding constraints, this bug was uncovered.

cc. `@aliemjay` because this caused your test failure in #99832 (I only realized as I was writing this)

r? `@nikomatsakis`
2023-02-10 03:21:39 +00:00
Jack Huey
0637b6b471 Update implied_outlives_bounds to properly register implied bounds behind normalization 2023-02-09 21:08:11 -05:00
Jack Huey
1a663c0f53 Cleanup free_region_relations a bit 2023-02-09 20:38:27 -05:00
Michael Goulet
3c4e1f85cb Multiple candidates with same response is not ambiguous 2023-02-10 00:35:25 +00:00
bors
a12d31d5a6 Auto merge of #102963 - ilammy:xray-basic, r=estebank
Add `-Z instrument-xray` flag

Implement MCP https://github.com/rust-lang/compiler-team/issues/561, adding `-Z instrument-xray` flag which enables XRay instrumentation in LLVM.
2023-02-10 00:02:43 +00:00
Dylan DPC
b080a1a4fc
Rollup merge of #107815 - compiler-errors:new-solver-no-auto-if-impl, r=lcnr
Disqualify `auto trait` built-in impl in new solver if explicit `impl` exists
2023-02-09 23:18:37 +05:30
Dylan DPC
16a4138387
Rollup merge of #107803 - eggyal:do_not_bring_trait_alias_supertraits_into_scope, r=compiler-errors
Do not bring trait alias supertraits into scope

Fixes #107747
cc #41517
2023-02-09 23:18:36 +05:30
Dylan DPC
39ba11036a
Rollup merge of #107786 - compiler-errors:new-solver-some-tweaks, r=lcnr
Implement some tweaks in the new solver

I've been testing the new solver on some small codebases, and these are a few small changes I've needed to make.

The most "controversial" here is implementing `trait_candidate_should_be_dropped_in_favor_of`, which I just implemented to always return false. This surprisingly allows some code to compile, without us having to actually decide on any semantics yet.

r? `@rust-lang/initiative-trait-system-refactor`
2023-02-09 23:18:35 +05:30
Dylan DPC
5aa062e249
Rollup merge of #107659 - bvanjoi:issue-107649, r=estebank
test: snapshot for derive suggestion in diff files

fixed #107649
2023-02-09 23:18:35 +05:30
Dylan DPC
be1789a56d
Rollup merge of #107648 - matthiaskrgr:unused_lifetime_104432_fix, r=cjgillot
unused-lifetimes: don't warn about lifetimes originating from expanded code

previously, we would warn like this:

````
warning: lifetime parameter `'s` never used
 --> /tmp/unusedlif/code.rs:6:62
  |
5 | #[derive(Clone)]
  |          - help: elide the unused lifetime
6 | struct ShimMethod4<T: Trait2 + 'static>(pub &'static dyn for<'s> Fn(&'s mut T::As));
  |                                                              ^^
  |
  = note: requested on the command line with `-W unused-lifetimes`
````

Fixes #104432
2023-02-09 23:18:34 +05:30
Camille GILLOT
221ea3080d Put deaggregated statements after original constant. 2023-02-09 17:27:31 +00:00
Michael Goulet
68e27b3052 Disqualify auto-trait builtin impl in new solver if impl exists 2023-02-09 17:23:50 +00:00
Michael Goulet
654f43f34e Move winnowing to assembly 2023-02-09 17:22:39 +00:00
Michael Goulet
8987e68247 Implement a dummy drop-in-favor-of for the new solver 2023-02-09 17:22:37 +00:00
Michael Goulet
8c67ecd124 Use elaborated item bounds for alias types 2023-02-09 17:16:47 +00:00
Michael Goulet
8dadd54f52 Fix subst issue with object_ty_for_trait 2023-02-09 17:16:47 +00:00
Esteban Küber
a576514e13 Introduce -Zterminal-urls to use OSC8 for error codes
Terminals supporting the OSC8 Hyperlink Extension can support inline
anchors where the text is user defineable but clicking on it opens a
browser to a specified URLs, just like `<a href="URL">` does in HTML.

https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
2023-02-09 14:52:54 +00:00
bohan
7615045ebd test: snapshot for derive suggestion in diff files 2023-02-09 22:28:53 +08:00
bors
8cca42a47f Auto merge of #107843 - bjorn3:sync_cg_clif-2023-02-09, r=bjorn3
Sync rustc_codegen_cranelift

* Couple of bugfixes
* A significant runtime perf improvement
* Implemented sym and const support for inline asm
* Improved self profile integration

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2023-02-09 14:12:59 +00:00
bjorn3
e25566e20b Merge commit '7d53619064ab7045c383644cb445052d2a3d46db' into sync_cg_clif-2023-02-09 2023-02-09 12:38:16 +01:00
Esteban Küber
3689295a6b Use ErrorGuaranteed more in ReError 2023-02-09 10:38:45 +00:00
Esteban Küber
3222725538 Fix RegionKind: PartialEq to account for ReError 2023-02-09 10:26:50 +00:00
Esteban Küber
ed8651c7b8 Use 'static RegionVid for ReError 2023-02-09 10:26:50 +00:00
Esteban Küber
861f451235 Change to ReError(ErrorGuaranteed) 2023-02-09 10:26:49 +00:00
Esteban Küber
ffaf2a5c27 review comments 2023-02-09 10:26:49 +00:00
Esteban Küber
30cf7a3f51 Introduce ReError
CC #69314
2023-02-09 10:26:49 +00:00
Matthias Krüger
f2a2e298ba
Rollup merge of #107835 - tshepang:fmt, r=WaffleLapkin
use idiomatic formatting

Also, remove needless `else`
2023-02-09 11:21:59 +01:00
Matthias Krüger
a621769881
Rollup merge of #107752 - riverar:rafael/gnu_dlltool_temp_prefix, r=petrochenkov
Specify dlltool prefix when generating import libs

Ref: https://github.com/rust-lang/rust/pull/106610#issuecomment-1418221274

tl;dr: This PR adds an explicit dlltool temporary filename prefix. The prefix resolves a race condition by ensuring dlltool temporary files are siloed in an appropriate/unique Rust temporary directory.

---

GNU dlltool, as part of its import library generation logic, uses a bunch of temporary files on disk. In the interest of deterministic build runs, dlltool supports deterministic temporary filenames. The temporary filename prefix is automatically generated internally or can be explicitly specified via a `--temp-prefix` argument.

GNU dlltool **2.38** (that ships with `x86_64-12.2.0-release-posix-seh-rt_v10-rev0` [installed during CI](https://github.com/rust-lang/rust/blob/master/src/ci/scripts/install-mingw.sh)) generates a prefix based on the target library name ([source](https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=binutils/dlltool.c;h=d95bf3f5470b999fa3b30bc887791859f48d81d1;hb=20756b0fbe065a84710aa38f2457563b57546440#l3992)). The tool writes to files such as `target_dll_h.s` and `target_dll_s00203.o` in the current working directory.

This presents a problem when multiple instances of rustc_codegen_llvm are running to generate an import library (as part of the raw_dylib feature) for the same target library (e.g. kernel32) ([source](https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_llvm/src/back/archive.rs#L185-L196)). That is, dlltool instances race and may overwrite or delete files belonging to each other.

GNU dlltool **2.39**+ (not used in Rust CI) generates a prefix based on the output library path ([source](https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=binutils/dlltool.c;h=e2af20847009945b4c61a6fef08268fbb4429715;hb=b51c2fec1da205ea3e7354cbb3e253018d64873c#l3992)). The tool, when invoked as part of rustc_codegen_llvm, writes to files at paths such as `C_Users_Foo_AppData_Local_Temp_rustcOFqhXZ_target_lib_h.s`. (The output library path is normalized and non-alphanumeric characters are replaced with underscores.)
2023-02-09 11:21:58 +01:00
Matthias Krüger
3b9543c89d
Rollup merge of #107446 - clubby789:rustc-parse-diag-migrate, r=compiler-errors
Migrate some of `rustc_parse` to derive diagnostics

`@rustbot` label +A-translation
r? rust-lang/diagnostics
cc #100717
2023-02-09 11:21:57 +01:00
Ralf Jung
569c2fe54b avoid duplicating the RUSTC_LOG env var name 2023-02-09 11:18:21 +01:00
yukang
b940f5088e fix #107822, handle properly when there is no crate attrs 2023-02-09 09:11:25 +00:00
Tshepang Mbambo
b651679d90 use idiomatic formatting
Also, remove needless else
2023-02-09 10:57:52 +02:00
许杰友 Jieyou Xu (Joe)
b58347a9c6
Don't expose type parameters and implementation details from macro expansion 2023-02-09 15:15:15 +08:00
bors
c40919b7a7 Auto merge of #106938 - GuillaumeGomez:normalize-projection-field-ty, r=oli-obk
Add missing normalization for union fields types

Overshadows https://github.com/rust-lang/rust/pull/106808.
From the experiment https://github.com/rust-lang/rust/pull/103985.

In short, it allows to use projections as a type for union's fields.

cc `@compiler-errors`
r? `@oli-obk`
2023-02-09 07:08:19 +00:00
Nicholas Nethercote
243944c653 Remove QueryContext.
There is a type `QueryCtxt`, which impls the trait `QueryContext`.
Confusingly, there is another type `QueryContext`. The latter is (like
`TyCtxt`) just a pointer to a `GlobalContext`. It's not used much, e.g.
its `impl` block has a single method.

This commit removes `QueryContext`, replacing its use with direct
`GlobalCtxt` use.
2023-02-09 16:14:51 +11:00
Nicholas Nethercote
afbe167fbb Avoid some tls::with calls.
These are in places where a `tcx` is easily obtained.
2023-02-09 15:28:04 +11:00
Nicholas Nethercote
18f751df6a Simplify with_tlv. 2023-02-09 15:26:37 +11:00