In the standard library, the `Extend` impl for `Iterator` (specialised
with `TrustedLen`) has a parameter which is constrained by a projection
predicate. This projection predicate provides a value for an inference
variable but host effect evaluation wasn't resolving variables first.
Adding the extra resolve can the number of errors in some tests when they
gain host effect predicates, but this is not unexpected as calls to
`resolve_vars_if_possible` can cause more error tainting to happen.
Co-authored-by: Boxy <rust@boxyuwu.dev>
Update books
## rust-lang/book
2 commits in d4d2c18cbd20876b2130a546e790446a8444cb32..4a01a9182496f807aaa5f72d93a25ce18bcbe105
2025-02-24 14:48:34 UTC to 2025-02-13 19:29:47 UTC
- Fix typos in chapter 17 (rust-lang/book#4238)
- NoStarch backports (rust-lang/book#4224)
## rust-lang/edition-guide
2 commits in 8dbdda7cae4fa030f09f8f5b63994d4d1dde74b9..daa4b763cd848f986813b5cf8069e1649f7147af
2025-02-22 14:58:51 UTC to 2025-02-21 02:30:17 UTC
- Remove precise capturing features (rust-lang/edition-guide#362)
- use same name as previous example (rust-lang/edition-guide#360)
## rust-lang/nomicon
1 commits in 336f75835a6c0514852cc65aba9a698b699b13c8..8f5c7322b65d079aa5b242eb10d89a98e12471e1
2025-02-19 13:16:47 UTC to 2025-02-19 13:16:47 UTC
- other-reprs: do not make it sound like we are making ABI promises for repr(int) enums (rust-lang/nomicon#461)
## rust-lang/reference
4 commits in 6195dbd70fc6f0980c314b4d23875ac570d8253a..615b4cec60c269cfc105d511c93287620032d5b0
2025-02-18 23:01:53 UTC to 2025-02-13 15:12:49 UTC
- Add rule identifiers to names chapters (rust-lang/reference#1737)
- Switch from AVX to SSE in the example (rust-lang/reference#1735)
- Remove attributes from struct field rest patterns (rust-lang/reference#1736)
- Update reference for target_feature_11. (rust-lang/reference#1720)
Don't immediately panic if dropck fails without returning errors
This span_bug was a little too optimistic. I've decided that matching on the ErrorGuaranteed is a little more sensible than a delay bug that will always be ignored.
closes#137329
r? `@compiler-errors`
remove `#[rustc_intrinsic_must_be_overridde]`
In https://github.com/rust-lang/rust/pull/135031, we gained support for just leaving away the body. Now that the bootstrap compiler got bumped, stop using the old style and remove support for it.
r? `@oli-obk`
There are a few more mentions of this attribute in RA code that I didn't touch; Cc `@rust-lang/rust-analyzer`
Consolidate and improve error messaging for `CoerceUnsized` and `DispatchFromDyn`
Firstly, this PR consolidates and reworks the error diagnostics for `CoercePointee` and `DispatchFromDyn`. There was a ton of duplication for no reason -- this reworks both the errors and also the error codes, since they can be shared between both traits since they report the same thing.
Secondly, when encountering a struct with multiple fields that must be coerced, point out the field spans, rather than mentioning the fields by name. This makes the error message clearer, but also means that we don't mention the `__S` dummy parameter for `derive(CoercePointee)`.
Thirdly, emit a custom error message when we encounter a trait error that comes from the recursive field `CoerceUnsized`/`DispatchFromDyn` trait check. **Note:** This is the only one I'm not too satisfied with -- I think it could use some more refinement, but ideally it explains that the field must be an unsize-able pointer... Feedback welcome.
Finally, don't emit `DispatchFromDyn` validity errors if we detect `CoerceUnsized` validity errors from an impl of the same ADT.
This is best reviewed per commit.
r? `@oli-obk` perhaps?
cc `@dingxiangfei2009` -- sorry for making my own attempt at this PR, but I wanted to see if I could implement a fix for #136796 in a less complicated way, since communicating over github review comments can be a bit slow. I'll leave comments inline to explain my thinking about the diagnostics changes.
Remove `feature(dyn_compatible_for_dispatch)` from the compiler
This PR proposes the removal of `feature(dyn_compatible_for_dispatch)` from the compiler.
* As far as I can tell from the tracking issue, there's very little demand for this feature. I think that if this feature becomes useful in the future, then a fresh implementation from a fresh set of eyes, with renewed understanding of how this feature fits into the picture of Rust as it exists **today** would be great to have; however, in the absence of this demand, I don't see a particularly good reason to keep this implementation around.
* The RFC didn't receive very much discussion outside of the lang team, and while the discussion it received seemed to suggest that this feature was aiming to simplify the language and improve expressibility, I don't think this feature has really demonstrated either of those goals in practice. Furthermore, nobody seems to have owned this feature for quite some time or express desire to push for its stabilization.
* Relatedly, I find some of the RFC discussion like "when we make things impossible it's often presumptuous"[^1] and "I tend to want to take a 'we are all adults here' attitude toward unsafe code"[^2] to be particularly uncompelling. Of course this is no criticism to the authors of those comments since they're pretty old comments now, but type soundness is (IMO) the primary goal of the types team. This feature doesn't really do much other than further complicating the story of where we must validate object safety for soundness, along making dyn-incompatible trait object types *almost* seem useful, but very much remain UB to create and misleading to users who don't know better.
* Dyn compatibility's story has gotten more complicated since the feature was proposed in 2017, and now it needs to interact with things like associated consts, GATs, RPITITs, trait upcasting, `dyn*`, etc. While some of this is exercised in the codebase today, I'm not confident all of the corners of this feature have been hammered out. Reducing the "surface area" for what can go wrong in the compiler, especially around a side of the language (`dyn Trait`) that has been known to be particularly unsound in the past, seems good enough motivation to get rid of this for now.
[^1]: https://github.com/rust-lang/rfcs/pull/2027#issuecomment-307592857
[^2]: https://github.com/rust-lang/rfcs/pull/2027#issuecomment-307645838
cc `@rust-lang/types` `@rust-lang/lang`
Tracking:
- #43561
r? types
remove some unnecessary rustc_const_unstable
If the function is anyway unstable, it doesn't need to be `rustc_const_unstable`.
`copy_from_slice` turns out to not do anything const-unstable itself, we just haven't stably committed to it being available in const yet. See [here](https://rustc-dev-guide.rust-lang.org/stability.html?highlight=rustc_const_stable_indirect) for more details on the `rustc_const_stable_indirect` attribute.
configure.py: don't instruct user to run nonexistent program
```shell-session
$ ./configure
configure: processing command line
configure:
configure: build.configure-args := []
configure: profile := dist
configure:
configure: writing `config.toml` in current directory
configure:
configure: run `python /mnt/filling/store/nabijaczleweli/code/rust/x.py --help`
```
This is naturally not valid since I don't have a "python" executable (and this will hopefully become more and more true as Python 2 dies out).
./configure knows this since it does `try python3 "$``@"`,`` then `python2.7` &c.
After, this now says
```
configure: run `python3 /mnt/filling/store/nabijaczleweli/code/rust/x.py --help`
```
which is possible, and corresponds to the interpreter actually running.
Implement `read_buf` for zkVM stdin
For the zkVM, even when a guest buffer is uninitialized, from the host's perspective it is just a normal piece of memory which was initialized before letting the guest write into it. This makes `sys_read` safe to use with an uninitialized buffer. See https://github.com/risc0/risc0/issues/2853.
cc `@bobbobbio,` `@flaub`
r? `@Noratrieb`
Tracked in https://github.com/rust-lang/rust/issues/136756
Update `String::from_raw_parts` safety requirements
These have become out of sync with `Vec::from_raw_part`'s safety requirements, and are likely to diverge again. I think it's safest to just point at `Vec`'s requirements.
https://github.com/rust-lang/rust/issues/119206#issuecomment-2180116680
New attribute parsing infrastructure
Another step in the plan outlined in https://github.com/rust-lang/rust/issues/131229
introduces infrastructure for structured parsers for attributes, as well as converting a couple of complex attributes to have such structured parsers.
This PR may prove too large to review. I left some of my own comments to guide it a little. Some general notes:
- The first commit is basically standalone. It just preps some mostly unrelated sources for the rest of the PR to work. It might not have enormous merit on its own, but not negative merit either. Could be merged alone, but also doesn't make the review a whole lot easier. (but it's only +274 -209)
- The second commit is the one that introduces new infrastructure. It's the important one to review.
- The 3rd commit uses the new infrastructure showing how some of the more complex attributes can be parsed using it. Theoretically can be split up, though the parsers in this commit are the ones that really test the new infrastructure and show that it all works.
- The 4th commit fixes up rustdoc and clippy. In the previous 2 they didn't compile yet while the compiler does. Separated them out to separate concerns and make the rest more palatable.
- The 5th commit blesses some test outputs. Sometimes that's just because a diagnostic happens slightly earlier than before, which I'd say is acceptable. Sometimes a diagnostic is now only emitted once where it would've been twice before (yay! fixed some bugs). One test I actually moved from crashes to fixed, because it simply doesn't crash anymore. That's why this PR Closes#132391. I think most choices I made here are generally reasonable, but let me know if you disagree anywhere.
- The 6th commit adds a derive to pretty print attributes
- The 7th removes smir apis for attributes, for the time being. The api will at some point be replaced by one based on `rustc_ast_data_structures::AttributeKind`
In general, a lot of the additions here are comments. I've found it very important to document new things in the 2nd commit well so other people can start using it.
Closes#132391Closes#136717
Type lowering can give non-fatal errors that dropck then uses to suppress its own errors. Assume this is the cases when we can't find the error in borrowck.
Rollup of 10 pull requests
Successful merges:
- #136610 (Allow `IndexSlice` to be indexed by ranges.)
- #136991 ([rustdoc] Add new setting to wrap source code lines when too long)
- #137061 (Unstable `gen_future` Feature Tracking )
- #137393 (Stabilize `unbounded_shifts`)
- #137482 (Windows: use existing wrappers in `File::open_native`)
- #137484 (Fix documentation for unstable sort on slice)
- #137491 (Tighten `str-to-string-128690.rs``CHECK{,-NOT}`s to make it less likely to incorrectly fail with symbol name mangling)
- #137495 (Added into_value function to ControlFlow<T, T>)
- #137501 (Move `impl` blocks out of `rustc_middle/src/mir/syntax.rs`)
- #137505 (Add a span to `CompilerBuiltinsCannotCall`)
r? `@ghost`
`@rustbot` modify labels: rollup