Commit Graph

210600 Commits

Author SHA1 Message Date
Oli Scherer
f42e490d6f Register obligations from type relation 2022-11-21 16:37:53 +00:00
Oli Scherer
9a8e1eea7a Move a field around 2022-11-21 16:35:23 +00:00
Oli Scherer
9cd44f8142 nit treat different opaque types 2022-11-21 16:35:10 +00:00
Oli Scherer
ae80c764d4 Add an always-ambiguous predicate to make sure that we don't accidentlally allow trait resolution to prove false things during coherence 2022-11-21 16:35:04 +00:00
Oli Scherer
94fe30ff2f Treat different opaque types of the same def id as equal during coherence 2022-11-21 16:06:07 +00:00
Oli Scherer
2752e328c9 Allow opaque types in trait impl headers and rely on coherence to reject unsound cases 2022-11-21 16:00:31 +00:00
bors
7fe6f36224 Auto merge of #103491 - cjgillot:self-rpit, r=oli-obk
Support using `Self` or projections inside an RPIT/async fn

I reuse the same idea as https://github.com/rust-lang/rust/pull/103449 to use variances to encode whether a lifetime parameter is captured by impl-trait.

The current implementation of async and RPIT replace all lifetimes from the parent generics by `'static`.  This PR changes the scheme
```rust
impl<'a> Foo<'a> {
    fn foo<'b, T>() -> impl Into<Self> + 'b { ... }
}

opaque Foo::<'_a>::foo::<'_b, T>::opaque<'b>: Into<Foo<'_a>> + 'b;
impl<'a> Foo<'a> {
    // OLD
    fn foo<'b, T>() -> Foo::<'static>::foo::<'static, T>::opaque::<'b> { ... }
                             ^^^^^^^ the `Self` becomes `Foo<'static>`

    // NEW
    fn foo<'b, T>() -> Foo::<'a>::foo::<'b, T>::opaque::<'b> { ... }
                             ^^ the `Self` stays `Foo<'a>`
}
```

There is the same issue with projections. In the example, substitute `Self` by `<T as Trait<'b>>::Assoc` in the sugared version, and `Foo<'_a>` by `<T as Trait<'_b>>::Assoc` in the desugared one.

This allows to support `Self` in impl-trait, since we do not replace lifetimes by `'static` any more.  The same trick allows to use projections like `T::Assoc` where `Self` is allowed.  The feature is gated behind a `impl_trait_projections` feature gate.

The implementation relies on 2 tweaking rules for opaques in 2 places:
- we only relate substs that correspond to captured lifetimes during TypeRelation;
- we only list captured lifetimes in choice region computation.

For simplicity, I encoded the "capturedness" of lifetimes as a variance, `Bivariant` vs `Invariant` for unused vs captured lifetimes. The `variances_of` query used to ICE for opaques.

Impl-trait that do not reference `Self` or projections will have their variances as:
- `o` (invariant) for each parent type or const;
- `*` (bivariant) for each parent lifetime --> will not participate in borrowck;
- `o` (invariant) for each own lifetime.

Impl-trait that does reference `Self` and/or projections will have some parent lifetimes marked as `o` (as the example above), and participate in type relation and borrowck.  In the example above, `variances_of(opaque) = ['_a: o, '_b: *, T: o, 'b: o]`.

r? types
cc `@compiler-errors` , as you asked about the issue with `Self` and projections.
2022-11-21 12:17:03 +00:00
bors
736c675d2a Auto merge of #103454 - camsteffen:remove-conservatively-uninhabited, r=oli-obk
Factor out `conservative_is_privately_uninhabited`

After #102660 there is no more need for `conservative_is_privately_uninhabited`.

r? `@oli-obk`
2022-11-21 04:42:43 +00:00
bors
ccde51a912 Auto merge of #102717 - beetrees:repr128-c-style-debuginfo, r=nagisa
Pass 128-bit C-style enum enumerator values to LLVM

Pass the full 128 bits of C-style enum enumerators through to LLVM. This means that debuginfo for C-style repr128 enums is now emitted correctly for DWARF platforms (as compared to not being correctly emitted on any platform).

Tracking issue: #56071
2022-11-21 01:44:12 +00:00
Cameron Steffen
cc8dddbac9 Factor out conservative_is_privately_uninhabited 2022-11-20 19:04:11 -06:00
Cameron Steffen
34cbe72780 Change to Ty::is_inhabited_from 2022-11-20 19:04:11 -06:00
Cameron Steffen
a6d96f9fd7 Fix typo 2022-11-20 19:04:11 -06:00
bors
a102dc806d Auto merge of #104655 - matthiaskrgr:rollup-r5kfffy, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #101310 (Clarify and restrict when `{Arc,Rc}::get_unchecked_mut` is allowed.)
 - #104461 (Fix building of `aarch64-pc-windows-gnullvm`)
 - #104487 (update ntapi dep to remove future-incompat warning)
 - #104504 (Add a detailed note for missing comma typo w/ FRU syntax)
 - #104581 (rustdoc: remove unused JS IIFE from main.js)
 - #104632 (avoid non-strict-provenance casts in libcore tests)
 - #104634 (move core::arch into separate file)
 - #104641 (replace unusual grammar)
 - #104643 (add examples to chunks remainder methods. )

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-11-20 23:03:20 +00:00
Matthias Krüger
846574828a
Rollup merge of #104643 - pnkfelix:examples-for-chunks-remainder, r=scottmcm
add examples to chunks remainder methods.

add examples to chunks remainder methods.

my motivation for adding the examples was to make it very clear that the state of the iterator (in terms of where its cursor lies) has no effect on what remainder returns.

Also fixed some links to rchunk remainder methods.
2022-11-20 23:50:30 +01:00
Matthias Krüger
9a9569698b
Rollup merge of #104641 - tshepang:grammar, r=Mark-Simulacrum
replace unusual grammar
2022-11-20 23:50:29 +01:00
Matthias Krüger
b3d491696b
Rollup merge of #104634 - RalfJung:core-arch, r=Mark-Simulacrum
move core::arch into separate file

This works around https://github.com/rust-lang/rust/issues/104633 which otherwise leads to warnings in miri-test-libstd.
2022-11-20 23:50:29 +01:00
Matthias Krüger
ff72187b06
Rollup merge of #104632 - RalfJung:core-test-strict-provenance, r=thomcc
avoid non-strict-provenance casts in libcore tests

r? `@thomcc`
2022-11-20 23:50:28 +01:00
Matthias Krüger
b2ee0df1b4
Rollup merge of #104581 - notriddle:notriddle/js-iife-2, r=GuillaumeGomez
rustdoc: remove unused JS IIFE from main.js

This [IIFE] made sense when it was added in deaf5e200e and there was a local variable scoped to it, but now it calls a function, but declares nothing.

[IIFE]: https://developer.mozilla.org/en-US/docs/Glossary/IIFE "immediately invoked function expression"
2022-11-20 23:50:28 +01:00
Matthias Krüger
fce077b053
Rollup merge of #104504 - compiler-errors:fru-syntax-note, r=estebank
Add a detailed note for missing comma typo w/ FRU syntax

Thanks to `@pierwill` for working on this with me!

Fixes #104373, perhaps `@alice-i-cecile` can comment on the new error for the example provided on that issue -- feedback is welcome.

```
error[E0063]: missing field `defaulted` in initializer of `Outer`
  --> $DIR/multi-line-fru-suggestion.rs:14:5
   |
LL |     Outer {
   |     ^^^^^ missing `defaulted`
   |
note: this expression may have been misinterpreted as a `..` range expression
  --> $DIR/multi-line-fru-suggestion.rs:16:16
   |
LL |           inner: Inner {
   |  ________________^
LL | |             a: 1,
LL | |             b: 2,
LL | |         }
   | |_________^ this expression does not end in a comma...
LL |           ..Default::default()
   |           ^^^^^^^^^^^^^^^^^^^^ ... so this is interpreted as a `..` range expression, instead of functional record update syntax
help: to set the remaining fields from `Default::default()`, separate the last named field with a comma
   |
LL |         },
   |          +

error: aborting due to previous error

For more information about this error, try `rustc --explain E0063`.
```
2022-11-20 23:50:27 +01:00
Matthias Krüger
7a10c4aea2
Rollup merge of #104487 - klensy:ntapi, r=Mark-Simulacrum
update ntapi dep to remove future-incompat warning

This fixes warning https://github.com/rust-lang-ci/rust/actions/runs/3477235400/jobs/5813202075#step:25:217
`warning: the following packages contain code that will be rejected by a future version of Rust: ntapi v0.3.7`

by upgrading `sysinfo` version (https://github.com/GuillaumeGomez/sysinfo/blob/master/CHANGELOG.md#0267)

There was some breaking changes in `sysinfo`:
* 0.25.0 (System::refresh_cpu behaviour changed: it only computes CPU usage and doesn't retrieve CPU frequency.) not affected?
* 0.26.0 (Switch memory unit from kilobytes to bytes) fixed.
2022-11-20 23:50:27 +01:00
Matthias Krüger
6a722aa170
Rollup merge of #104461 - mati865:gnullvm-aarch64-fixup, r=Mark-Simulacrum
Fix building of `aarch64-pc-windows-gnullvm`

That change had been lost during rebase of my last PR (https://github.com/rust-lang/rust/pull/103894).
2022-11-20 23:50:26 +01:00
Matthias Krüger
b4513ce6f8
Rollup merge of #101310 - zachs18:rc_get_unchecked_mut_docs_soundness, r=Mark-Simulacrum
Clarify and restrict when `{Arc,Rc}::get_unchecked_mut` is allowed.

(Tracking issue for `{Arc,Rc}::get_unchecked_mut`: #63292)

(I'm using `Rc` in this comment, but it applies for `Arc` all the same).

As currently documented, `Rc::get_unchecked_mut` can lead to unsoundness when multiple `Rc`/`Weak` pointers to the same allocation exist. The current documentation only requires that other `Rc`/`Weak` pointers to the same allocation "must not be dereferenced for the duration of the returned borrow". This can lead to unsoundness in (at least) two ways: variance, and `Rc<str>`/`Rc<[u8]>` aliasing. ([playground link](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=d7e2d091c389f463d121630ab0a37320)).

This PR changes the documentation of `Rc::get_unchecked_mut` to restrict usage to when all `Rc<T>`/`Weak<T>` have the exact same `T` (including lifetimes). I believe this is sufficient to prevent unsoundness, while still allowing `get_unchecked_mut` to be called on an aliased `Rc` as long as the safety contract is upheld by the caller.

## Alternatives

* A less strict, but still sound alternative would be to say that the caller must only write values which are valid for all aliased `Rc`/`Weak` inner types. (This was [mentioned](https://github.com/rust-lang/rust/issues/63292#issuecomment-568284090) in the tracking issue). This may be too complicated to clearly express in the documentation.
* A more strict alternative would be to say that there must not be any aliased `Rc`/`Weak` pointers, i.e. it is required that get_mut would return `Some(_)`. (This was also mentioned in the tracking issue). There is at least one codebase that this would cause to become unsound ([here](be5a164d77/src/memtable.rs (L166)), where additional locking is used to ensure unique access to an aliased `Rc<T>`;  I saw this because it was linked on the tracking issue).
2022-11-20 23:50:26 +01:00
bors
a28f3c88e5 Auto merge of #104646 - matthiaskrgr:rollup-7xnhzf0, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #104537 (fix std::thread docs are unclear regarding stack sizes)
 - #104558 (Don't assume `FILE_ID_BOTH_DIR_INFO` will be aligned)
 - #104564 (interpret: use Either over Result when it is not representing an error condition)
 - #104568 (clarify that realloc refreshes pointer provenance even when the allocation remains in-place)
 - #104611 (rustdoc: use real buttons for scrape examples controls)
 - #104640 (Migrate kdb style to CSS variables)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-11-20 19:14:14 +00:00
Matthias Krüger
2aa7f54df2
Rollup merge of #104640 - GuillaumeGomez:migrate-kdb-css, r=notriddle
Migrate kdb style to CSS variables

r? `@notriddle`
2022-11-20 18:21:49 +01:00
Matthias Krüger
c5f92ce2a0
Rollup merge of #104611 - notriddle:notriddle/scrape-examples-button, r=GuillaumeGomez
rustdoc: use real buttons for scrape examples controls

This makes the expand and switch controls keyboard-accessible.

Preview: https://notriddle.com/notriddle-rustdoc-demos/scrape-examples-button/test_dingus/fn.test.html
2022-11-20 18:21:49 +01:00
Matthias Krüger
db5f005f35
Rollup merge of #104568 - RalfJung:realloc, r=Amanieu
clarify that realloc refreshes pointer provenance even when the allocation remains in-place

This [matches what C does](https://en.cppreference.com/w/c/memory/realloc):

> The original pointer ptr is invalidated and any access to it is undefined behavior (even if reallocation was in-place).

Cc `@rust-lang/wg-allocators`
2022-11-20 18:21:48 +01:00
Matthias Krüger
820a41580e
Rollup merge of #104564 - RalfJung:either, r=oli-obk
interpret: use Either over Result when it is not representing an error condition

r? `@oli-obk`
2022-11-20 18:21:48 +01:00
Matthias Krüger
379d3365fd
Rollup merge of #104558 - thomcc:unalign-diriter, r=ChrisDenton
Don't assume `FILE_ID_BOTH_DIR_INFO` will be aligned

Fixes #104530. See that issue for info.

r? `@ChrisDenton`
2022-11-20 18:21:47 +01:00
Matthias Krüger
ddb12348ca
Rollup merge of #104537 - HintringerFabian:docs_default_min_stack_size, r=the8472
fix std::thread docs are unclear regarding stack sizes

Improves the documentation about the default stack size of a spawned thread
Fixes #102671
2022-11-20 18:21:47 +01:00
Felix S. Klock II
98993af828 add examples to chunks remainder methods. Also fixed some links to rchunk remainder methods. 2022-11-20 11:43:23 -05:00
Tshepang Mbambo
bebe5db517 replace unusual grammar 2022-11-20 17:28:34 +02:00
Ralf Jung
428ab59fb7 enable fuzzy_provenance_casts in libcore+tests 2022-11-20 16:04:16 +01:00
Guillaume Gomez
b01502a398 Extend GUI tests to check kbd colors 2022-11-20 14:32:49 +01:00
Guillaume Gomez
18b45d8144 Migrate kdb colors to CSS variables 2022-11-20 14:32:49 +01:00
bors
911cbf8e46 Auto merge of #104617 - RalfJung:miri, r=RalfJung
update Miri

r? `@thomcc` for the lib changes (removing a `cfg(miri)` that is no longer needed)
2022-11-20 12:57:48 +00:00
Ralf Jung
c043a0e7d6 cfg(miri) no longer needed in sys/unix/time.rs 2022-11-20 12:13:48 +01:00
Ralf Jung
a689eb0ded update lockfile 2022-11-20 12:13:48 +01:00
bors
8459a16869 Auto merge of #2683 - RalfJung:align_offset, r=RalfJung
make align_offset always work on no-provenance pointers

Fixes https://github.com/rust-lang/miri/issues/2682
2022-11-20 10:16:02 +00:00
bors
9cdfe03b06 Auto merge of #103390 - compiler-errors:metadata-mod-regions, r=eholk
Check fat pointer metadata compatibility modulo regions

Regions don't really mean anything anyways during hir typeck.

If this `erase_regions` makes anyone nervous, it's probably equally valid to just equate the types using a type relation, but regardless we should _not_ be using strict type equality while region variables are present.

Fixes #103384
2022-11-20 10:09:39 +00:00
Ralf Jung
c8c82a0bca make align_offset always work on no-provenance pointers 2022-11-20 11:01:00 +01:00
bors
c26b510dbc Auto merge of #2681 - RalfJung:seed, r=oli-obk
make miri-seed a regular integer, and also set layout-seed in many-seeds

This makes the seed format consistent between `-Zlayout-seed` and `-Zmiri-seed`.
2022-11-20 09:49:34 +00:00
Ralf Jung
772d521616 make miri-seed a regular integer, and also set layout-seed in many-seeds 2022-11-20 10:49:13 +01:00
Ralf Jung
e19bc6eb80 move core::arch into separate file 2022-11-20 10:28:14 +01:00
Fabian Hintringer
0f9384603a Improve documentation of Stack size 2022-11-20 09:58:30 +01:00
Ralf Jung
2bb28c174b avoid non-strict-provenance casts in libcore tests 2022-11-20 09:58:29 +01:00
bors
e07425d55b Auto merge of #98914 - fee1-dead-contrib:min-deref-patterns, r=compiler-errors
Minimal implementation of implicit deref patterns for Strings

cc `@compiler-errors` `@BoxyUwU` https://github.com/rust-lang/lang-team/issues/88 #87121

~~I forgot to add a feature gate, will do so in a minute~~ Done
2022-11-20 07:16:42 +00:00
bors
0a9e5e8e81 Auto merge of #2680 - RalfJung:rustup, r=RalfJung
Rustup
2022-11-20 07:06:11 +00:00
Ralf Jung
4da7d4b168 fix unused warning in a test 2022-11-20 08:04:36 +01:00
Ralf Jung
3865e654f0 Merge from rustc 2022-11-20 07:48:27 +01:00
Ralf Jung
aada2d1689 Preparing for merge from rustc 2022-11-20 07:48:21 +01:00