1
Fork 0
Commit graph

286548 commits

Author SHA1 Message Date
Matthias Krüger
584cd13924
Rollup merge of #139513 - compiler-errors:higher-ranked-proj, r=lcnr
Report higher-ranked trait error when higher-ranked projection goal fails in new solver

~~See HACK comment inline. Not actually sure if it should be marked as a *HACK*, b/c~~ it's kinda a legitimate case we want to care about unless we're going to make the proof tree visitor *smarter* about the leak check than the actual trait solver itself.

Encountered this while battling with `NiceRegionError`s in the old solver b/c I wondered what this code ended up giving us in the *new* solver as a comparison:
```rust
trait Foo {}

impl<T: FnOnce(&())> Foo for T {}

fn baz<T: Foo>() {}

fn main() {
    baz::<fn(&'static ())>();
}
```

On master it's pretty bad:
```
error[E0271]: type mismatch resolving `<fn(&()) as FnOnce<(&(),)>>::Output == ()`
 --> <source>:8:11
  |
8 |     baz::<fn(&'static ())>();
  |           ^^^^^^^^^^^^^^^ types differ
  |
note: required for `fn(&'static ())` to implement `Foo`
 --> <source>:3:22
  |
3 | impl<T: FnOnce(&())> Foo for T {}
  |         -----------  ^^^     ^
  |         |
  |         unsatisfied trait bound introduced here
```

After this PR it's much better:
```
error[E0277]: the trait bound `fn(&'static ()): Foo` is not satisfied
 --> /home/mgx/test.rs:8:11
  |
8 |     baz::<fn(&'static ())>();
  |           ^^^^^^^^^^^^^^^ the trait `for<'a> FnOnce(&'a ())` is not implemented for `fn(&'static ())`
  |
  = note: expected a closure with arguments `(&'static (),)`
             found a closure with arguments `(&(),)`
note: required for `fn(&'static ())` to implement `Foo`
 --> /home/mgx/test.rs:3:22
  |
3 | impl<T: FnOnce(&())> Foo for T {}
  |         -----------  ^^^     ^
  |         |
  |         unsatisfied trait bound introduced here
note: required by a bound in `baz`
 --> /home/mgx/test.rs:5:11
  |
5 | fn baz<T: Foo>() {}
  |           ^^^ required by this bound in `baz`
```

r? lcnr
2025-04-09 20:23:11 +02:00
Matthias Krüger
4911635ec3
Rollup merge of #139489 - petrochenkov:noreqann, r=jieyouxu
compiletest: Add directive `dont-require-annotations`

for making matching on specific diagnostic kinds non-exhaustive.

E.g. `//@ dont-require-annotations:ERROR`, like in the examples in this PR.

cc https://github.com/rust-lang/rust/pull/139427#issuecomment-2782827583

Closes #132647 FYI `@BoxyUwU` since you've wanted this.

r? `@jieyouxu`
2025-04-09 20:23:10 +02:00
Matthias Krüger
ac41b940f2
Rollup merge of #139488 - GuillaumeGomez:add-missing-gui-test, r=camelid
Add missing regression GUI test

Add missing GUI test for #139282 (and also fixes the invalid CSS).

cc `@lolbinarycat`
r? `@notriddle`
2025-04-09 20:23:10 +02:00
Matthias Krüger
d5f930fe76
Rollup merge of #139164 - xizheyin:issue-139034, r=joboet
std: improve documentation for get_mut() methods regarding forgotten guards

Fixes #139034

This PR improves the documentation for `get_mut()` methods in `Mutex`, `RefCell`, and `RwLock` to clarify their behavior when lock guards are forgotten (e.g., via std::mem::forget).

The current documentation for these methods states that a mutable borrow "statically guarantees no locks exist", which is not entirely accurate. While a mutable borrow prevents new locks from being created, it does not clear or detect previously abandoned locks through `forget()`. This can lead to counterintuitive behavior:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=e68cefec12dcd435daf2237c16824ed3
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=81263ad652c752afd63c903113d3082c
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=311baa4edb3abf82a25c8d7bf21a4a52

r? libs
2025-04-09 20:23:09 +02:00
Matthias Krüger
3507f359b1
Rollup merge of #138628 - spastorino:add-more-ergonomic-clone-tests, r=nikomatsakis
Add more ergonomic clone tests

I've added some extra tests.

r? `@nikomatsakis`
2025-04-09 20:23:09 +02:00
Matthias Krüger
2b28e6be5a
Rollup merge of #138470 - spastorino:test-rfc2229-and-ergonomic-clones, r=nikomatsakis
Test interaction between RFC 2229 migration and use closures

r? `@nikomatsakis`

Fixes #138101
2025-04-09 20:23:08 +02:00
bors
934880f586 Auto merge of #124810 - lincot:speed-up-string-push-and-string-insert, r=tgross35
speed up `String::push` and `String::insert`

Addresses the concerns described in #116235.

The performance gain comes mainly from avoiding temporary buffers.

Complex pattern matching in `encode_utf8` (introduced in #67569) has been simplified to a comparison and an exhaustive `match` in the `encode_utf8_raw_unchecked` helper function. It takes a slice of `MaybeUninit<u8>` because otherwise we'd have to construct a normal slice to uninitialized data, which is not desirable, I guess.

Several functions still have that [unneeded zeroing](https://rust.godbolt.org/z/5oKfMPo7j), but a single instruction is not that important, I guess.

`@rustbot` label T-libs C-optimization A-str
2025-04-09 17:58:25 +00:00
Michael Goulet
f6faaee372 Report higher-ranked trait error when higher-ranked projection goal fails in new solver 2025-04-09 17:53:32 +00:00
Scott McMurray
63dcac8423 skip tests/codegen/swap-small-types when debug assertions are on
In `swap_nonoverlapping_short` there's a new `debug_assert!`, and if that's enabled then the `alloca`s don't optimize out.
2025-04-09 10:44:49 -07:00
Noah Lev
8b227a42fa rustdoc: Enable Markdown extensions when looking for doctests
We should enable these to avoid misinterpreting uses of the extended
syntax as code blocks. This happens in practice with multi-paragraph
footnotes, as discovered in #139064.
2025-04-09 13:04:57 -04:00
Scott McMurray
b06a88ff61 Add a Miri test for 134713 2025-04-09 09:09:37 -07:00
Scott McMurray
50d0ce1b42 Ensure swap_nonoverlapping is really always untyped 2025-04-09 09:09:37 -07:00
Ben Kimock
67ff33666f
saethlin is back from vacation 2025-04-09 12:03:28 -04:00
bors
48f89e7659 Auto merge of #139581 - matthiaskrgr:rollup-d6hph16, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #138869 (Try not to use verbatim paths in `Command::current_dir`)
 - #138993 (Make `cfg_match!` a semitransparent macro)
 - #139099 (Promise `array::from_fn` is generated in order of increasing indices)
 - #139364 (Make the compiler suggest actual paths instead of visible paths if the visible paths are through any doc hidden path.)
 - #139468 (Don't call `Span::with_parent` on the good path in `has_stashed_diagnostic`)
 - #139481 (Add job summary links to post-merge report)
 - #139573 (Miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-09 14:48:05 +00:00
Oli Scherer
3528a65dd7 Deduplicate target type setting in unify_and callbacks 2025-04-09 13:17:38 +00:00
Oli Scherer
34258d62cd Add a dedicated function for the common unify_and(identity) case 2025-04-09 13:00:33 +00:00
Oli Scherer
804b6c9636 Rename unify to unify_raw 2025-04-09 12:57:58 +00:00
Oli Scherer
697768a664 Simplify some unify_and calls 2025-04-09 12:55:07 +00:00
Matthias Krüger
1aa6f70e3e
Rollup merge of #139573 - RalfJung:miri-sync, r=RalfJung
Miri subtree update

r? `@ghost`
2025-04-09 14:52:39 +02:00
Matthias Krüger
704d301b43
Rollup merge of #139481 - Kobzol:post-merge-links, r=marcoieni
Add job summary links to post-merge report

This should make it much easier to investigate the individual job test/duration changes.

The GitHub API handling is a bit crude, but I didn't want to include octocrab, because it more than doubles the current number of dependencies of `citool`...

Can be tested with:
```bash
$ cargo run --manifest-path src/ci/citool/Cargo.toml post-merge-report bad13a970a 1e008dd5d8
```

r? ```@marcoieni```
2025-04-09 14:52:39 +02:00
Matthias Krüger
db7e32c074
Rollup merge of #139468 - compiler-errors:has_stashed_diagnostic, r=oli-obk
Don't call `Span::with_parent` on the good path in `has_stashed_diagnostic`

More unnecessary incurred span tracking avoided by not calling `span.with_parent(None)`. This is useless on its own but makes it much easier to fix other "span tracking on the good path" issues in the future.

r? oli-obk
2025-04-09 14:52:38 +02:00
Matthias Krüger
7494bd9a4f
Rollup merge of #139364 - Kohei316:feat/doc-hidden-suggestion, r=nnethercote
Make the compiler suggest actual paths instead of visible paths if the visible paths are through any doc hidden path.

close #127011
Currently, when emitting a diagnostic about a valid trait, the compiler suggestes using visible paths of the trait even if they are through a doc hidden path. This PR updates the compiler to suggest actual paths in these cases.
2025-04-09 14:52:37 +02:00
Matthias Krüger
4d1a63975c
Rollup merge of #139099 - scottmcm:from_fn_docs, r=Amanieu
Promise `array::from_fn` is generated in order of increasing indices

Fixes #139061

I agree this needs to be documented because of the `FnMut`, either with a guarantee or to explicitly disclaim one.

I'm pretty sure this will be non-controversial (like the other "well sure you *could* do it in a different order, but why?" things were), but I couldn't find any previous libs-api decision on it so it's seemingly a new promise that will need FCP.

Basically, yes, it would be plausible to fill in the reverse order, but there's no obvious way we could ever know that that might even be a good idea, so forward seems like an easy thing to promise.  We could always add a `from_fn_rev` or something later if there's ever a strong enough need, but it seems unlikely.

Let's just do the obvious thing so it matches what `[gen(0), gen(1), …, gen(N-1)]` does.
2025-04-09 14:52:37 +02:00
Matthias Krüger
19d4d9f371
Rollup merge of #138993 - CAD97:cfg_match_semitransparent, r=dtolnay
Make `cfg_match!` a semitransparent macro

IIUC this is preferred when (potentially) stabilizing `macro` items, to avoid potentially utilizing def-site hygiene instead of mixed-site.

Tracking issue: #115585
2025-04-09 14:52:36 +02:00
Matthias Krüger
9e541c4673
Rollup merge of #138869 - ChrisDenton:command-curdir, r=tgross35
Try not to use verbatim paths in `Command::current_dir`

If possible, we should try not to use verbatim paths in `Command::current_dir`. It might work but it might also break code in the subprocess that assume the current directory isn't verbatim (including Windows APIs). cc ``@ehuss``

Side note: we now have a lot of ad-hoc fixes like this spread about the place. It'd be good to make a proper `WindowsPath` type that handles all this in one place. But that's a bigger job for another PR.
2025-04-09 14:52:36 +02:00
xizheyin
32c8f7dbcf
librustdoc: remove IndexItem::new, use previous fields constructor
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-04-09 20:51:52 +08:00
Oli Scherer
f20efc4c61 Handle UnsafePointer coercions in one place 2025-04-09 12:45:54 +00:00
León Orell Valerian Liehr
cf68565313
Temporarily leave the review rotation 2025-04-09 13:48:39 +02:00
Boxy
5a5bda52f0 Update boostrap 2025-04-09 12:33:09 +01:00
Boxy
acf678bd4c intra-doc link 2025-04-09 12:29:59 +01:00
Boxy
c274459b63 clippy lints 2025-04-09 12:29:59 +01:00
Boxy
2b684f39e4 update missing targets list 2025-04-09 12:29:59 +01:00
Boxy
c93005ee65 update cfgs 2025-04-09 12:29:59 +01:00
Boxy
609eacbb22 bump stage0 2025-04-09 12:29:59 +01:00
Boxy
a6c2ec04b4 replace version placeholder 2025-04-09 12:29:59 +01:00
timesince
069fd02588
Remove redundant words 2025-04-09 18:46:50 +08:00
David Wood
72d17bfebb
re-use sized fast path
There's an existing fast path for the `type_op_prove_predicate`
predicate, checking for trivially `Sized` types, which can be re-used
when evaluating obligations within queries. This should improve
performance, particularly in anticipation of new sizedness traits being
added which can take advantage of this.
2025-04-09 10:42:26 +00:00
lincot
ff248de852
Add missing black_box in String benchmarks 2025-04-09 13:06:10 +03:00
lincot
09d5bcf1ad
Speed up String::push and String::insert
Improve performance of `String` methods by avoiding unnecessary memcpy
for the character bytes, with added codegen check to ensure compliance.
2025-04-09 13:06:10 +03:00
bors
f06e5c1e35 Auto merge of #139327 - cjgillot:gvn-place, r=oli-obk
Allow GVN to produce places and not just locals.

That may be too big of a hammer, as we may introduce new deref projections (possible UB footgun + probably not good for perf).

The second commit opts out of introducing projections that don't have a stable offset, which is probably what we want. Hence no new Deref and no new Index projections.

Fixes https://github.com/rust-lang/rust/issues/138936
cc `@scottmcm` `@dianqk`
2025-04-09 08:50:33 +00:00
Oli Scherer
b2aa9d0620 Remove some dead or leftover code related to rustc-intrinsic abi removal 2025-04-09 07:57:13 +00:00
Romain Perier
8b6ff4a378 Suggest the use of impl Trait in function parameter only
Currently in case of a Trait object in closure parameter, the compiler
suggests either to use a reference, which is correct or to use an
`impl Trait` which is not. Do not emit this suggestion when the parameter
is part of a closure.
2025-04-09 08:56:04 +02:00
Vadim Petrochenkov
12829122bf Migrate some tests to dont-require-annotations 2025-04-09 09:51:50 +03:00
Vadim Petrochenkov
cffc5c21fc compiletest: Add directive dont-require-annotations
for making matching on specific diagnostic kinds non-exhaustive
2025-04-09 09:51:39 +03:00
Ralf Jung
f0fb21e93c update lockfile 2025-04-09 08:25:40 +02:00
Ralf Jung
6c619bb9ee
Merge pull request #4067 from CraftSpider/windows-metadata
Support getting file metadata on Windows
2025-04-09 06:17:18 +00:00
bors
97c966bb40 Auto merge of #139552 - matthiaskrgr:rollup-b194mk8, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #139494 (Restrict some queries by def-kind more)
 - #139496 (Revert r-a changes of rust-lang/rust#139455)
 - #139506 (add missing word in doc comment (part 2))
 - #139515 (Improve presentation of closure signature mismatch from `Fn` trait goal)
 - #139520 (compiletest maintenance: sort deps and drop dep on `anyhow`)
 - #139523 (Rustc dev guide subtree update)
 - #139526 (Fix deprecation note for std::intrinsics)
 - #139528 (compiletest: Remove the `--logfile` flag)
 - #139541 (Instantiate higher-ranked transmute goal w/ placeholders before emitting sub-obligations)
 - #139547 (Update library tracking issue template to set S-tracking-unimplemented)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-09 05:39:18 +00:00
Nicholas Nethercote
7ae5c7f32d Avoid an empty trait name in impl blocks.
`resolve_ident_in_lexical_scope` checks for an empty name. Why is this
necessary? Because `parse_item_impl` can produce an `impl` block with an
empty trait name in some cases. This is pretty gross and very
non-obvious.

This commit avoids the use of the empty trait name. In one case the
trait name is instead pulled from `TyKind::ImplTrait`, which prevents
the output for `tests/ui/impl-trait/extra-impl-in-trait-impl.rs` from
changing. In the other case we just fail the parse and don't try to
recover. I think losing error recovery in this obscure case is worth
the code cleanup.

This change affects `tests/ui/parser/impl-parsing.rs`, which is split in
two, and the obsolete `..` syntax cases are removed (they are tested
elsewhere).
2025-04-09 15:01:14 +10:00
Nicholas Nethercote
f419b18d16 Return early on an error path in parse_item_impl.
Currently the code continues, using an empty path, but it doesn't need
to.
2025-04-09 15:00:30 +10:00
Rune Tynan
209ce59195 Implement trivial file operations - opening and closing handles. Just enough to get file metadata. 2025-04-08 21:11:58 -07:00