Commit Graph

226617 Commits

Author SHA1 Message Date
Michael Goulet
bc78d0cbf1 Error on unconstrained lifetime in RPITIT 2023-06-14 05:20:31 +00:00
bors
6330daade9 Auto merge of #112062 - lukas-code:unsized-layout, r=wesleywiser
Make struct layout not depend on unsizeable tail

fixes (after backport) https://github.com/rust-lang/rust/issues/112048

Since unsizing `Ptr<Foo<T>>` -> `Ptr<Foo<U>` just copies the pointer and adds the metadata, the layout of `Foo` must not depend on niches in and alignment of the tail `T`.

Nominating for beta 1.71, because it will have this issue: `@rustbot` label beta-nominated
2023-06-13 22:34:59 +00:00
Wesley Wiser
b982f3a988 Add test case for unsizing with niche 2023-06-13 15:32:42 -04:00
bors
371994e0d8 Auto merge of #112314 - ferrocene:pa-core-alloc-abort, r=bjorn3
Ignore `core`, `alloc` and `test` tests that require unwinding on `-C panic=abort`

Some of the tests for `core` and `alloc` require unwinding through their use of `catch_unwind`. These tests fail when testing using `-C panic=abort` (in my case through a target without unwinding support, and `-Z panic-abort-tests`), while they should be ignored as they don't indicate a failure.

This PR marks all of these tests with this attribute:

```rust
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
```

I'm not aware of a way to test this on rust-lang/rust's CI, as we don't test any target with `-C panic=abort`, but I tested this locally on a Ferrocene target and it does indeed make the test suite pass.
2023-06-13 19:03:27 +00:00
bors
5683791ebb Auto merge of #112017 - Nemo157:unsafe-block-rustfix, r=eholk
Add MVP suggestion for `unsafe_op_in_unsafe_fn`

Rebase of https://github.com/rust-lang/rust/pull/99827

cc tracking issue https://github.com/rust-lang/rust/issues/71668

No real changes since the original PR, just migrated the new suggestion to use fluent messages and added a couple more testcases, AFAICT from the discussion there were no outstanding changes requested.
2023-06-13 15:57:59 +00:00
Pietro Albini
a988dc2711
remove patch from cranelift backend to ignore unwinding tests 2023-06-13 15:53:26 +02:00
Pietro Albini
44556eed36
ignore core, alloc and test tests that require unwinding on panic=abort 2023-06-13 15:53:24 +02:00
Wim Looman
802c1d5979
Add test cases for suggestions with unsafe operations contained inside macros 2023-06-13 15:48:57 +02:00
Wim Looman
8f3e876e52
Add note about unsafe functions body not being unsafe 2023-06-13 15:48:57 +02:00
Wim Looman
62a712a8bb
Hide suggestion to wrap function in unsafe block 2023-06-13 15:48:55 +02:00
Wim Looman
aca61b2c07
Test that a couple more types of unsafe-ops get a wrapping unsafe block added 2023-06-13 15:47:02 +02:00
Léo Lanteri Thauvin
975152ce30
Add MVP suggestion for unsafe_op_in_unsafe_fn
Nemo157 rebase notes: Migrated the changes to the lint into fluent
2023-06-13 15:46:54 +02:00
bors
2ca8d358e5 Auto merge of #112549 - jieyouxu:fix-tests-for-unit-bindings, r=Nilstrieb
Adjust UI tests for `unit_bindings` lint

- Explicitly annotate `let x: () = expr;` where `x` has unit type, or remove the unit binding to leave only `expr;` instead.
- Use `let () = init;` or `let pat = ();` where appropriate.
- Fix disjoint-capture-in-same-closure test which wasn't actually testing a closure: `tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs`.

Note that unfortunately there's *a lot* of UI tests, there are a couple of places where I may have left something like `let (): ()` (this is not needed but is left over from an ealier version of the lint) which is bad style.

This PR is to help with the `unit_bindings` lint at #112380.
2023-06-13 13:07:43 +00:00
bors
4bd4e2ea82 Auto merge of #112386 - loongarch-rs:reloc-static, r=eholk
loongarch64-unknown-none*: Set default relocation model to static

This PR sets the default relocation model to `static` for `loongarch64-unknown-none*` targets. This change aims to streamline the development of the bare-metal project by removing the need for the executable program loader to implement relocation.
2023-06-13 09:13:03 +00:00
bors
caeea3f0a2 Auto merge of #112575 - matthiaskrgr:rollup-7a8d7tg, r=matthiaskrgr
Rollup of 2 pull requests

Successful merges:

 - #111885 (Don't ICE on unsized `extern "rust-call"` call)
 - #112558 (Fix typo in mod.rs)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-13 06:13:43 +00:00
Matthias Krüger
aee8e10a26
Rollup merge of #112558 - eltociear:patch-21, r=thomcc
Fix typo in mod.rs

assoicated -> associated
2023-06-13 07:02:28 +02:00
Matthias Krüger
b7706e891d
Rollup merge of #111885 - compiler-errors:rust-call-abi-sized, r=eholk
Don't ICE on unsized `extern "rust-call"` call

Conceptually builds on #111864, but doesn't depend on it.
2023-06-13 07:02:28 +02:00
bors
de1ff0a8b5 Auto merge of #99339 - yanchith:binary-heap-ta, r=Amanieu
Make BinaryHeap parametric over Allocator

Tracking issue: #32838
Related: https://github.com/rust-lang/wg-allocators/issues/7

This parametrizes `BinaryHeap` with `A`, similarly to how other collections are parametrized.

A couple things I left out:

```
BinaryHeap::append

    Currently requires both structures to have the same allocator type. Could
    change, but depends on Vec::append, which has the same constraints.

impl<T: Ord> Default for BinaryHeap<T>

    Not parametrized, because there's nowhere to conjure the allocator from.

impl<T: Ord> FromIterator<T> for BinaryHeap<T>

    Not parametrized, because there's nowhere to conjure the allocator from.

impl<T: Ord, const N: usize> From<[T; N]> for BinaryHeap<T>

    Not parametrized, because there's nowhere to conjure the allocator from.

unsafe impl<I> AsVecIntoIter for IntoIter<I>

    AsVecIntoIter is not allocator aware, and I didn't dare change it without guidance. Is this something important?
```

I've seen very few tests for allocator_api in general, but I'd like to at least test this on some usage code in my projects before moving forward.

EDIT: Updated the list of impls and functions that are not affected by this. `BinaryHeap` no longer has a `SpecExtend` impl, and prior work made implementing `Extend` possible.
2023-06-13 03:23:12 +00:00
bors
5e8c53f1f6 Auto merge of #112524 - GuillaumeGomez:migrate-gui-test-color-14, 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-06-13 00:35:32 +00:00
bors
df77afbcaf Auto merge of #112563 - matthiaskrgr:rollup-ebetrzi, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #112302 (Suggest using `ptr::null_mut` when user provided `ptr::null` to a function expecting `ptr::null_mut`)
 - #112416 (Fix debug ICE for extern type with where clauses)
 - #112527 (Add windows_sys type definitions for ARM32 manually)
 - #112546 (new solver: extend assert to other aliases)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-12 17:23:48 +00:00
Matthias Krüger
9cb785b9d3
Rollup merge of #112546 - lcnr:opaque-type-cleanup, r=compiler-errors
new solver: extend assert to other aliases
2023-06-12 17:44:39 +02:00
Matthias Krüger
9c4cff424e
Rollup merge of #112527 - bdbai:fix/winarm32, r=ChrisDenton
Add windows_sys type definitions for ARM32 manually

`windows_sys` bindings do not include platform-specific type definitions for ARM 32 architecture, so it breaks `thumbv7a-pc-windows-msvc` and `thumbv7a-uwp-windows-msvc` targets. This PR tries to add them back by manually inserting them together with the generated ones.

`WSADATA` is copied from the generated definition for `x86`. `CONTEXT` is copied from the definition before `windows_sys` is introduced (which is just an empty enum): 4a18324a4d/library/std/src/sys/windows/c.rs (L802).

Fixes #112265.
2023-06-12 17:44:38 +02:00
Matthias Krüger
8475a88d67
Rollup merge of #112416 - jieyouxu:issue-112363, r=wesleywiser
Fix debug ICE for extern type with where clauses

Fixes #112363.
2023-06-12 17:44:38 +02:00
Matthias Krüger
a5245b5894
Rollup merge of #112302 - jieyouxu:issue-85184, r=WaffleLapkin
Suggest using `ptr::null_mut` when user provided `ptr::null` to a function expecting `ptr::null_mut`

```
error[E0308]: mismatched types
  --> $DIR/ptr-null-mutability-suggestions.rs:9:24
   |
LL |     expecting_null_mut(ptr::null());
   |     ------------------ ^^^^^^^^^^^
   |     |                  |
   |     |                  types differ in mutability
   |     |                  help: consider using `core::ptr::null_mut` instead: `core::ptr::null_mut()`
   |     arguments to this function are incorrect
   |
   = note: expected raw pointer `*mut u8`
              found raw pointer `*const _`
note: function defined here
  --> $DIR/ptr-null-mutability-suggestions.rs:6:4
   |
LL | fn expecting_null_mut(_: *mut u8) {}
   |    ^^^^^^^^^^^^^^^^^^ ----------
```

Closes #85184.
2023-06-12 17:44:37 +02:00
Ikko Eltociear Ashimine
69de7ca199
Fix typo in mod.rs
assoicated -> associated
2023-06-13 00:09:13 +09:00
bdbai
df08f56b08 Add comment for arm_shim in generate-windows-sys 2023-06-12 22:40:30 +08:00
bdbai
f7f25b0e2f Add windows_sys typedef for Win ARM32 2023-06-12 22:40:30 +08:00
bors
b963a57205 Auto merge of #112541 - ozkanonur:gtfx, r=clubby789
implement stdout streaming in `render_tests::Renderer`

This way, we can show the test dot characters on the console immediately, without having to wait for the entire line to finish.

cc `@GuillaumeGomez`
2023-06-12 14:34:20 +00:00
许杰友 Jieyou Xu (Joe)
edafbaffb2
Adjust UI tests for unit_bindings
- Either explicitly annotate `let x: () = expr;` where `x` has unit
  type, or remove the unit binding to leave only `expr;` instead.
- Fix disjoint-capture-in-same-closure test
2023-06-12 20:24:48 +08:00
lcnr
e74d1cd581 update comment 2023-06-12 12:47:09 +02:00
bors
cb882fa998 Auto merge of #112543 - GuillaumeGomez:revert-112429, r=lcnr
[rustdoc] Fix infinite loop when retrieving impls for type alias

Fixes #112515.
Reverts #112429.

r? `@lcnr`
2023-06-12 10:08:45 +00:00
ozkanonur
6c966dc656 implement stdout streaming in render_tests::Renderer
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-06-12 13:03:00 +03:00
lcnr
f45502d20d extend assert 2023-06-12 11:58:40 +02:00
Guillaume Gomez
b93ca0146a Add regression test for #112515 2023-06-12 11:35:19 +02:00
Guillaume Gomez
810c5176ad Revert "List matching impls on type aliases"
This reverts commit 4b1d13d984.
2023-06-12 11:27:56 +02:00
Guillaume Gomez
87d2361dcb Revert "Add regression test for #32077"
This reverts commit 6f552c800b.
2023-06-12 11:18:28 +02:00
Guillaume Gomez
7c5e41631d Revert "Fix intra-doc links from pointer appearing in windows HANDLE type alias"
This reverts commit 2ce7cd906b.
2023-06-12 11:18:28 +02:00
许杰友 Jieyou Xu (Joe)
72421bfb0c
Fix debug ICE for extern type with where clauses 2023-06-12 15:15:45 +08:00
bors
fd0a3313f7 Auto merge of #112261 - jieyouxu:c-like-ptr-arithmetics-diagnostics, r=WaffleLapkin
Add help for trying to do C-like pointer arithmetics

This PR adds help messages for these cases:

```rust
fn main() {
    let ptr1: *const u32 = std::ptr::null();
    let ptr2: *const u32 = std::ptr::null();
    let a = ptr1 + 5;
    let b = ptr1 - 5;
    let c = ptr2 - ptr1;
    let d = ptr1[5];
}
```

### Current Output

```
error[E0369]: cannot add `{integer}` to `*const u32`
 --> tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs:4:18
  |
4 |     let a = ptr1 + 5; //~ ERROR cannot add
  |             ---- ^ - {integer}
  |             |
  |             *const u32

error[E0369]: cannot subtract `{integer}` from `*const u32`
 --> tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs:5:18
  |
5 |     let b = ptr1 - 5; //~ ERROR cannot subtract
  |             ---- ^ - {integer}
  |             |
  |             *const u32

error[E0369]: cannot subtract `*const u32` from `*const u32`
 --> tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs:6:18
  |
6 |     let c = ptr2 - ptr1; //~ ERROR cannot subtract
  |             ---- ^ ---- *const u32
  |             |
  |             *const u32

error[E0608]: cannot index into a value of type `*const u32`
 --> tests/ui/typeck/issue-112252-ptr-arithmetics-help.rs:7:13
  |
7 |     let d = ptr1[5]; //~ ERROR cannot index
  |             ^^^^^^^

error: aborting due to 4 previous errors
```

### Output After This PR

```
error[E0369]: cannot add `{integer}` to `*const u32`
  --> $DIR/issue-112252-ptr-arithmetics-help.rs:6:20
   |
LL |     let _a = _ptr1 + 5;
   |              ------^--
   |              |       |
   |              |       {integer}
   |              *const u32
   |              help: consider using `wrapping_add` or `add` for pointer + {integer}: `_ptr1.wrapping_add(5)`

error[E0369]: cannot subtract `{integer}` from `*const u32`
  --> $DIR/issue-112252-ptr-arithmetics-help.rs:7:20
   |
LL |     let _b = _ptr1 - 5;
   |              ------^--
   |              |       |
   |              |       {integer}
   |              *const u32
   |              help: consider using `offset` for pointer - {integer}: `unsafe { _ptr1.offset(-5) }`

error[E0369]: cannot subtract `*const u32` from `*const u32`
  --> $DIR/issue-112252-ptr-arithmetics-help.rs:8:20
   |
LL |     let _c = _ptr2 - _ptr1;
   |              ------^------
   |              |       |
   |              |       *const u32
   |              *const u32
   |              help: consider using `offset_from` for pointer - pointer if the pointers point to the same allocation: `_ptr2.offset_from(_ptr1)`

error[E0608]: cannot index into a value of type `*const u32`
  --> $DIR/issue-112252-ptr-arithmetics-help.rs:9:14
   |
LL |     let _d = _ptr1[5];
   |              ^^^^^^^^
   |
help: consider using `wrapping_add` or `add` for indexing into raw pointer
   |
LL |     let _d = _ptr1.wrapping_add(5);
   |              ~~~~~~~~~~~~~~~~~~~~~

error: aborting due to 4 previous errors
```

Closes #112252.
2023-06-12 07:15:19 +00:00
bors
77dba225c1 Auto merge of #111801 - Bryanskiy:lints1, r=petrochenkov
Private-in-public lints implementation

Next part of RFC https://github.com/rust-lang/rust/issues/48054.

r? `@petrochenkov`
2023-06-11 22:18:23 +00:00
Bryanskiy
6d46382f6f Private-in-public lints implementation 2023-06-12 01:02:19 +03:00
yanchith
e0e355dd25 Impl allocator function for iterators 2023-06-11 22:56:16 +02:00
yanchith
d9b6181d2f Remove explicit lifetimes 2023-06-11 22:42:50 +02:00
bors
37998ab508 Auto merge of #112530 - matthiaskrgr:rollup-qee1kc1, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #112487 (Update documentation for `tools` defaults)
 - #112513 (Dont compute `opt_suggest_box_span` span for TAIT)
 - #112528 (bootstrap: Don't override `debuginfo-level = 1` to mean `line-tables-only`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-11 17:33:51 +00:00
Matthias Krüger
c1f2da5683
Rollup merge of #112528 - jyn514:fix-debuginfo-level, r=Mark-Simulacrum
bootstrap: Don't override `debuginfo-level = 1` to mean `line-tables-only`

This has real differences in the effective debuginfo: in particular, it omits the module-level information and makes perf less useful (it can't distinguish "self" from "child" time anymore).

Allow passing `line-tables-only` directly in config.toml instead.

See https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/debuginfo.20in.20try.20builds/near/365090631 and https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bsteering.5D.202023-06-09/near/364883519 for more discussion. This effectively reverts the cargo half of https://github.com/rust-lang/rust/pull/110221 to avoid regressing https://github.com/rust-lang/rust/issues/60020 again in 1.72.
2023-06-11 18:38:29 +02:00
Matthias Krüger
d9ae7180e4
Rollup merge of #112513 - compiler-errors:dont-compute-box-span-for-tait, r=cjgillot
Dont compute `opt_suggest_box_span` span for TAIT

Fixes #112434

Also a couple more commits on top, pruning some dead code and fixing another weird suggestion encountered in the above issue.
2023-06-11 18:38:28 +02:00
Matthias Krüger
733617bd16
Rollup merge of #112487 - zwhiteley:improve-docs, r=Mark-Simulacrum
Update documentation for `tools` defaults

This PR alters the information in the tools profile config to mention that `download-rustc` uses the stage2 toolchain and not the stage1 toolchain (see https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Unable.20to.20compile.20rustc.20MSVC and rust-lang/rustc-dev-guide#1694).
2023-06-11 18:38:28 +02:00
jyn
123693953f Don't override debuginfo-level = 1 to mean line-tables-only
This has real differences in the effective debuginfo: in particular, it omits the module-level information and breaks perf.

Allow passing `line-tables-only` directly in config.toml instead.
2023-06-11 10:14:37 -05:00
bors
81c02da94e Auto merge of #111958 - notriddle:notriddle/type-search-slice-array, r=GuillaumeGomez
rustdoc: search for slices and arrays by type with `[]`

This feature extends rustdoc to support the syntax that most users will naturally attempt to use to search for slices and arrays. Part of #60485

Function signature searches already support arrays and slices. The explicit name `primitive:slice<u8>` and `primitive:array<u8>` can be used to match a slice or array of bytes, while square brackets `[u8]` will match either one. Empty square brackets, `[]`, will match any slice regardless of what it contains.

Preview:

* [`option -> []`](https://notriddle.com/rustdoc-demo-html-3/search-slice-array/std/index.html?search=option%20-%3E%20%5B%5D)
* [`[u8] -> str`](https://notriddle.com/rustdoc-demo-html-3/search-slice-array/std/index.html?search=%5Bu8%5D%20-%3E%20str)
* [`Box<[u8]> -> str`](https://notriddle.com/rustdoc-demo-html-3/search-slice-array/std/index.html?search=Box%3C%5Bu8%5D%3E%20-%3E%20str)

Motivation:

When type-based search was first landed, it was directly described as "incomplete". Here's [a comment] from the discussion thread:

[a comment]: https://github.com/rust-lang/rust/pull/23289#issuecomment-79437386

> This is looking really great, nice work! I can think of a number of cases that aren't quite covered by this, but I feel like this is a great improvement regardless and it can always be iterated on so I'm fine landing with a few known cases where it may not work :)

Filling out the missing functionality is going to mean adding support for more of Rust's [type expression] syntax, such as slices (in this PR), tuples, references, raw pointers, function pointers, and generics.

[type expression]: https://doc.rust-lang.org/reference/types.html#type-expressions

There does seem to be demand for this sort of thing, such as [this Discord message](https://discord.com/channels/442252698964721669/443150878111694848/1042145740065099796) expressing regret at rustdoc not supporting tuples in search queries.
2023-06-11 14:48:58 +00:00
Guillaume Gomez
5894193996 Migrate GUI colors test to original CSS color format 2023-06-11 14:40:12 +02:00