about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2024-12-15simplify `emit_access_facts` and fact generationRémy Rakic-58/+21
- integrate it within existing fact generation instead of being called in typeck - simplify access fact extraction - also remove single use fact emit functions in root fact generation
2024-12-15use let else more consistently in fact generationRémy Rakic-49/+43
also remove a useless trace
2024-12-15clean up `translate_outlives_facts`Rémy Rakic-37/+48
- remove dependency on `TypeChecker` - move to legacy fact generation module - group facts emitted during typeck together
2024-12-15clean up `emit_drop_facts`Rémy Rakic-29/+32
- remove dependency on `TypeChecker` - move to legacy fact generation module - remove polonius module from liveness
2024-12-15clean up `emit_access_facts`Rémy Rakic-104/+120
- remove dependency on `TypeChecker` - move to legacy fact generation module
2024-12-15Auto merge of #134332 - Zalathar:rollup-oe23hkw, r=Zalatharbors-471/+1030
Rollup of 7 pull requests Successful merges: - #130361 (std::net: Solaris supports `SOCK_CLOEXEC` as well since 11.4.) - #133406 (Add value accessor methods to `Mutex` and `RwLock`) - #133633 (don't show the full linker args unless `--verbose` is passed) - #134285 (Add some convenience helper methods on `hir::Safety`) - #134310 (Add clarity to the examples of some `Vec` & `VecDeque` methods) - #134313 (Don't make a def id for `impl_trait_in_bindings`) - #134315 (A couple of polonius fact generation cleanups) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-15Rollup merge of #134315 - lqd:polonius-next-episode-1, r=jackh726Stuart Cook-265/+253
A couple of polonius fact generation cleanups This PR is extracted from #134268 for easier review and contains its first two commits. They have already been reviewed by `@jackh726.` r? `@jackh726`
2024-12-15Rollup merge of #134313 - compiler-errors:no-itib-def-id, r=oli-obkStuart Cook-0/+20
Don't make a def id for `impl_trait_in_bindings` The def collector is awkward, so for now just wrap let statements in a new `ImplTraitContext::InBinding` which tells `visit_ty` not to make a def id for the type. This will not generalize to other ITIB cases, like if we allow them in turbofishes (e.g. `foo::<impl Fn()>(|| {})`). Fixes #134307 r? oli-obk
2024-12-15Rollup merge of #134310 - tkr-sh:master, r=NoratriebStuart Cook-36/+39
Add clarity to the examples of some `Vec` & `VecDeque` methods In some `Vec` and `VecDeque` examples where elements are `i32`, examples can seem a bit confusing at first glance if a parameter of the method is an `usize`. In this case, I think it's better to use `char` rather than `i32`. > [!NOTE] > It's already done in the implementation of `VecDeque::insert` #### Difference - `i32` ```rs let mut v = vec![1, 2, 3]; assert_eq!(v.remove(1), 2); assert_eq!(v, [1, 3]); ``` - `char` ```rs let mut v = vec!['a', 'b', 'c']; assert_eq!(v.remove(1), 'b'); assert_eq!(v, ['a', 'c']); ``` Even tho it's pretty minor, it's a nice to have.
2024-12-15Rollup merge of #134285 - oli-obk:push-vwrqsqlwnuxo, r=UrgauStuart Cook-70/+74
Add some convenience helper methods on `hir::Safety` Makes a lot of call sites simpler and should make any refactorings needed for https://github.com/rust-lang/rust/pull/134090#issuecomment-2541332415 simpler, as fewer sites have to be touched in case we end up storing some information in the variants of `hir::Safety`
2024-12-15Rollup merge of #133633 - jyn514:hide-linker-args, r=bjorn3,jyn514Stuart Cook-14/+126
don't show the full linker args unless `--verbose` is passed the linker arguments can be *very* long, especially for crates with many dependencies. often they are not useful. omit them unless the user specifically requests them. split out from https://github.com/rust-lang/rust/pull/119286. fixes https://github.com/rust-lang/rust/issues/109979. r? `@bjorn3` try-build: i686-mingw
2024-12-15Rollup merge of #133406 - EFanZh:lock-value-accessors, r=NoratriebStuart Cook-86/+517
Add value accessor methods to `Mutex` and `RwLock` - ACP: https://github.com/rust-lang/libs-team/issues/485. - Tracking issue: https://github.com/rust-lang/rust/issues/133407. This PR adds `get`, `set` and `replace` methods to the `Mutex` and `RwLock` types for quick access to their contained values. One possible optimization would be to check for poisoning first and return an error immediately, without attempting to acquire the lock. I didn’t implement this because I consider poisoning to be relatively rare, adding this extra check could slow down common use cases.
2024-12-15Rollup merge of #130361 - devnexen:sock_cloexec_solaris, r=cuviperStuart Cook-0/+1
std::net: Solaris supports `SOCK_CLOEXEC` as well since 11.4. try-job: dist-various-2
2024-12-15Auto merge of #133223 - zachs18:uniquerc-impls, r=Noratriebbors-4/+282
`UniqueRc` trait impls UniqueRc tracking Issue: #112566 Stable traits: (i.e. impls behind only the `unique_rc_arc` feature gate) * Support the same formatting as `Rc`: * `fmt::Debug` and `fmt::Display` delegate to the pointee. * `fmt::Pointer` prints the address of the pointee. * Add explicit `!Send` and `!Sync` impls, to mirror `Rc`. * Borrowing traits: `Borrow`, `BorrowMut`, `AsRef`, `AsMut` * `Rc` does not implement `BorrowMut` and `AsMut`, but `UniqueRc` can. * Unconditional `Unpin`, like other heap-allocated types. * Comparison traits `(Partial)Ord` and `(Partial)Eq` delegate to the pointees. * `PartialEq for UniqueRc` does not do `Rc`'s specialization shortcut for pointer equality when `T: Eq`, since by definition two `UniqueRc`s cannot share an allocation. * `Hash` delegates to the pointee. * `AsRawFd`, `AsFd`, `AsHandle`, `AsSocket` delegate to the pointee like `Rc`. * Sidenote: The bounds on `T` for the existing `Pointer<T>` impls for specifically `AsRawFd` and `AsSocket` do not allow `T: ?Sized`. For the added `UniqueRc` impls I allowed `T: ?Sized` for all four traits, but I did not change the existing (stable) impls. Unstable traits: * `DispatchFromDyn`, allows using `UniqueRc<Self>` as a method receiver under `feature(arbitrary_self_types)`. * Existing `PinCoerceUnsized for UniqueRc` is generalized to allow non-`Global` allocators, like `Rc`. * `DerefPure`, allows using `UniqueRc` in deref-patterns under `feature(deref_patterns)`, like `Rc`. For documentation, `Rc` only has documentation on the comparison traits' methods, so I copied/adapted the documentation for those, and left the rest without impl-specific docs. ~~Edit: Marked as draft while I figure out `UnwindSafe`.~~ Edit: Ignoring `UnwindSafe` for this PR
2024-12-15Auto merge of #134258 - bjorn3:no_public_specialization, r=petrochenkovbors-180/+58
Remove support for specializing ToString outside the standard library This is the only trait specializable outside of the standard library. Before stabilizing specialization we will probably want to remove support for this. It was originally made specializable to allow a more efficient ToString in libproc_macro back when this way the only way to get any data out of a TokenStream. We now support getting individual tokens, so proc macros no longer need to call it as often.
2024-12-14don't show the full linker args unless `--verbose` is passedjyn-14/+126
the linker arguments can be *very* long, especially for crates with many dependencies. some parts of them are not very useful. unless specifically requested: - omit object files specific to the current invocation - fold rlib files into a single braced argument (in shell expansion format) this shortens the output significantly without removing too much information.
2024-12-15Auto merge of #134318 - matthiaskrgr:rollup-jda0jkx, r=matthiaskrgrbors-329/+1152
Rollup of 7 pull requests Successful merges: - #132939 (Suggest using deref in patterns) - #133293 (Updates Solaris target information, adds Solaris maintainer) - #133392 (Fix ICE when multiple supertrait substitutions need assoc but only one is provided) - #133986 (Add documentation for anonymous pipe module) - #134022 (Doc: Extend for tuples to be stabilized in 1.85.0) - #134259 (Clean up `infer_return_ty_for_fn_sig`) - #134264 (Arbitrary self types v2: Weak & NonNull diagnostics) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-14Rollup merge of #134264 - adetaylor:weak-and-nonnull, r=compiler-errorsMatthias Krüger-1/+101
Arbitrary self types v2: Weak & NonNull diagnostics This builds on top of #134262 which is more urgent to review and merge first. I'll likely rebase this PR once that lands. This is the first part of the diagnostic enhancements planned for Arbitrary Self Types v2. Various types can be used as method receivers, such as `Rc<>`, `Box<>` and `Arc<>`. The arbitrary self types v2 work allows further types to be made method receivers by implementing the Receiver trait. With that in mind, it may come as a surprise to people when certain common types do not implement Receiver and thus cannot be used as a method receiver. The RFC for arbitrary self types v2 therefore proposes emitting specific lint hints for these cases: * `NonNull` * `Weak` * Raw pointers The code already emits a hint for this third case, in that it advises folks that the `arbitrary_self_types_pointers` feature may meet their need. This PR adds diagnostic hints for the `Weak` and `NonNull` cases. Tracking issue #44874 r? `@wesleywiser`
2024-12-14Rollup merge of #134259 - compiler-errors:infer-ret-ty, r=dtolnayMatthias Krüger-85/+94
Clean up `infer_return_ty_for_fn_sig` The code for lowering fn signatures from HIR currently is structured to prefer the recovery path (where users write `-> _`) over the good path. This PR pulls the recovery code out into a separate fn. Review w/o whitespace
2024-12-14Rollup merge of #134022 - shahn:doc_clarify_extend_for_tuple_version, r=tgross35Matthias Krüger-7/+56
Doc: Extend for tuples to be stabilized in 1.85.0 I assumed the RUSTC_CURRENT_VERSION would be replaced automatically, but it doesn't look like it on the nightly docs page. Sorry!
2024-12-14Rollup merge of #133986 - olishmollie:tracking-issue-127154-documentation, ↵Matthias Krüger-5/+135
r=tgross35 Add documentation for anonymous pipe module Tracking issue: https://github.com/rust-lang/rust/issues/127154 `@NobodyXu` I've been using this feature lately and thought I might contribute with some documentation. I borrowed liberally from [os_pipe](https://docs.rs/os_pipe/latest/os_pipe/) so thanks to `@oconnor663.`
2024-12-14Rollup merge of #133392 - compiler-errors:object-sup, r=lcnrMatthias Krüger-163/+184
Fix ICE when multiple supertrait substitutions need assoc but only one is provided Dyn traits must have all of their associated types constrained either by: 1. writing them in the dyn trait itself as an associated type bound, like `dyn Iterator<Item = u32>`, 2. A supertrait bound, like `trait ConstrainedIterator: Iterator<Item = u32> {}`, then you may write `dyn ConstrainedIterator` which doesn't need to mention `Item`. However, the object type lowering code did not consider the fact that there may be multiple supertraits with different substitutions, so it just used the associated type's *def id* as a key for keeping track of which associated types are missing: https://github.com/rust-lang/rust/blob/1fc691e6ddc24506b5234d586a5c084eb767f1ad/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs#L131 This means that we can have missing associated types when there are mutliple supertraits with different substitutions and only one of them is constrained, like: ```rust trait Sup<T> { type Assoc: Default; } impl<T: Default> Sup<T> for () { type Assoc = T; } impl<T: Default, U: Default> Dyn<T, U> for () {} trait Dyn<A, B>: Sup<A, Assoc = A> + Sup<B> {} ``` The above example allows you to name `<dyn Dyn<i32, u32> as Sup<u32>>::Assoc` even though it is not possible to project since it's neither constrained by a manually written projection bound or a supertrait bound. This successfully type-checks, but leads to a codegen ICE since we are not able to project the associated type. This PR fixes the validation for checking that a dyn trait mentions all of its associated type bounds. This is theoretically a breaking change, since you could technically use that `dyn Dyn<A, B>` type mentionedin the example above without actually *projecting* to the bad associated type, but I don't expect it to ever be relevant to a user since it's almost certainly a bug. This is corroborated with the crater results[^crater], which show no failures[^unknown]. Crater: https://github.com/rust-lang/rust/pull/133392#issuecomment-2508769703 Fixes #133388 [^crater]: I cratered this originally with #133397, which is a PR that is stacked on top, then re-ran crater with just the failures from that PR. [^unknown]: If you look at the crater results, it shows all of the passes as "unknown". I believe this is a crater bug, since looking at the results manually shows them as passes.
2024-12-14Rollup merge of #133293 - psumbera:solaris-maintainer, ↵Matthias Krüger-4/+38
r=workingjubilee,jieyouxu,tgross35 Updates Solaris target information, adds Solaris maintainer
2024-12-14Rollup merge of #132939 - uellenberg:suggest-deref, r=oli-obkMatthias Krüger-64/+544
Suggest using deref in patterns Fixes #132784 This changes the following code: ```rs use std::sync::Arc; fn main() { let mut x = Arc::new(Some(1)); match x { Some(_) => {} None => {} } } ``` to output ```rs error[E0308]: mismatched types --> src/main.rs:5:9 | LL | match x { | - this expression has type `Arc<Option<{integer}>>` ... LL | Some(_) => {} | ^^^^^^^ expected `Arc<Option<{integer}>>`, found `Option<_>` | = note: expected struct `Arc<Option<{integer}>>` found enum `Option<_>` help: consider dereferencing to access the inner value using the Deref trait | LL | match *x { | ~~ ``` instead of ```rs error[E0308]: mismatched types --> src/main.rs:5:9 | 4 | match x { | - this expression has type `Arc<Option<{integer}>>` 5 | Some(_) => {} | ^^^^^^^ expected `Arc<Option<{integer}>>`, found `Option<_>` | = note: expected struct `Arc<Option<{integer}>>` found enum `Option<_>` ``` This makes it more obvious that a Deref is available, and gives a suggestion on how to use it in order to fix the issue at hand.
2024-12-14Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵bors-1663/+1451
r=davidtwco,RalfJung Bounds-check with PtrMetadata instead of Len in MIR Rather than emitting `Len(*_n)` in array index bounds checks, emit `PtrMetadata(copy _n)` instead -- with some asterisks for arrays and `&mut` that need it to be done slightly differently. We're getting pretty close to removing `Len` entirely, actually. I think just one more PR after this (for slice drop shims). r? mir
2024-12-14Correct spelling of CURRENT_RUSTC_VERSIONSebastian Hahn-7/+56
I mixed it up with RUSTC_CURRENT_VERSION unfortunately. Also improve the formatting of the macro invocation slightly.
2024-12-14Add some convenience helper methods on `hir::Safety`Oli Scherer-68/+72
2024-12-14Arbitrary self types v2: Weak, NonNull hintsAdrian Taylor-1/+101
Various types can be used as method receivers, such as Rc<>, Box<> and Arc<>. The arbitrary self types v2 work allows further types to be made method receivers by implementing the Receiver trait. With that in mind, it may come as a surprise to people when certain common types do not implement Receiver and thus cannot be used as a method receiver. The RFC for arbitrary self types v2 therefore proposes emitting specific lint hints for these cases: * NonNull * Weak * Raw pointers The code already emits a hint for this third case, in that it advises folks that the `arbitrary_self_types_pointers` feature may meet their need. This PR adds diagnostic hints for the Weak and NonNull cases.
2024-12-14Auto merge of #134305 - matthiaskrgr:rollup-bja3lsz, r=matthiaskrgrbors-72/+592
Rollup of 6 pull requests Successful merges: - #133221 (Add external macros specific diagnostics for check-cfg) - #133386 (Update linux_musl base to dynamically link the crt by default) - #134191 (Make some types and methods related to Polonius + Miri public) - #134227 (Update wasi-sdk used to build WASI targets) - #134279 ((Re-)return adjustment target if adjust kind is never-to-any) - #134295 (Encode coroutine-closures in SMIR) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-14Don't make a def id for impl_trait_in_bindingsMichael Goulet-0/+20
2024-12-14Stop handling specialization in clippy's to_string_trait_impl lintbjorn3-59/+1
ToString can no longer be specialized, so no need to account for it in to_string_trait_impl either.
2024-12-14refactor access fact generationRémy Rakic-80/+67
- use consistent names - inline single use functions - dedupe and simplify some paths - fix fact generation timer activity: it was missing the walk and extraction process
2024-12-14move datalog fact generation into a legacy moduleRémy Rakic-185/+186
2024-12-14Auto merge of #134278 - weihanglo:update-cargo, r=weihanglobors-0/+0
Update cargo 19 commits in 20a443231846b81c7b909691ec3f15eb173f2b18..769f622e12db0001431d8ae36d1093fb8727c5d9 2024-12-06 21:56:56 +0000 to 2024-12-14 04:27:35 +0000 - test(build-std): dont require rustup (rust-lang/cargo#14933) - fix(base): Support bases in patches in virtual manifests (rust-lang/cargo#14931) - fix(resolver): Report invalid index entries (rust-lang/cargo#14927) - feat: Implement `--depth workspace` for `cargo tree` command (rust-lang/cargo#14928) - fix(resolver): In errors, show rejected versions over alt versions (rust-lang/cargo#14923) - fix: emit_serialized_unit_graph uses the configured shell (rust-lang/cargo#14926) - fix(script): Don't override the release profile (rust-lang/cargo#14925) - feature(SourceId): use stable hash from rustc-stable-hash (rust-lang/cargo#14917) - fix(resolver): Don't report all versions as rejected (rust-lang/cargo#14921) - fix(resolver): Report unmatched versions, rather than saying no package (rust-lang/cargo#14897) - fix(build-rs): Implicitly report rerun-if-env-changed for input (rust-lang/cargo#14911) - a faster hash for ActivationsKey (rust-lang/cargo#14915) - feat(build-script): Pass CARGO_CFG_FEATURE (rust-lang/cargo#14902) - fix(build-rs): Correctly refer to the item in assert (rust-lang/cargo#14913) - chore: update auto-label to include build-rs crate (rust-lang/cargo#14912) - refactor: use Path::push to construct remap-path-prefix (rust-lang/cargo#14908) - feat(build-rs): Add the 'error' directive (rust-lang/cargo#14910) - fix(build-std): determine root crates by target spec `std:bool` (rust-lang/cargo#14899) - SemVer: Add section on RPIT capturing (rust-lang/cargo#14849)
2024-12-14Update cargoWeihang Lo-0/+0
2024-12-14Replace i32 by char in `split_at` & `_unchecked`tkirishima-12/+12
2024-12-14Add clarity to the "greater" of `VecDeque::insert`tkirishima-1/+1
2024-12-14Replace i32 by char to add claritytkirishima-23/+26
In some `Vec` and `VecDeque` examples where elements are i32, examples can seem a bit confusing at first glance if a parameter of the method is an usize.
2024-12-14Rollup merge of #134295 - compiler-errors:smir-async-closure, r=oli-obkMatthias Krüger-4/+137
Encode coroutine-closures in SMIR Fixes #134246 r? oli-obk
2024-12-14Rollup merge of #134279 - jieyouxu:return-adjustment-target, r=compiler-errorsMatthias Krüger-10/+58
(Re-)return adjustment target if adjust kind is never-to-any This PR fixes #134162 where we ICE'd on ```rs fn main() { struct X; let _ = [X] == [panic!(); 2]; } ``` In https://github.com/rust-lang/rust/pull/121208#discussion_r1494187622, there was a change ```diff - if let Some(adjustments) = self.typeck_results.borrow().adjustments().get(expr.hir_id) { - let reported = self.dcx().span_delayed_bug( - expr.span, - "expression with never type wound up being adjusted", - ); - return if let [Adjustment { kind: Adjust::NeverToAny, target }] = &adjustments[..] { - target.to_owned() - } else { - Ty::new_error(self.tcx(), reported) - }; - } + if let Some(_) = self.typeck_results.borrow().adjustments().get(expr.hir_id) { + self.dcx() + .span_bug(expr.span, "expression with never type wound up being adjusted"); + } ``` It turned out returning the adjustment target if the adjustment kind is `NeverToAny` is necessary, as otherwise we will go through a series of `delay_bug`s and eventually find that we constructed a `TyKind::Error` without having actually emitted an error. This PR addresses that by re-returning the adjustment target if the adjustment kind is `NeverToAny`, partially reverting this change from #121208. This PR has two commits: 1. The first commit adds a regression test for #134162, which will ICE (on stable 1.83.0, beta and nightly 2024-12-13). 2. The second commit is the partial revert, which will fix the ICE. cc `@nnethercote` FYI as this is related to #121208 changes. The changes from #121208 exposed that we lacked test coverage for the code pattern reported in #134162.
2024-12-14Rollup merge of #134227 - alexcrichton:update-wasi-sdk, r=lqdMatthias Krüger-4/+4
Update wasi-sdk used to build WASI targets Bump to the latest wasi-sdk-25 release which brings in various wasi-libc updates as well as LLVM 19 as the version used to compile wasi-libc. - https://github.com/WebAssembly/wasi-sdk/releases/tag/wasi-sdk-24 - https://github.com/WebAssembly/wasi-sdk/releases/tag/wasi-sdk-25
2024-12-14Rollup merge of #134191 - willcrichton:dev, r=RalfJung,lqdMatthias Krüger-18/+83
Make some types and methods related to Polonius + Miri public We have a tool, [Aquascope](https://github.com/cognitive-engineering-lab/aquascope/), which uses Polonius and Miri to visualize the compile-time and run-time semantics of a Rust program. Changes in the last few months to both APIs have hidden away details we depend upon. This PR re-exposes some of those details, specifically: **Polonius:** - `BorrowSet` and `BorrowData` are added to `rustc_borrowck::consumers`, and their fields are made `pub` instead of `pub(crate)`. We need this to interpret the `BorrowIndex`es generated by Polonius. - `BorrowSet::build` is now `pub`. We need this because the borrowck API doesn't provide access to the `BorrowSet` constructed during checking. - `PoloniusRegionVid` is added to `rustc_borrowck::consumers`. We need this because it's also contained in the Polonius facts. **Miri:** - `InterpCx::local_to_op` is now a special case of `local_at_frame_to_op`, which allows querying locals in any frame. We need this because we walk the whole stack at each step to collect the state of memory. - `InterpCx::layout_of_local` is now `pub`. We need this because we need to know the layout of every local at each step. If these changes go against some design goal for keeping certain types private, please let me know so we can hash out a better solution. Additionally, if there's a better way to document that it's important that certain types stay public, also let me know. For example, `BorrowSet` was previously public but was hidden in 6676cec, breaking our build. cc ```@RalfJung``` ```@nnethercote``` ```@gavinleroy```
2024-12-14Rollup merge of #133386 - wesleywiser:update_musl_base_crt_default, r=jieyouxuMatthias Krüger-7/+99
Update linux_musl base to dynamically link the crt by default However, don't change the behavior of any existing targets at this time. For targets that used the old default, explicitly set `crt_static_default = true`. This makes it easier for new targets to use the correct defaults while leaving the changing of individual targets to future PRs. Related to https://github.com/rust-lang/compiler-team/issues/422
2024-12-14Rollup merge of #133221 - Urgau:check-cfg-macro-diag, r=jieyouxuMatthias Krüger-29/+211
Add external macros specific diagnostics for check-cfg This PR adds specific check-cfg diagnostics for unexpected cfg in external macros. As well as hiding the some of the Cargo specific help/suggestions as they distraction for external macros and are generally not the right solution. Follow-up to #132577 `@rustbot` label +L-unexpected_cfgs r? compiler
2024-12-14Auto merge of #134296 - matthiaskrgr:rollup-o0sxozj, r=matthiaskrgrbors-249/+327
Rollup of 6 pull requests Successful merges: - #132150 (Fix powerpc64 big-endian FreeBSD ABI) - #133942 (Clarify how to use `black_box()`) - #134081 (Try to evaluate constants in legacy mangling) - #134192 (Remove `Lexer`'s dependency on `Parser`.) - #134208 (coverage: Tidy up creation of covmap and covfun records) - #134211 (On Neutrino QNX, reduce the need to set archiver via environment variables) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-14Auto merge of #134185 - compiler-errors:impl-trait-in-bindings, r=oli-obkbors-52/+442
(Re-)Implement `impl_trait_in_bindings` This reimplements the `impl_trait_in_bindings` feature for local bindings. "`impl Trait` in bindings" serve as a form of *trait* ascription, where the type basically functions as an infer var but additionally registering the `impl Trait`'s trait bounds for the infer type. These trait bounds can be used to enforce that predicates hold, and can guide inference (e.g. for closure signature inference): ```rust let _: impl Fn(&u8) -> &u8 = |x| x; ``` They are implemented as an additional set of bounds that are registered when the type is lowered during typeck, and then these bounds are tied to a given `CanonicalUserTypeAscription` for borrowck. We enforce these `CanonicalUserTypeAscription` bounds during borrowck to make sure that the `impl Trait` types are sensitive to lifetimes: ```rust trait Static: 'static {} impl<T> Static for T where T: 'static {} let local = 1; let x: impl Static = &local; //~^ ERROR `local` does not live long enough ``` r? oli-obk cc #63065 --- Why can't we just use TAIT inference or something? Well, TAITs in bodies have the problem that they cannot reference lifetimes local to a body. For example: ```rust type TAIT = impl Display; let local = 0; let x: TAIT = &local; //~^ ERROR `local` does not live long enough ``` That's because TAITs requires us to do *opaque type inference* which is pretty strict, since we need to remap all of the lifetimes of the hidden type to universal regions. This is simply not possible here. --- I consider this part of the "impl trait everywhere" experiment. I'm not certain if this needs yet another lang team experiment.
2024-12-14Return adjustment target if adjust kind is never-to-any许杰友 Jieyou Xu (Joe)-2/+7
Without doing so, we'll run into a series of delayed bugs then find that we have a `TyKind::Error` constructed yet fail to emit an error. This partially reverts a change in <https://github.com/rust-lang/rust/pull/121208> related to never type adjustments in expr typecheck errors.
2024-12-14Add a regression test for #134162许杰友 Jieyou Xu (Joe)-8/+51
2024-12-14Add documentation for anonymous pipe moduleAndrew Bond-5/+135
2024-12-14Auto merge of #134294 - matthiaskrgr:rollup-anh6io8, r=matthiaskrgrbors-54/+157
Rollup of 8 pull requests Successful merges: - #134252 (Fix `Path::is_absolute` on Hermit) - #134254 (Fix building `std` for Hermit after `c_char` change) - #134255 (Update includes in `/library/core/src/error.rs`.) - #134261 (Document the symbol Visibility enum) - #134262 (Arbitrary self types v2: adjust diagnostic.) - #134265 (Rename `ty_def_id` so people will stop using it by accident) - #134271 (Arbitrary self types v2: better feature gate test) - #134274 (Add check-pass test for `&raw`) r? `@ghost` `@rustbot` modify labels: rollup