Commit Graph

211212 Commits

Author SHA1 Message Date
Matthias Krüger
cc2397b2cd
Rollup merge of #104511 - dpaoliello:privateglobalworkaround, r=michaelwoerister
Mark functions created for `raw-dylib` on x86 with DllImport storage class

Fix for #104453

## Issue Details
On x86 Windows, LLVM uses 'L' as the prefix for any private global symbols (`PrivateGlobalPrefix`), so when the `raw-dylib` feature creates an undecorated function symbol that begins with an 'L' LLVM misinterprets that as a private global symbol that it created and so fails the compilation at a later stage since such a symbol must have a definition.

## Fix Details
Mark the function we are creating for `raw-dylib` with `DllImport` storage class (this was already being done for MSVC at a later point for `callee::get_fn` but not for GNU (due to "backwards compatibility")): this will cause LLVM to prefix the name with `__imp_` and so it won't mistake it for a private global symbol.
2022-11-21 14:11:10 +01:00
Matthias Krüger
b39e0c23bb
Rollup merge of #104500 - WaffleLapkin:deref-the-compiler, r=wesleywiser
`rustc_ast`: remove `ref` patterns

Or in other words use match ergonomics in `rustc_ast`. I do plan to do the same with other crates, but to keep the diff sane, let's do them one at a time.
2022-11-21 14:11:10 +01:00
Matthias Krüger
4300b9e5cf
Rollup merge of #104499 - Enselic:no-method-in-rustdoc-json, r=GuillaumeGomez
rustdoc JSON: Use `Function` everywhere and remove `Method`

Closes #100259
2022-11-21 14:11:09 +01:00
Matthias Krüger
369e44943f
Rollup merge of #104420 - TethysSvensson:master, r=JohnTitor
Fix doc example for `wrapping_abs`

The `max` variable is unused. This change introduces the `min_plus` variable, to make the example similar to the one from `saturating_abs`. An alternative would be to remove the unused variable.
2022-11-21 14:11:09 +01: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
hi-rustin
fec6ffc816 Add delay span bug
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-21 20:03:28 +08:00
Léo Lanteri Thauvin
baa59d1a77 Only declare bindings for if-let guards once per arm 2022-11-21 12:45:29 +01:00
bors
51ec465cc3 Auto merge of #9873 - smoelius:move-line-span, r=flip1995
Move `line_span` to source.rs

`line_span` is a non-public function used only in source.rs. It seems like it ought to go in source.rs.

changelog: none
2022-11-21 11:07:32 +00:00
Maybe Waffle
d9f2c0b33d Revert formatting changes of a test 2022-11-21 10:23:53 +00:00
Guillaume Gomez
90d7beb624 Extend GUI test for alias search result 2022-11-21 11:15:54 +01:00
Guillaume Gomez
ca0aad8795 Migrate search result alias to CSS variables 2022-11-21 11:15:41 +01:00
Maybe Waffle
417ed9fee2 Remove ref patterns from rustc_ast
Also use if let chains in one case.
2022-11-21 09:18:59 +00:00
Michael Howell
32c75235e6 rustdoc: factor out common button CSS 2022-11-20 21:48:57 -07: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
Nicholas Nethercote
a6e09a19fc Streamline deriving on packed structs.
The current approach to field accesses in derived code:
- Normal case: `&self.0`
- In a packed struct that derives `Copy`: `&{self.0}`
- In a packed struct that doesn't derive `Copy`: `let Self(ref x) = *self`

The `let` pattern used in the third case is equivalent to the simpler
field access in the first case. This commit changes the third case to
use a field access.

The commit also combines two boolean arguments (`is_packed` and
`always_copy`) into a single field (`copy_fields`) earlier, to save
passing both around.
2022-11-21 14:07:39 +11: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
hi-rustin
a60e267200 Do not check transmute if has non region infer
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-21 09:03:33 +08:00
Caio
70db20e503 Move tests 2022-11-20 20:08:14 -03: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
bors
e0c1959616 Auto merge of #9592 - c410-f3r:arith, r=Jarcho
[arithmetic-side-effects] Detect overflowing associated constants of integers

Triggers the negation of maximum unsigned integers using associated constants. Rustc already handles `-128i8` but doesn't handle `-i8::MAX`.

At the same time, allows stuff like `-1234`.

changelog: FP: [arithmetic-side-effects] Detect overflowing associated constants of integers
2022-11-20 22:51:25 +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
Rune Tynan
8998711d9b Only one feature gate needed 2022-11-20 17:10:47 -05:00
bors
a85c8f33ff Auto merge of #9870 - koka831:unformat-unused-rounding, r=Jarcho
Keep original literal notation in suggestion

While I did some investigation of https://github.com/rust-lang/rust-clippy/issues/9866 (I couldn't reproduce it though) I found that `unused_rounding` formats as follows:

```rust
3.0_f64.round() // => 3.0f64
```

This PR makes them preserve as the original notation.

```rust
3.0_f64.round() // => 3.0_f64
```

changelog: Suggestion Enhancement: [`unused_rounding`]: The suggestion now preserves the original float literal notation
2022-11-20 22:09:25 +00:00
Nicholas Bishop
60546088bc dist: Ensure UEFI rlibs are all COFF
If clang isn't the C compiler used for the UEFI targets, or if the wrong
`--target` is passed to clang, we will get ELF objects in some
rlibs. This will cause problems at link time when trying to compile a
UEFI program that uses any of those objects. Add a check to the dist
step for UEFI targets that reads each rlib with the `object` crate and
fails with an error if any non-COFF objects are found.
2022-11-20 20:25:22 +00:00
Rune Tynan
07911879d2 Use ? instead of match 2022-11-20 15:01:22 -05:00
Rune Tynan
a5fecc6905 Fix issue number 2022-11-20 15:01:21 -05:00
Rune Tynan
7972b8aa37 Add derive_const feature 2022-11-20 15:01:21 -05:00
Rune Tynan
6f2dcac78b Update with derive_const 2022-11-20 15:01:21 -05:00
Rune Tynan
414e84a2f7 Add stability for alignment 2022-11-20 15:01:21 -05:00
Rune Tynan
9f4b4e46a3 constify remaining layout methods
Remove bad impl for Eq

Update Cargo.lock and fix last ValidAlign
2022-11-20 15:01:21 -05:00
bors
26562973b3 Auto merge of #13653 - VannTen:fix/doc-typo-vim-lsp, r=Veykril
Fix typo on 'configuration' anchor

https://rust-analyzer.github.io/manual.html#_configuration lands you at
the start of the page, while
https://rust-analyzer.github.io/manual.html#configuration correctly puts
you at the correct anchor
2022-11-20 19:59:43 +00:00
Nicholas Bishop
01a2a546be test-various: Use clang for the UEFI test
This syncs it with how the UEFI targets are built in dist-various-2.
2022-11-20 19:16:43 +00: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
bors
75e1de88f8 Auto merge of #13649 - ZZzzaaKK:master, r=lnicola
Improve grammar of architecture.md

Corrects a few grammar mistakes I found while reading the documentation 😄
2022-11-20 18:31:50 +00:00
Ralf Jung
7f5adddb25 enable fuzzy_provenance_casts lint in libstd 2022-11-20 19:23:28 +01:00
Ralf Jung
644a5a34dd enable fuzzy_provenance_casts lint in liballoc 2022-11-20 19:12:18 +01: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