Commit Graph

263909 Commits

Author SHA1 Message Date
bors
feeba198f2 Auto merge of #128792 - compiler-errors:foreign-sig, r=spastorino
Use `FnSig` instead of raw `FnDecl` for `ForeignItemKind::Fn`, fix ICE for `Fn` trait error on safe foreign fn

Let's use `hir::FnSig` instead of `hir::FnDecl + hir::Safety` for `ForeignItemKind::Fn`. This consolidates some handling code between normal fns and foreign fns.

Separetly, fix an ICE where we weren't handling `Fn` trait errors for safe foreign fns.

If perf is bad for the first commit, I can rework the ICE fix to not rely on it. But if perf is good, I prefer we fix and clean up things all at once 👍

r? spastorino

Fixes #128764
2024-08-17 19:35:01 +00:00
Chris Denton
0156eb57a1
Always use ar_archive_writer for import libs 2024-08-17 19:10:46 +00:00
tiif
56eee8e870 Apply test fix
- Fix epoll_ctl_del test
- Simplified epoll_ctl_mod test and add test_no_notification_for_unregister_flag
- Use assert_eq(0) for epoll_ctl
2024-08-18 01:19:07 +08:00
bors
0f26ee4fd9 Auto merge of #129202 - matthiaskrgr:rollup-wev7uur, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #128989 (Emit an error for invalid use of the linkage attribute)
 - #129167 (mir/pretty: use `Option` instead of `Either<Once, Empty>`)
 - #129168 (Return correct HirId when finding body owner in diagnostics)
 - #129191 (rustdoc-json: Clean up serialization and printing.)
 - #129192 (Remove useless attributes in merged doctest generated code)
 - #129196 (Remove a useless ref/id/ref round-trip from `pattern_from_hir`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-17 17:09:33 +00:00
Michael Goulet
b2dd943d4b Use cnum for extern crate data 2024-08-17 12:50:18 -04:00
Matthias Krüger
4e6147d956
Rollup merge of #129196 - Zalathar:ref-id-ref, r=compiler-errors
Remove a useless ref/id/ref round-trip from `pattern_from_hir`

This re-lookup of `&hir::Pat` by its ID appears to be an artifact of earlier complexity that has since been removed from the compiler.

Merely deleting the let/match results in borrow errors, but sprinkling `'tcx` in the signature allows it to work again, so I suspect that this code's current function is simply to compensate for overly loose lifetimes in the signature. Perhaps it made more sense at a time when HIR lifetimes were not tied to `'tcx`.

I spotted this while working on some more experimental changes, which is why I've extracted it into its own PR.
2024-08-17 18:18:21 +02:00
Matthias Krüger
8a023b31bd
Rollup merge of #129192 - GuillaumeGomez:rm-useless-merged-doctest-attrs, r=notriddle
Remove useless attributes in merged doctest generated code

I took another look at the generated code for merged doctests and it seems like those attributes are only useful when running `rustc --test`, which isn't the case for merged doctests. Less code generated. \o/

r? `@notriddle`
2024-08-17 18:18:20 +02:00
Matthias Krüger
1a95a5f2db
Rollup merge of #129191 - aDotInTheVoid:rdj-serial-cleanup, r=GuillaumeGomez
rustdoc-json: Clean up serialization and printing.

Somewhat a followup to #128963, but makes sense regardless.

- Renames `out_path` to `out_dir` because it's not the path to the JSON, but the directory
  - Also adds a comment explaining `None`
- Renames `write` to `serialize_and_write` because it does both.
  - Also renames the self-profile activity name to be clear this measures both IO cost and serialization CPU cost
  - Expands the timer to cover flushing
- Renames `output` to `output_crate`, to emphasize it's the contents, not the `--output` flag.

r? `@GuillaumeGomez`
2024-08-17 18:18:19 +02:00
Matthias Krüger
ddbbda47eb
Rollup merge of #129168 - BoxyUwU:mismatched_ty_correct_id, r=compiler-errors
Return correct HirId when finding body owner in diagnostics

Fixes #129145
Fixes #128810

r? ```@compiler-errors```

```rust
fn generic<const N: u32>() {}

trait Collate<const A: u32> {
    type Pass;
    fn collate(self) -> Self::Pass;
}

impl<const B: u32> Collate<B> for i32 {
    type Pass = ();
    fn collate(self) -> Self::Pass {
        generic::<{ true }>()
        //~^ ERROR: mismatched types
    }
}
```

When type checking the `{ true }` anon const we would error with a type mismatch. This then results in diagnostics code attempting to check whether its due to a type mismatch with the return type. That logic was implemented by walking up the hir until we reached the body owner, except instead of using the `enclosing_body_owner` function it special cased various hir nodes incorrectly resulting in us walking out of the anon const and stopping at `fn collate` instead.

This then resulted in diagnostics logic inside of the anon consts `ParamEnv` attempting to do trait solving involving the `<i32 as Collate<B>>::Pass` type which ICEs because it is in the wrong environment.

I have rewritten this function to just walk up until it hits the `enclosing_body_owner` and made some other changes since I found this pretty hard to read/understand. Hopefully it's easier to understand now, it also makes it more obvious that this is not implemented in a very principled way and is definitely missing cases :)
2024-08-17 18:18:19 +02:00
Matthias Krüger
9c910ae7ee
Rollup merge of #129167 - cuviper:either-once-empty, r=Nadrieril
mir/pretty: use `Option` instead of `Either<Once, Empty>`

`Either` is wasteful for a one-or-none iterator, especially since `Once`
is already an `option::IntoIter` internally. We don't really need any of
the iterator mechanisms in this case, just a single conditional insert.
2024-08-17 18:18:18 +02:00
Matthias Krüger
cfeded47a4
Rollup merge of #128989 - s7tya:check-linkage-attribute-pos, r=petrochenkov
Emit an error for invalid use of the linkage attribute

fixes #128486

Currently, the use of the linkage attribute for Mod, Impl,... is incorrectly permitted. This PR will correct this issue by generating errors, and I've also added some UI test cases for it.

Related: #128552.
2024-08-17 18:18:18 +02:00
bors
6ac5bbbe02 Auto merge of #3823 - RalfJung:sync, r=RalfJung
simplify synchronization object creation logic
2024-08-17 15:42:23 +00:00
Ralf Jung
7c811203cd simplify synchronization object creation logic 2024-08-17 17:39:22 +02:00
bors
3e698d0287 Auto merge of #3822 - RalfJung:tls, r=RalfJung
tls_leak_main_thread_allowed: make test check target_thread_local

Instead of ignoring the test entirely on some targets, make the test check the `target_thread_local` flag to determine whether `thread_local!` statics can be tracked by Miri and hence can have main-thread-TLS leaks ignored.
2024-08-17 14:45:42 +00:00
Ralf Jung
bd4ef64a60 run TLS tests on Solarish 2024-08-17 16:44:05 +02:00
Ralf Jung
34e8245e4c tls_leak_main_thread_allowed: make test check target_thread_local 2024-08-17 16:41:53 +02:00
bors
9b318d2e93 Auto merge of #128786 - estebank:multiple-crate-versions, r=fee1-dead
Detect multiple crate versions on method not found

When a type comes indirectly from one crate version but the imported trait comes from a separate crate version, the called method won't be found. We now show additional context:

```
error[E0599]: no method named `foo` found for struct `dep_2_reexport::Type` in the current scope
 --> multiple-dep-versions.rs:8:10
  |
8 |     Type.foo();
  |          ^^^ method not found in `Type`
  |
note: there are multiple different versions of crate `dependency` in the dependency graph
 --> multiple-dep-versions.rs:4:32
  |
4 | use dependency::{do_something, Trait};
  |                                ^^^^^ `dependency` imported here doesn't correspond to the right crate version
  |
 ::: ~/rust/build/x86_64-unknown-linux-gnu/test/run-make/crate-loading/rmake_out/multiple-dep-versions-1.rs:4:1
  |
4 | pub trait Trait {
  | --------------- this is the trait that was imported
  |
 ::: ~/rust/build/x86_64-unknown-linux-gnu/test/run-make/crate-loading/rmake_out/multiple-dep-versions-2.rs:4:1
  |
4 | pub trait Trait {
  | --------------- this is the trait that is needed
5 |     fn foo(&self);
  |        --- the method is available for `dep_2_reexport::Type` here
```

Fix #128569, fix #110926, fix #109161, fix #81659, fix #51458, fix #32611. Follow up to #124944.
2024-08-17 14:40:04 +00:00
Zalathar
194ade1267 Remove a useless ref/id/ref round-trip from pattern_from_hir
This re-lookup of `&hir::Pat` by its ID appears to be an artifact of earlier
complexity that has since been removed from the compiler.
2024-08-17 22:18:37 +10:00
bors
c6f81a452e Auto merge of #126877 - GrigorenkoPV:clone_to_uninit, r=dtolnay
CloneToUninit impls

As per #126799.

Also implements it for `Wtf8` and both versions of `os_str::Slice`.

Maybe it is worth to slap `#[inline]` on some of those impls.

r? `@dtolnay`
2024-08-17 11:39:08 +00:00
Guillaume Gomez
7bde314de8 Remove useless attributes in merged doctest generated code 2024-08-17 13:24:38 +02:00
Alona Enraght-Moony
321d40f060 rustdoc-json: Clean up serialization and printing. 2024-08-17 11:00:26 +00:00
bors
0058752986 Auto merge of #3819 - RalfJung:epoll-test, r=RalfJung
epoll test: further clean up check_epoll_wait

Given that `check_epoll_wait` compared the length of the two slices, I don't think it was possible for it to ever return `false`. It's also strange to have some requirements checked inside the function and some checked by the caller, so let's just move it all inside the function.

Cc `@tiif` -- did I miss anything?
2024-08-17 10:24:29 +00:00
bors
a4222b97ca Auto merge of #3815 - RalfJung:pipe, r=RalfJung
implement pipe and pipe2

Fixes https://github.com/rust-lang/miri/issues/3746
2024-08-17 09:59:37 +00:00
Ralf Jung
465df5656f epoll test: further clean up check_epoll_wait 2024-08-17 11:47:29 +02:00
bors
db9a97fbb0 Auto merge of #3817 - rust-lang:rustup-2024-08-17, r=RalfJung
Automatic Rustup
2024-08-17 09:33:36 +00:00
Ralf Jung
02a11668a3 SocketPair -> AnonSocket, because a single FD is not a pair 2024-08-17 11:32:19 +02:00
Ralf Jung
5d59bdefb4 test cleanup 2024-08-17 11:32:18 +02:00
Ralf Jung
5402be8f99 socketpair: test behavior when one end got closed 2024-08-17 11:32:18 +02:00
Ralf Jung
99d742e9b0 implement pipe and pipe2 2024-08-17 11:32:17 +02:00
bors
426a60abc2 Auto merge of #128598 - RalfJung:float-comments, r=workingjubilee
float to/from bits and classify: update for float semantics RFC

With https://github.com/rust-lang/rfcs/pull/3514 having been accepted, it is clear that hardware which e.g. flushes subnormal to zero is just non-conformant from a Rust perspective -- this is a hardware bug, or maybe an LLVM backend bug (where LLVM doesn't lower floating-point ops in a way that they have the standardized behavior). So update the comments here to make it clear that we don't have to do any of this, we're just being nice.

Also remove the subnormal/NaN checks from the (unstable) const-version of to/from-bits; they are not needed since we decided with the aforementioned RFC that it is okay to get a different result at const-time and at run-time.

r? `@workingjubilee` since I think you wrote many of the comments I am editing here.
2024-08-17 09:13:13 +00:00
bors
78dfb8a108 Auto merge of #3814 - tiif:epollhup, r=RalfJung
Add epoll EPOLLHUP flag support

Related discussion in https://github.com/rust-lang/miri/issues/3811#issuecomment-2293854742.

This PR added support for ``EPOLLHUP`` flag.
2024-08-17 08:57:07 +00:00
Ralf Jung
cab81d3fa9
extend comments on HUP vs RDHUP 2024-08-17 10:36:46 +02:00
bors
94e57fcf54 Auto merge of #3807 - RalfJung:projects, r=oli-obk
add 'project' process guidlines for larger contributions

Fixes https://github.com/rust-lang/miri/issues/3443

I am honestly not entirely sure what the consensus from what issue was. I feel like the epoll PR worked reasonably well, and not having been closely involved I am not sure which process `@oli-obk` followed there. Compared to the first draft in #3443 I tried to make this less formal and framed more as guidelines than hard rules.
2024-08-17 08:30:56 +00:00
Ralf Jung
5f33085a7f more clear NAN names and fix broken_floats logic
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2024-08-17 10:26:59 +02:00
Ralf Jung
53e1a2ee46 disable problematic float-conv tests in i586 targets
also fix typo in const-float-bits-conv
2024-08-17 10:26:53 +02:00
Zalathar
3116db669c Port run-make/libtest-json/validate_json.py to Rust
This is a trivial Python script that simply tries to parse each line of stdin
(i.e. the test process output) as JSON, to verify that the overall output is
JSON Lines.

We can perform the same check directly in `rmake.rs` using `serde_json`.
2024-08-17 18:15:38 +10:00
Shina
3c8dad152b Emit an error for invalid use of the linkage attribute 2024-08-17 15:03:20 +09:00
The Miri Cronjob Bot
dc0faecfcf Merge from rustc 2024-08-17 05:02:50 +00:00
The Miri Cronjob Bot
23b57e8994 Preparing for merge from rustc 2024-08-17 04:54:54 +00:00
bors
54a50bd86f Auto merge of #129178 - weihanglo:update-cargo, r=weihanglo
Update cargo

8 commits in 2f738d617c6ead388f899802dd1a7fd66858a691..ba8b39413c74d08494f94a7542fe79aa636e1661
2024-08-13 10:57:52 +0000 to 2024-08-16 22:48:57 +0000
- feat(update): Report when incompatible-rust-version packages are selected (rust-lang/cargo#14401)
- test: Migrate old_cargos to snapbox (rust-lang/cargo#14410)
- Correct diagnostic for `TomlDebugInfo` (rust-lang/cargo#14413)
- Add `--lockfile-path` flag (rust-lang/cargo#14326)
- test: Migrate some json tests to snapbox (rust-lang/cargo#14402)
- Implement base paths (RFC 3529) 1/n: path dep and patch support (rust-lang/cargo#14360)
- doc: convert comments to rustdoc in workspace (rust-lang/cargo#14397)
- Fix MSRV for workspace .package and .dependencies (rust-lang/cargo#14400)

r? ghost
2024-08-17 04:11:30 +00:00
tiif
f9a7d6ec6f Move epoll_ready_events.epollhup = true up 2024-08-17 12:02:23 +08:00
bors
f24a6ba06f Auto merge of #106943 - mina86:exact_size_take_repeat, r=dtolnay
Implement DoubleEnded and ExactSize for Take<Repeat> and Take<RepeatWith>

Repeat iterator always returns the same element and behaves the same way
backwards and forwards.  Take iterator can trivially implement backwards
iteration over Repeat inner iterator by simply doing forwards iteration.

DoubleEndedIterator is not currently implemented for Take<Repeat<T>>
because Repeat doesn’t implement ExactSizeIterator which is a required
bound on DEI implementation for Take.

Similarly, since Repeat is an infinite iterator which never stops, Take
can trivially know how many elements it’s going to return.  This allows
implementing ExactSizeIterator on Take<Repeat<T>>.

While at it, observe that ExactSizeIterator can also be implemented for
Take<RepeatWhile<F>> so add that implementation too.  Since in contrast
to Repeat, RepeatWhile doesn’t guarante to always return the same value,
DoubleEndedIterator isn’t implemented.

Those changes render core::iter::repeat_n somewhat redundant.

Issue: https://github.com/rust-lang/rust/issues/104434
Issue: https://github.com/rust-lang/rust/issues/104729

- [ ] ACP: https://github.com/rust-lang/libs-team/issues/120 (this is actually ACP for repeat_n but this is nearly the same functionality so hijacking it so both approaches can be discussed in one place)
2024-08-17 01:46:24 +00:00
Weihang Lo
6c201561ac
Update cargo 2024-08-16 21:18:24 -04:00
Ben Kimock
70320c1936 Enable more debuginfo tests on Windows 2024-08-16 21:14:45 -04:00
beetrees
9bc7cea412
Fix is_val_statically_known for floats 2024-08-17 02:14:23 +01:00
bors
67d09736ea Auto merge of #116528 - daxpedda:stabilize-ready-into-inner, r=dtolnay
Stabilize `Ready::into_inner()`

This PR stabilizes `Ready::into_inner()`.

Tracking issue: #101196.
Implementation PR: #101189.

Closes #101196.
2024-08-16 23:20:38 +00:00
bors
506052d49d Auto merge of #129162 - matthiaskrgr:rollup-r0oxdev, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #128990 (Re-enable more debuginfo tests on freebsd)
 - #129042 (Special-case alias ty during the delayed bug emission in `try_from_lit`)
 - #129086 (Stabilize `is_none_or`)
 - #129149 (Migrate `validate_json.py` script to rust in `run-make/rustdoc-map-file` test)
 - #129154 (Fix wrong source location for some incorrect macro definitions)
 - #129161 (Stabilize std:🧵:Builder::spawn_unchecked)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-16 20:19:00 +00:00
Boxy
ed6315b3fe Rewrite get_fn_id_for_return_block 2024-08-16 20:53:13 +01:00
Josh Stone
29017e45a1 mir/pretty: use Option instead of Either<Once, Empty>
`Either` is wasteful for a one-or-none iterator, especially since `Once`
is already an `option::IntoIter` internally. We don't really need any of
the iterator mechanisms in this case, just a single conditional insert.
2024-08-16 12:42:02 -07:00
Michael Goulet
84633f47f6 Simplify cleaning foreign fns in rustdoc 2024-08-16 14:10:06 -04:00