Commit Graph

22629 Commits

Author SHA1 Message Date
Nilstrieb
b7a7077ba4 Give proper error message when tcx wasn't passed to decoder 2023-03-11 11:29:08 +01:00
bors
35a0961bbc Auto merge of #108977 - matthiaskrgr:rollup-1bnl1hu, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #108879 (Unconstrained terms should account for infer vars being equated)
 - #108936 (Rustdoc: don't hide anonymous reexport)
 - #108940 (Add myself to compiler reviewers list)
 - #108945 (Make some report and emit errors take DefIds instead of BodyIds)
 - #108946 (Document the resulting values produced when using `From<bool>` on floats)
 - #108956 (Make ptr::from_ref and ptr::from_mut in #106116 const.)
 - #108960 (Remove `body_def_id` from `Inherited`)
 - #108963 (only call git on git checkouts during bootstrap)
 - #108964 (Fix the docs for pointer method with_metadata_of)

Failed merges:

 - #108950 (Directly construct Inherited in typeck.)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-10 15:39:25 +00:00
bors
d5833423a0 Auto merge of #102256 - cjgillot:let-under, r=lcnr
Introduce a no-op `PlaceMention` statement for `let _ =`.

Fixes https://github.com/rust-lang/rust/issues/54003
Fixes https://github.com/rust-lang/rust/issues/80059
Split from https://github.com/rust-lang/rust/pull/101500

This PR introduces a new `PlaceMention` statement dedicated to matches that neither introduce bindings nor ascribe types.  Without this, all traces of the match would vanish from MIR, making it impossible to diagnose unsafety or use in #101500.

This allows to mark `let _ = <unsafe union access or dereference>` as requiring an unsafe block.
Nominating for lang team, as this introduces an extra error.
2023-03-10 11:55:59 +00:00
Matthias Krüger
671339cdb0
Rollup merge of #108960 - compiler-errors:no-body-def-id, r=cjgillot
Remove `body_def_id` from `Inherited`

We can just use the body id from the obligation cause.

Follow-up to #108945, only my commit is relevant.

r? `@cjgillot` cc `@spastorino`
2023-03-10 12:32:01 +01:00
Matthias Krüger
afd8558d62
Rollup merge of #108945 - spastorino:pass-def-id-instead-of-using-hir-id, r=compiler-errors
Make some report and emit errors take DefIds instead of BodyIds

Breaking off from #108915

r? `@compiler-errors`
2023-03-10 12:31:59 +01:00
Matthias Krüger
4bd32ac31d
Rollup merge of #108879 - compiler-errors:constrained-root-var, r=lcnr
Unconstrained terms should account for infer vars being equated

Follow-up from the canonicalization PR, wanted to break this one out so I can approve the other PR.

r? `@lcnr`
2023-03-10 12:31:58 +01:00
Michael Goulet
a8f905cdd9 Unconstrained terms should account for infer vars being equated 2023-03-10 04:08:09 +00:00
Michael Goulet
fd34549686 Remove body_def_id from Inherited 2023-03-09 23:25:23 +00:00
Santiago Pastorino
5b99723439
Make some report and emit errors take DefIds instead of BodyIds 2023-03-09 17:53:35 -03:00
Camille GILLOT
09dc10c9c2 Bug on PlaceMention in dest-prop. 2023-03-09 17:45:13 +00:00
Camille GILLOT
45f2a1af3b Document borrowck behaviour. 2023-03-09 17:45:13 +00:00
Camille GILLOT
b34a8a294d Pacify tidy. 2023-03-09 17:45:13 +00:00
Camille GILLOT
e107194b66 Ignore AscribeUserType in unsafeck to avoid duplicate diagnostics. 2023-03-09 17:45:13 +00:00
Camille GILLOT
4462bb54e3 Introduce a no-op PlaceMention statement for let _ =. 2023-03-09 17:45:13 +00:00
Matthias Krüger
bec7011a2c
Rollup merge of #108854 - Ezrashaw:improve-int-idents, r=oli-obk
feat/refactor: improve errors in case of ident with number at start

Improve parser code when we parse a integer (or float) literal but expect an identifier. We emit an error message saying that identifiers can't begin with numbers. This PR just improves that code and expands it to all identifiers. Note that I haven't implemented error recovery (this didn't exist before anyway), I might do that in a follow up PR.
2023-03-09 12:11:53 +01:00
Matthias Krüger
ac258e9e02
Rollup merge of #108294 - compiler-errors:arbitary-sugg-binder, r=TaKO8Ki
Place binder correctly for arbitrary trait bound suggestion

suggest `for<'a> &'a T: Trait` instead of `&'a T: for<'a> T`.
2023-03-09 12:11:52 +01:00
Ezra Shaw
252e0b3385
feat/refactor: improve errors in case of ident with number at start 2023-03-09 21:29:32 +13:00
bors
39f2657d11 Auto merge of #108920 - matthiaskrgr:rollup-qrr9a0u, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #108754 (Retry `pred_known_to_hold_modulo_regions` with fulfillment if ambiguous)
 - #108759 (1.41.1 supported 32-bit Apple targets)
 - #108839 (Canonicalize root var when making response from new solver)
 - #108856 (Remove DropAndReplace terminator)
 - #108882 (Tweak E0740)
 - #108898 (Set `LIBC_CHECK_CFG=1` when building Rust code in bootstrap)
 - #108911 (Improve rustdoc-gui/tester.js code a bit)
 - #108916 (Remove an unused return value in `rustc_hir_typeck`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-09 08:21:17 +00:00
bors
66a2d62210 Auto merge of #108178 - cjgillot:ssa-deref, r=oli-obk
Do not consider `&mut *x` as mutating `x` in `CopyProp`

This PR removes an unfortunate overly cautious case from the current implementation.

Found by https://github.com/rust-lang/rust/pull/105274 cc `@saethlin`
2023-03-09 04:50:38 +00:00
Matthias Krüger
a22c5f9581
Rollup merge of #108916 - fmease:rm-unused-ret-val, r=compiler-errors
Remove an unused return value in `rustc_hir_typeck`

Unused since #89580. Just something I noticed a while ago.

`@rustbot` label C-cleanup
2023-03-08 21:26:53 +01:00
Matthias Krüger
e6e82db307
Rollup merge of #108882 - compiler-errors:E0740, r=eholk
Tweak E0740

Also drive-by suppress E0740 if it's an unresolved type.
2023-03-08 21:26:52 +01:00
Matthias Krüger
4e84fbf8a0
Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiasko
Remove DropAndReplace terminator

#107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-08 21:26:51 +01:00
Matthias Krüger
2428083558
Rollup merge of #108839 - compiler-errors:canonicalize-the-root-var, r=lcnr
Canonicalize root var when making response from new solver

During trait solving, if we equate two inference variables `?0` and `?1` but don't equate them with any rigid types, then `InferCtxt::probe_ty_var` will return `Err` for both of these. The canonicalizer code will then canonicalize the variables independently(!), and the response will not reflect the fact that these two variables have been made equal.

This hinders inference and I also don't think it's sound? I haven't thought too much about it past that, so let's talk about it.

r? ``@lcnr``
2023-03-08 21:26:51 +01:00
Matthias Krüger
9408af97f5
Rollup merge of #108754 - compiler-errors:retry, r=oli-obk
Retry `pred_known_to_hold_modulo_regions` with fulfillment if ambiguous

Fixes #108721

The problem here is that when we're checking `is_sized_raw` during codegen on some type that has a lot of opaques in it, something emits several nested obligations that are individually ambiguous, but when processed together in a loop then apply modulo regions. Since the `evaluate_predicates_recursively` inner loop doesn't process predicates until they stop changing, we return `EvaluatedToAmbig`, which makes the sized check return false incorrectly. See:

f15f0ea739/compiler/rustc_trait_selection/src/traits/select/mod.rs (L596-L606)

... Compared to the analogous loop in the new solver:

f15f0ea739/compiler/rustc_trait_selection/src/solve/mod.rs (L481-L512)

To fix this, if we get ambiguous during `pred_known_to_hold_modulo_regions`, just retry the obligation in a fulfillment context.

--

Unfortunately... I don't have a test for this. I've only tested this locally. Pending minimization :/

r? types
2023-03-08 21:26:50 +01:00
Matthias Krüger
33c3036826
Rollup merge of #108901 - LYF1999:yf/108897, r=lcnr
fix: evaluate with wrong obligation stack

fix #108897
r? ``@lcnr``
2023-03-08 21:24:53 +01:00
Matthias Krüger
a95943b77d
Rollup merge of #108887 - nnethercote:rename-MapInPlace, r=lqd
Rename `MapInPlace` as `FlatMapInPlace`.

After removing the `map_in_place` method, which isn't much use because modifying every element in a collection such as a `Vec` can be done trivially with iteration.

r? ``@lqd``
2023-03-08 21:24:53 +01:00
Matthias Krüger
031b528052
Rollup merge of #108884 - compiler-errors:tweak-illegal-copy-impl-message, r=WaffleLapkin
Tweak illegal `Copy` impl message

The phrase "may not" can both mean "is not able to" and "possibly does not". Disambiguate this by just using "cannot".
``@Lokathor`` expressed being annoyed by this [here](https://twitter.com/Lokathor/status/1633200313544089602?s=20).

Also drive-by fix for this extremely noisy message: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6a37275bc810f7846bfe191845b7d11d.

r? diagnostics
2023-03-08 21:24:52 +01:00
Matthias Krüger
f6b8a9f6db
Rollup merge of #108883 - compiler-errors:post-norm-copy-err, r=BoxyUwU
Suppress copy impl error when post-normalized type references errors

Suppress spurious errors from the `Copy` impl validity check when fields have bad types *post*-normalization, instead of just pre-normalization.

----

The const-generics test regressed recently due to #107965, cc `````@BoxyUwU.`````
 * I think it's because `[_; 0u32]: Copy` now fails to hold because a nested obligation `ConstArgHasType(0u32, usize)` fails.
 * It's interesting that `[const_error]` shows up in the type only after normalization, though, but I'm pretty sure that it's due to the evaluate call that happens when normalizing unevaluated consts.
2023-03-08 21:24:51 +01:00
Matthias Krüger
1a9376dc47
Rollup merge of #108873 - WaffleLapkin:cmp, r=cjgillot
Simplify `sort_by` calls

small cleanup
2023-03-08 21:24:51 +01:00
Matthias Krüger
9b6b7a3e84
Rollup merge of #108846 - celinval:smir-poc, r=oli-obk
StableMIR: Proof-of-concept implementation + test

This PR is part of the [project Stable MIR](https://github.com/rust-lang/project-stable-mir). The PR deletes old re-exports from rustc_smir and introduces a proof-of-concept implementation for APIs to retrieve crate information.

The implementation follows the [design described here](https://hackmd.io/XhnYHKKuR6-LChhobvlT-g?view), but instead of using separate crates for the implementation, it uses separate modules inside `rustc_smir`.

The API introduced at this point should be seen just as an example on how we are planning to structure the communication between tools and the compiler.

I have not explored yet what should be the right granularity, the best starting point for users, neither the best way to implement it.

r? ``````@oli-obk``````
2023-03-08 21:24:50 +01:00
León Orell Valerian Liehr
a74e651e36
clean-up: remove unused return value in typeck 2023-03-08 19:18:22 +01:00
bors
7c306f6dcd Auto merge of #108121 - aliemjay:resolve-var-region, r=lcnr
always resolve to universal regions if possible

`RegionConstraintCollector::opportunistic_resolve_var`, which is used in canonicalization and projection logic, doesn't resolve the region var to an equal universal region. So if we have equated `'static == '1 == '2`, it doesn't resolve `'1` or `'2` to `'static`. Now it does!

Addresses review comment https://github.com/rust-lang/rust/pull/107376#discussion_r1093233687.

r? `@lcnr`
2023-03-08 12:33:21 +00:00
yifei
204ba3224e fix: evaluate with wrong obligation stack 2023-03-08 20:12:46 +08:00
Ali MJ Al-Nasrawy
0b232d022f prefer universal from lower universe
In case a variable is unified with two universal regions from different
universes, use the one with the lower universe as it has a higher chance
of being compatible with the variable.
2023-03-08 15:10:37 +03:00
Ali MJ Al-Nasrawy
228f40820d address review comment 2023-03-08 14:07:01 +03:00
bors
9b60e6c68f Auto merge of #108312 - michaelwoerister:hash-set-not-hash-stable, r=eholk
Do not implement HashStable for HashSet (MCP 533)

This PR removes all occurrences of `HashSet` in query results, replacing it either with `FxIndexSet` or with `UnordSet`, and then removes the `HashStable` implementation of `HashSet`. This is part of implementing [MCP 533](https://github.com/rust-lang/compiler-team/issues/533), that is, removing the `HashStable` implementations of all collection types with unstable iteration order.

The changes are mostly mechanical. The only place where additional sorting is happening is in Miri's override implementation of the `exported_symbols` query.
2023-03-08 06:07:11 +00:00
Nicholas Nethercote
be60bcb28a Rename MapInPlace as FlatMapInPlace.
After removing the `map_in_place` method, which isn't much use because
modifying every element in a collection such as a `Vec` can be done
trivially with iteration.
2023-03-08 15:53:56 +11:00
Michael Goulet
64eea3c47a Tweak E0740 2023-03-08 01:58:15 +00:00
Michael Goulet
08e5a77b06 Don't report E0740 for type error 2023-03-08 01:55:32 +00:00
Michael Goulet
8a99ffc344 Suppress copy impl error when post-normalized type references errors 2023-03-08 00:12:33 +00:00
Michael Goulet
0f4255ece2 Dedup copy field errors for identical types 2023-03-08 00:00:19 +00:00
Michael Goulet
a439c0293c may not => cannot 2023-03-08 00:00:18 +00:00
bors
38b9655311 Auto merge of #108877 - matthiaskrgr:rollup-7gwgvgc, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #108460 (migrate `rustc_hir_analysis` to session diagnostic [Part Two])
 - #108581 (Add a new config flag, dist.include-mingw-linker.)
 - #108583 (Account for binders correctly when adding default RPITIT method assumption)
 - #108783 (Sync rustc_codegen_gcc 2023/03/04)
 - #108793 (Append to existing `PYTHONPATH` in compiletest instead of overwriting)
 - #108822 (Remove references to PassManagerBuilder)
 - #108866 (Force to use the stage 2 compiler  when config.download_rustc is set)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-07 22:07:56 +00:00
Celina G. Val
5eaeb71b9f Change item collection to be on demand 2023-03-07 12:47:25 -08:00
Giacomo Pasini
153bfa06e5
remove leftover comment 2023-03-07 20:01:22 +01:00
Matthias Krüger
85c475a839
Rollup merge of #108822 - nikic:legacy-pm-removal-2, r=cuviper
Remove references to PassManagerBuilder

This is a legacy PM concept that we no longer use.
2023-03-07 19:57:46 +01:00
Matthias Krüger
c21a640c5a
Rollup merge of #108783 - antoyo:sync-cg_gcc-2023-03-04, r=cjgillot
Sync rustc_codegen_gcc 2023/03/04

Hi.
This sync all the changes from rustc_codegen_gcc.
Thanks for the review.
2023-03-07 19:57:45 +01:00
Matthias Krüger
63635880f6
Rollup merge of #108583 - compiler-errors:rpitit-default-method-with-nested-rpitits, r=spastorino
Account for binders correctly when adding default RPITIT method assumption

As of #108203, we install extra projection predicates into the param-env of a default trait method when it has return-position `impl Trait` (or is async).

The implementation didn't account for the fact that it's walking into and out of binders, so we just need to shift all the debruijn indices accordingly when constructing the projection predicates.

Fixes #108579

r? types
2023-03-07 19:57:44 +01:00
Matthias Krüger
14260c83ac
Rollup merge of #108460 - obeis:hir-analysis-migrate-diagnostics-2, r=compiler-errors
migrate `rustc_hir_analysis` to session diagnostic [Part Two]

migrate `rustc_hir_analysis` to session diagnostic (part two)
files list:
- rustc_hir_analysis/variance/*
- rustc_hir_analysis/missing_cast_for_variadic_arg.rs
- rustc_hir_analysis/sized_unsized_cast.rs

Updates #100717
2023-03-07 19:57:43 +01:00
bors
e3dfeeaa45 Auto merge of #108167 - Zoxc:query-config-instance-slim, r=cjgillot
Make `rustc_query_system` take `QueryConfig` by instance.

This allows for easy switching between virtual tables and specialized instances for queries. It also has the benefit of less turbofish. `QueryStorage` has also been merged with `QueryCache`.

Split out from https://github.com/rust-lang/rust/pull/107937.

r? `@cjgillot`
2023-03-07 18:55:36 +00:00