Commit Graph

225036 Commits

Author SHA1 Message Date
Michael Goulet
f3c9c21658 Prepopulate opaques in canonical input 2023-05-25 03:21:22 +00:00
Michael Goulet
a2d7ffc635 Move DefiningAnchor 2023-05-25 03:21:21 +00:00
Michael Goulet
4d80b8090c Pull out logic from #111131, plus some new logic in EvalCtxt::normalize_opaque_type
Co-authored-by: lcnr <rust@lcnr.de>
2023-05-25 03:19:15 +00:00
Michael Goulet
4692375389 Don't print newlines in APITs 2023-05-25 02:45:14 +00:00
bors
7664dfe433 Auto merge of #111925 - Manishearth:rollup-z6z6l2v, r=Manishearth
Rollup of 5 pull requests

Successful merges:

 - #111741 (Use `ObligationCtxt` in custom type ops)
 - #111840 (Expose more information in `get_body_with_borrowck_facts`)
 - #111876 (Roll compiler_builtins to 0.1.92)
 - #111912 (Use `Option::is_some_and` and `Result::is_ok_and` in the compiler  )
 - #111915 (libtest: Improve error when missing `-Zunstable-options`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-25 00:33:43 +00:00
Caio
462a96c9e9 [RFC-2011] Expand more expressions 2023-05-24 21:15:50 -03:00
sladynnunes
8e399275ad Migrate item_static to Askama 2023-05-24 17:11:26 -07:00
Caio
41d414e3f4 Address comments 2023-05-24 19:54:13 -03:00
Caio
25e395653d Move tests 2023-05-24 19:35:59 -03:00
Manish Goregaokar
8038606bf3
Rollup merge of #111915 - jyn514:libtest-errors, r=thomcc
libtest: Improve error when missing `-Zunstable-options`

"only accepted on the nightly compiler" is misleading when this *is* nightly.
2023-05-24 15:05:05 -07:00
Manish Goregaokar
d0b3ebee66
Rollup merge of #111912 - WaffleLapkin:is_some_and_in_the_compiler, r=petrochenkov
Use `Option::is_some_and` and `Result::is_ok_and` in the compiler

`.is_some_and(..)`/`.is_ok_and(..)` replace `.map_or(false, ..)` and `.map(..).unwrap_or(false)`, making the code more readable.

This PR is a sibling of https://github.com/rust-lang/rust/pull/111873#issuecomment-1561316515
2023-05-24 15:05:05 -07:00
Manish Goregaokar
33ded73c76
Rollup merge of #111876 - danakj:builtins92, r=Mark-Simulacrum
Roll compiler_builtins to 0.1.92

This pulls in the weak-intrinsics feature (which currently defaults off), and a minor version update to libm for the compiler_builtins crate to 0.2.7.
2023-05-24 15:05:04 -07:00
Manish Goregaokar
b84ab57f90
Rollup merge of #111840 - voidc:borrowck-consumers, r=oli-obk
Expose more information in `get_body_with_borrowck_facts`

Verification tools for Rust such as, for example, Creusot or Prusti would benefit from having access to more information computed by the borrow checker.
As a first step in that direction, #86977 added the `get_body_with_borrowck_facts` API, allowing compiler consumers to obtain a `mir::Body` with accompanying borrow checker information.
At RustVerify 2023, multiple people working on verification tools expressed their need for a more comprehensive API.
While eventually borrow information could be part of Stable MIR, in the meantime, this PR proposes a more limited approach, extending the existing `get_body_with_borrowck_facts` API.
In summary, we propose the following changes:

- Permit obtaining the borrow-checked body without necessarily running Polonius
- Return the `BorrowSet` and the `RegionInferenceContext` in `BodyWithBorrowckFacts`
- Provide a way to compute the `borrows_out_of_scope_at_location` map
- Make some helper methods public

This is similar to #108328 but smaller in scope.
`@smoelius` Do you think these changes would also be sufficient for your needs?

r? `@oli-obk`
cc `@JonasAlaif`
2023-05-24 15:05:04 -07:00
Manish Goregaokar
a9a4c9b3db
Rollup merge of #111741 - compiler-errors:custom-type-op, r=lcnr
Use `ObligationCtxt` in custom type ops

We already make one when evaluating the `CustomTypeOp`, so it's simpler to just pass it to the user. Removes a redundant `ObligationCtxt::new_in_snapshot` usage and simplifies some other code.

This makes several refactorings related to opaque types in the new solver simpler, but those are not included in this PR.
2023-05-24 15:05:03 -07:00
bors
096309e6dc Auto merge of #111919 - matthiaskrgr:rollup-8qcdp0q, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #111121 (Work around `rust-analyzer` false-positive type errors)
 - #111759 (Leverage the interval property to precompute borrow kill points.)
 - #111841 (Run AST validation on match guards correctly)
 - #111862 (Split out opaque collection from from `type_of`)
 - #111863 (Don't skip mir typeck if body has errors)
 - #111903 (Migrate GUI colors test to original CSS color format)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-24 21:56:17 +00:00
Matthias Krüger
0cc987fae2
Rollup merge of #111903 - GuillaumeGomez:migrate-gui-test-color-6, r=notriddle
Migrate GUI colors test to original CSS color format

Follow-up of https://github.com/rust-lang/rust/pull/111459.

r? `@notriddle`
2023-05-24 21:36:58 +02:00
Matthias Krüger
680f8b8efe
Rollup merge of #111863 - compiler-errors:check-more-mir, r=b-naber
Don't skip mir typeck if body has errors

Comment says:

```
// if verifier failed, don't do further checks to avoid ICEs
```

But there are no ICEs to be found. The comment is quite old, so perhaps something fixed it... maybe because the MIR typechecker is delaying span bugs rather than panicking via eager bugs? IDK

I'm generally inclined to fix the ICEs themselves that were to arise from this, rather than just totally skipping large parts of the compiler that have impacts on downstream logic (namely, our opaque type results are affected). Anyways, this happens on the error path, so it shouldn't really matter.

Fixes this hack: https://github.com/rust-lang/rust/pull/111853/files#r1201501540
2023-05-24 21:36:58 +02:00
Matthias Krüger
d09ee575ee
Rollup merge of #111862 - compiler-errors:opq, r=lcnr
Split out opaque collection from from `type_of`

requested by lcnr

r? `@lcnr`
2023-05-24 21:36:57 +02:00
Matthias Krüger
092352f6fd
Rollup merge of #111841 - matthewjasper:validate-match-guards, r=compiler-errors
Run AST validation on match guards correctly

AST validation was being skipped on match guards other than `if let` guards.
2023-05-24 21:36:57 +02:00
Matthias Krüger
52890cc719
Rollup merge of #111759 - cjgillot:interval-kill, r=b-naber
Leverage the interval property to precompute borrow kill points.
2023-05-24 21:36:56 +02:00
Matthias Krüger
09489b9137
Rollup merge of #111121 - Zalathar:ra-false-positive, r=jackh726
Work around `rust-analyzer` false-positive type errors

rust-analyzer incorrectly reports two type errors in `debug.rs`:

> expected &dyn Display, found &i32
> expected &dyn Display, found &i32

This is due to a known bug in r-a: (https://github.com/rust-lang/rust-analyzer/issues/11847).

In these particular cases, changing `&0` to `&0i32` seems to be enough to avoid the bug.
2023-05-24 21:36:56 +02:00
Markus Everling
fd5fa012e9 Use helper functions for min/max_idx 2023-05-24 19:33:04 +00:00
Camille GILLOT
9a7ed3625f Emit diagnostic for privately uninhabited uncovered witnesses. 2023-05-24 19:16:07 +00:00
bors
c373194cb6 Auto merge of #111260 - petrochenkov:effvisperf7, r=cjgillot
rustc_privacy: Cleanups and perf improvements to `EmbargoVisitor`

Continuation of https://github.com/rust-lang/rust/pull/110907.
2023-05-24 19:02:19 +00:00
Michael Goulet
d7ccbdd696 Split out opaque from type_of 2023-05-24 17:23:58 +00:00
Michael Goulet
b1387e776c Don't skip mir typeck if body has errors 2023-05-24 17:12:46 +00:00
bors
97d328012b Auto merge of #111673 - cjgillot:dominator-preprocess, r=cjgillot,tmiasko
Preprocess and cache dominator tree

Preprocessing dominators has a very strong effect for https://github.com/rust-lang/rust/pull/111344.
That pass checks that assignments dominate their uses repeatedly. Using the unprocessed dominator tree caused a quadratic runtime (number of bbs x depth of the dominator tree).

This PR also caches the dominator tree and the pre-processed dominators in the MIR cfg cache.

Rebase of https://github.com/rust-lang/rust/pull/107157
cc `@tmiasko`
2023-05-24 16:18:21 +00:00
jyn
9314ed0cbd libtest: Improve error when missing -Zunstable-options
"only accepted on the nightly compiler" is misleading when this *is* nightly.
2023-05-24 11:18:20 -05:00
Michael Goulet
521a0bcd1f Use ObligationCtxt in custom type ops 2023-05-24 16:06:32 +00:00
Maybe Waffle
307799a711 Use is_some_and/is_ok_and in less obvious spots 2023-05-24 14:33:43 +00:00
Maybe Waffle
fb0f74a8c9 Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00
bors
b3cbf7c835 Auto merge of #111694 - Amanieu:no-assume-bdynamic, r=petrochenkov
Don't assume that `-Bdynamic` is the default linker mode

In particular this is false when passing `-static` or `-static-pie` to the linker, which changes the default to `-Bstatic`. This PR ensures we explicitly initialize the correct mode when we first need it.
2023-05-24 13:35:30 +00:00
Guillaume Gomez
0a7293ff00 Migrate GUI colors test to original CSS color format 2023-05-24 14:41:18 +02:00
bors
70db836922 Auto merge of #111566 - clubby789:bootstrap-override-config, r=ozkanonur
Override config.toml options from command line

https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/Running.20tests.20on.20precompiled.20rustc/near/357763280

cc `@jyn514`
2023-05-24 10:56:34 +00:00
bors
d69787f098 Auto merge of #111195 - GuillaumeGomez:fix-ice-intra-doc-link, r=petrochenkov
Prevent crash when a path is not resolved in intra-doc link

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

cc `@petrochenkov`
r? `@notriddle`
2023-05-24 07:49:53 +00:00
bors
82faf5ed60 Auto merge of #111895 - matthiaskrgr:rollup-9a6szng, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #111861 (Don't ICE on return-type notation when promoting trait preds to associated type bounds)
 - #111864 (Always require closure parameters to be `Sized`)
 - #111870 (Rename `traits_in_crate` query to `traits`)
 - #111880 (Don't ICE when computing PointerLike trait when region vars are in param-env)
 - #111887 (Add regression tests for pretty-printing inherent projections)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-24 05:07:22 +00:00
Matthias Krüger
d49d347f15
Rollup merge of #111887 - fmease:inh-proj-pp-tests, r=compiler-errors
Add regression tests for pretty-printing inherent projections

Tests for #111486.
Fixes #111879.

r? `@matthiaskrgr`
2023-05-24 06:05:39 +02:00
Matthias Krüger
8227c4fd6e
Rollup merge of #111880 - compiler-errors:pointer-like-param-env, r=jackh726
Don't ICE when computing PointerLike trait when region vars are in param-env

Fixes #111877
2023-05-24 06:05:39 +02:00
Matthias Krüger
783bea940b
Rollup merge of #111870 - WaffleLapkin:just_🌟traits🌟_query, r=compiler-errors
Rename `traits_in_crate` query to `traits`

> NOTE: Not named just `traits` due to a naming conflict.

This can, in fact, be easily avoided.
2023-05-24 06:05:38 +02:00
Matthias Krüger
efea88ae08
Rollup merge of #111864 - Jules-Bertholet:sized-closures, r=compiler-errors
Always require closure parameters to be `Sized`

The `rust-call` ABI isn't compatible with `#![feature(unsized_fn_params)]`, so trying to use that feature with closures leads to an ICE (#67981). This turns that ICE into a type-check error.

`@rustbot` label A-closures F-unsized_fn_params
2023-05-24 06:05:38 +02:00
Matthias Krüger
224b6511b1
Rollup merge of #111861 - compiler-errors:rtn-in-super, r=jackh726
Don't ICE on return-type notation when promoting trait preds to associated type bounds

Fixes #111846
2023-05-24 06:05:37 +02:00
Nicholas Nethercote
59c5259bc9 Add a clarifying comment.
This is something that took me some time to figure out.
2023-05-24 12:33:35 +10:00
Nicholas Nethercote
20de2ba759 Remove {Pre,Post}InliningPartitioning.
I find that these structs obfuscate the code. Removing them and just
passing the individual fields around makes the `Partition` method
signatures a little longer, but makes the data flow much clearer. E.g.

- `codegen_units` is mutable all the way through.
- `codegen_units`'s length is changed by `merge_codegen_units`, but only
  the individual elements are changed by `place_inlined_mono_items` and
  `internalize_symbols`.
- `roots`, `internalization_candidates`, and `mono_item_placements` are
  all immutable after creation, and all used by just one of the four
  methods.
2023-05-24 12:33:35 +10:00
bors
9d826e01e8 Auto merge of #110936 - loongarch-rs:promote-tier2, r=Mark-Simulacrum
Promote loongarch64-unknown-linux-gnu to Tier 2 with host tools

This PR promotes `loongarch64-unknown-linux-gnu` to Tier 2 (with host tools).

MCP: https://github.com/rust-lang/compiler-team/issues/518
2023-05-24 02:29:47 +00:00
Nicholas Nethercote
b39b7098ea Remove the merging module.
Three of the four methods in `DefaultPartitioning` are defined in
`default.rs`. But `merge_codegen_units` is defined in a separate module,
`merging`, even though it's less than 100 lines of code and roughly the
same size as the other three methods. (Also, the `merging` module
currently sits alongside `default`, when it should be a submodule of
`default`, adding to the confusion.)

In #74275 this explanation was given:

> I pulled this out into a separate module since it seemed like we might
> want a few different merge algorithms to choose from.

But in the three years since there have been no additional merging
algorithms, and there is no mechanism for choosing between different
merging algorithms. (There is a mechanism,
`-Zcgu-partitioning-strategy`, for choosing between different
partitioning strategies, but the merging algorithm is just one piece of
a partitioning strategy.)

This commit merges `merging` into `default`, making the code easier to
navigate and read.
2023-05-24 12:25:58 +10:00
Markus Everling
3d11b655bd Add Median of Medians fallback to introselect 2023-05-24 00:38:20 +00:00
Nicholas Nethercote
e26c0c92bd Inline and remove numbered_codegen_unit_name.
It is small and has a single call site, and this change will facilitate
the next commit.
2023-05-24 10:05:15 +10:00
bors
edbd5c5a78 Auto merge of #111890 - weihanglo:update-cargo, r=weihanglo
Update cargo

10 commits in 09276c703a473ab33daaeb94917232e80eefd628..64fb38c97ac4d3a327fc9032c862dd28c8833b17
2023-05-16 21:43:35 +0000 to 2023-05-23 18:53:23 +0000
- Consider rust-version when selecting packages for cargo add (rust-lang/cargo#12078)
- fix(lints): Switch to -Zlints so stable projects can experiment (rust-lang/cargo#12168)
- Automatically inherit workspace fields when running cargo new/init (rust-lang/cargo#12069)
- ci: check if any version bump needed for member crates (rust-lang/cargo#12126)
- feat: `lints` feature (rust-lang/cargo#12148)
- fix: pass `-C debuginfo` after weakening if explicitly set (rust-lang/cargo#12165)
- Tweak build help to clarify role of --bin (rust-lang/cargo#12157)
- fix: Pass CI on nightly (rust-lang/cargo#12160)
- docs(source): doc comments for Source and its impls (rust-lang/cargo#12159)
- docs(source): doc comments for `Source` and friends (rust-lang/cargo#12153)

r? `@ghost`
2023-05-23 23:52:07 +00:00
León Orell Valerian Liehr
4a63b07d24
Add tests for pretty-printing inherent projections 2023-05-24 01:17:38 +02:00
Weihang Lo
17f41b2ed5
Update cargo 2023-05-23 23:20:16 +01:00