Commit Graph

216021 Commits

Author SHA1 Message Date
bors
6cd6bad51f Auto merge of #101692 - cjgillot:generator-lazy-witness, r=oli-obk
Compute generator saved locals on MIR

Generators are currently type-checked by introducing a `witness` type variable, which is unified with a `GeneratorWitness(captured types)` whose purpose is to ensure that the auto traits correctly migrate from the captured types to the `witness` type.  This requires computing the captured types on HIR during type-checking, only to re-do it on MIR later.

This PR proposes to drop the HIR-based computation, and only keep the MIR one.  This is done in 3 steps.
1. During type-checking, the `witness` type variable is never unified.  This allows to stall all the obligations that depend on it until the end of type-checking.  Then, the stalled obligations are marked as successful, and saved into the typeck results for later verification.
2. At type-checking writeback, `witness` is replaced by `GeneratorWitnessMIR(def_id, substs)`.  From this point on, all trait selection involving `GeneratorWitnessMIR` will fetch the MIR-computed locals, similar to what opaque types do.  There is no lifetime to be preserved here: we consider all the lifetimes appearing in this witness type to be higher-ranked.
3. After borrowck, the stashed obligations are verified against the actually computed types, in the `check_generator_obligations` query.  If any obligation was wrongly marked as fulfilled in step 1, it should be reported here.

There are still many issues:
- ~I am not too happy having to filter out some locals from the checked bounds, I think this is MIR building that introduces raw pointers polluting the analysis;~ solved by a check specific to static variables.
- the diagnostics for captured types don't show where they are used/dropped;
- I do not attempt to support chalk.

cc `@eholk` `@jyn514` for the drop-tracking work
r? `@oli-obk` as you warned me of potential unsoundness
2023-01-28 01:05:29 +00:00
Camille GILLOT
d3d626920a Bless mir-opt tests. 2023-01-27 22:01:47 +00:00
Camille GILLOT
de110f9208 Pacify tidy. 2023-01-27 22:01:25 +00:00
Camille GILLOT
65c3c90f3e Restrict amount of ignored locals. 2023-01-27 22:01:12 +00:00
bors
7d4df2d30e Auto merge of #107386 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2023-01-27 21:20:39 +00:00
Camille GILLOT
c51fc382bd Bless ui-fulldeps. 2023-01-27 20:10:25 +00:00
Camille GILLOT
0e52a671d4 Bless tests. 2023-01-27 20:10:17 +00:00
Camille GILLOT
60e04d1e8c Compute generator saved locals on MIR. 2023-01-27 20:10:06 +00:00
Philipp Krones
c71062a324
Update Cargo.lock 2023-01-27 21:09:23 +01:00
Philipp Krones
1dd773175a
Merge commit '1480cea393d0cee195e59949eabdfbcf1230f7f9' into clippyup 2023-01-27 21:09:08 +01:00
bors
1480cea393 Auto merge of #10242 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-01-27 19:31:37 +00:00
Philipp Krones
6f9c70a201
Bump Clippy version -> 0.1.69 2023-01-27 20:27:00 +01:00
Philipp Krones
1f403e9ab9
Bump nightly version -> 2023-01-27 2023-01-27 20:26:48 +01:00
Philipp Krones
2bc2431fd1
Merge remote-tracking branch 'upstream/master' into rustup 2023-01-27 20:26:35 +01:00
Camille GILLOT
400cb9aa41 Separate witness type computation from the generator transform. 2023-01-27 19:00:26 +00:00
Camille GILLOT
e2387ad484 Remember where a type was kept in MIR. 2023-01-27 18:59:32 +00:00
Camille GILLOT
1974b6b68d Introduce GeneratorWitnessMIR. 2023-01-27 18:58:44 +00:00
Camille GILLOT
03618d6afd Always require Drop for generators. 2023-01-27 18:58:23 +00:00
Camille GILLOT
9259da51ed Test the 3 generator handling versions for generator/async tests. 2023-01-27 18:58:13 +00:00
Camille GILLOT
a20078f044 Add drop_tracking_mir option. 2023-01-27 18:57:34 +00:00
Camille GILLOT
cb873b2d93 Separate trait selection from ambiguity reporting. 2023-01-27 18:57:10 +00:00
Camille GILLOT
2870ce01b8 Impl HashStable/Encodable/Decodable for ObligationCause. 2023-01-27 18:56:32 +00:00
Camille GILLOT
caefec955f Do not abort compilation when failing to normalize opaque types. 2023-01-27 18:55:58 +00:00
bors
ef982929c0 Auto merge of #107372 - JohnTitor:rollup-zkl2ges, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #106806 (Replace format flags u32 by enums and bools.)
 - #107194 (Remove dependency on slice_internals feature in rustc_ast)
 - #107234 (Revisit fix_is_ci_llvm_available logic)
 - #107316 (Update snap from `1.0.1` to `1.1.0`)
 - #107321 (solver comments + remove `TyCtxt::evaluate_goal`)
 - #107332 (Fix wording from `rustbuild` to `bootstrap`)
 - #107347 (reduce rightward-drift)
 - #107352 (compiler: Fix E0587 explanation)
 - #107357 (Fix infinite loop in rustdoc get_all_import_attributes function)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-27 17:49:56 +00:00
Yuki Okushi
c64f4c41f7
Rollup merge of #107357 - GuillaumeGomez:fix-infinite-loop-in-rustdoc-get_all_import_attributes, r=notriddle
Fix infinite loop in rustdoc get_all_import_attributes function

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

We'll also need to backport this fix to beta.

r? `@notriddle`
2023-01-28 00:23:16 +09:00
Yuki Okushi
85dc93b4d3
Rollup merge of #107352 - sameo:topic/E0587, r=JohnTitor
compiler: Fix E0587 explanation

We meant to use 8 as the packed argument.

Signed-off-by: Samuel Ortiz <sameo@rivosinc.com>
2023-01-28 00:23:15 +09:00
Yuki Okushi
b247253edd
Rollup merge of #107347 - tshepang:rightward-drift, r=Nilstrieb
reduce rightward-drift
2023-01-28 00:23:15 +09:00
Yuki Okushi
1e0cf727c3
Rollup merge of #107332 - chansuke:issue-107230, r=albertlarsan68
Fix wording from `rustbuild` to `bootstrap`

Fixes #107230
2023-01-28 00:23:14 +09:00
Yuki Okushi
d62f6fdff9
Rollup merge of #107321 - lcnr:comment, r=compiler-errors
solver comments + remove `TyCtxt::evaluate_goal`

from the `RustcContributor::explore` session yesterday.

This also removes `TyCtxt::evaluate_goal` because to canonicalize you have to use an `InferCtxt` anyways at which point we should just always get people to use `evaluate_root_goal`.

r? ``@spastorino``
2023-01-28 00:23:14 +09:00
Yuki Okushi
9ec7492862
Rollup merge of #107316 - ChrisDenton:snap, r=oli-obk
Update snap from `1.0.1` to `1.1.0`

As spotted by `@mejrs,` snap 1.0.1 emits a future compatibility warning. This was fixed in https://github.com/BurntSushi/rust-snappy/pull/39
2023-01-28 00:23:13 +09:00
Yuki Okushi
04dfde4ea2
Rollup merge of #107234 - Rattenkrieg:bootstrap-fix-is_ci_llvm_available, r=albertlarsan68
Revisit fix_is_ci_llvm_available logic

Fixes #107225
Now `supported_platforms` has a knowledge whether llvm asserts artifacts are available for particular host triple.

``@jyn514`` ``@albertlarsan68`` PTAL
2023-01-28 00:23:13 +09:00
Yuki Okushi
bed113de49
Rollup merge of #107194 - xfix:remove-slice-internals-dependency-in-rustc-ast, r=Nilstrieb
Remove dependency on slice_internals feature in rustc_ast

This reduces dependency on unstable features by the compiler.
2023-01-28 00:23:12 +09:00
Yuki Okushi
1163279c3a
Rollup merge of #106806 - m-ou-se:format-args-flags, r=oli-obk
Replace format flags u32 by enums and bools.

This gets rid of the `flags: u32` field where each bit has a special meaning, and replaces it by simple enums and booleans.

Part of #99012
2023-01-28 00:23:11 +09:00
bors
7919ef0ec5 Auto merge of #107055 - kylematsuda:eb-fn-sig, r=lcnr
Switch to `EarlyBinder` for `fn_sig` query

Part of the work to finish #105779 (also see https://github.com/rust-lang/types-team/issues/78).

Several queries `X` have a `bound_X` variant that wraps the output in [`EarlyBinder`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/subst/struct.EarlyBinder.html). This adds `EarlyBinder` to the return type of the `fn_sig` query and removes `bound_fn_sig`.

r? `@lcnr`
2023-01-27 15:02:44 +00:00
bors
54e929bdde Auto merge of #10237 - cstyles:fix-docs-for-suspicious_xor_used_as_pow, r=Jarcho
Fix styling in documentation for `suspicious_xor_used_as_pow` lint

There was a tab after the three leading slashes which caused the contents of the "Why is this bad?" section to be rendered as a code block.

**Before:**

<img width="626" alt="master" src="https://user-images.githubusercontent.com/4869194/214985546-4433d211-9fd3-450c-8ff7-2c0a47fccdc0.png">

**After:**

<img width="520" alt="fixed" src="https://user-images.githubusercontent.com/4869194/214985561-87255196-008c-4a1c-8cc8-c54b337d22a2.png">

The file still contains a lot of tabs but they don't affect the documentation.

---

changelog: [`suspicious_xor_used_as_pow`]: Fix styling in documentation
2023-01-27 14:02:23 +00:00
Guillaume Gomez
1b64e16643 Add regression test for #107350 2023-01-27 12:11:01 +01:00
Guillaume Gomez
b8c44fa414 Fix infinite loop in rustdoc get_all_import_attributes function 2023-01-27 12:11:00 +01:00
Mara Bos
21cf9dbc85 Destructure format_options in make_format_spec. 2023-01-27 11:43:38 +01:00
Samuel Ortiz
706132d409 compiler: Fix E0587 explanation
We meant to use 8 as the packed argument.

Signed-off-by: Samuel Ortiz <sameo@rivosinc.com>
2023-01-27 10:59:51 +01:00
bors
6874f4e3fc Auto merge of #107054 - petrochenkov:effvisdoc3, r=GuillaumeGomez
rustdoc: Collect "rustdoc-reachable" items during early doc link resolution

This pass only needs to know about visibilities, attributes and reexports, so it can be run early, similarly to `compute_effective_visibilities` in rustc.
Results of this pass can be used to prune the list of extern impls early thus improving performance of https://github.com/rust-lang/rust/pull/94857.
2023-01-27 09:01:05 +00:00
Mara Bos
be69002dd7 Update clippy for restructured format flags fields. 2023-01-27 08:53:41 +01:00
Mara Bos
0abf8a0617 Replace format flags u32 by enums and bools. 2023-01-27 08:53:39 +01:00
Sergey Prytkov
9ef8407610 Revisit fix_is_ci_llvm_available logic; read build triple from toml 2023-01-27 10:18:04 +03:00
bors
18890f05f6 Auto merge of #107343 - JohnTitor:rollup-s6l94aj, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #105784 (update stdarch)
 - #106856 (core: Support variety of atomic widths in width-agnostic functions)
 - #107171 (rustc_metadata: Fix `encode_attrs`)
 - #107242 (rustdoc: make item links consistently use `title="{shortty} {path}"`)
 - #107279 (Use new solver during selection)
 - #107284 (rustdoc: use smarter encoding for playground URL)
 - #107325 (rustdoc: Stop using `HirId`s)
 - #107336 (rustdoc: remove mostly-unused CSS classes `import-item` and `module-item`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-27 06:10:19 +00:00
Tshepang Mbambo
cce452d8c8 reduce rightward-drift 2023-01-27 07:52:44 +02:00
Yuki Okushi
17a2e1fef3
Rollup merge of #107336 - notriddle:notriddle/import-item-module-item, r=GuillaumeGomez
rustdoc: remove mostly-unused CSS classes `import-item` and `module-item`
2023-01-27 12:57:57 +09:00
Yuki Okushi
aac937a37c
Rollup merge of #107325 - petrochenkov:hiddoc2, r=GuillaumeGomez
rustdoc: Stop using `HirId`s

Use `LocalDefId`s instead.
Rustdoc doesn't work with item bodies, so it almost never needs fine-grained HIR IDs.
2023-01-27 12:57:56 +09:00
Yuki Okushi
d68b5a42e2
Rollup merge of #107284 - notriddle:notriddle/plus, r=jsha
rustdoc: use smarter encoding for playground URL

The old way would compress okay with DEFLATE, but this version makes uncompressed docs smaller, which matters for memory usage and stuff like `cargo doc`.

Try it out: <https://play.rust-lang.org/?code=fn+main()+{%0Alet+mut+v+=+Vec::new();%0Av.push(1+/+1);%0Aprintln!(%22{}%22,+v[0]);%0A}>

In local testing, this change shrinks sample pages by anywhere between 4.0% and 0.031%

    $ du -b after.dir/std/vec/struct.Vec.html before.dir/std/vec/struct.Vec.html
    759235  after.dir/std/vec/struct.Vec.html
    781842  before.dir/std/vec/struct.Vec.html

100*((759235-781842)/781842)=-2.8

    $ du -b after.dir/std/num/struct.Wrapping.html before.dir/std/num/struct.Wrapping.html
    3194173 after.dir/std/num/struct.Wrapping.html
    3204351 before.dir/std/num/struct.Wrapping.html

100*((3194173-3204351)/3204351)=-0.031

    $ du -b after.dir/std/keyword.match.html before.dir/std/keyword.match.html
    8151    after.dir/std/keyword.match.html
    8495    before.dir/std/keyword.match.html

100*((8151-8495)/8495)=-4.0

Gzipped tarball sizes seem shrunk, but not by much.

    du -s before.tar.gz after.tar.gz
    69600   before.tar.gz
    69480   after.tar.gz

100*((69480-69600)/69600)=-0.17
2023-01-27 12:57:56 +09:00
Yuki Okushi
5683915ca4
Rollup merge of #107279 - compiler-errors:new-solver-evaluate, r=lcnr
Use new solver during selection

r? ``@lcnr``
2023-01-27 12:57:55 +09:00
Yuki Okushi
145241402d
Rollup merge of #107242 - notriddle:notriddle/title-ordering, r=GuillaumeGomez
rustdoc: make item links consistently use `title="{shortty} {path}"`

The ordering in item tables was flipped in 3030cbea95, making it inconsistent with the ordering in method signatures.

Compare these (before this PR is merged):

c8e6a9e8b6/src/librustdoc/html/render/print_item.rs (L455-L459)

c8e6a9e8b6/src/librustdoc/html/format.rs (L903-L908)
2023-01-27 12:57:55 +09:00