You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New "type annotations needed" error in Rust nightly-2025-06-24 #143164
Starting in Rust nightly-2025-06-24, I'm seeing a new "type annotations needed" error, in tests/path/arg.rs in rustix. The code below is a reduced standalone testcase.
I tried this code:
use std::ffi::CStr;use std::borrow::{Borrow,Cow};fnred() -> &'staticCStr{todo!()}fngreen() -> Cow<'static,CStr>{todo!()}fnmain(){assert!(red() == Borrow::borrow(&green()))}
I expected to see this happen: The code compiles.
Instead, this happened: Starting with Rust nightly-2025-06-24, and still with nightly-2025-06-27, I get this error:
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
--> t.rs:12:22
|
12 | assert!(red() == Borrow::borrow(&green()))
| ^^^^^^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait
|
help: use a fully-qualified path to one of the available implementations
|
12 | assert!(red() == <OsString as Borrow>::borrow(&green()))
| ++++++++++++ +
12 | assert!(red() == <PathBuf as Borrow>::borrow(&green()))
| +++++++++++ +
12 | assert!(red() == <&T as Borrow>::borrow(&green()))
| ++++++ +
12 | assert!(red() == <&mut T as Borrow>::borrow(&green()))
| ++++++++++ +
and 13 other candidates
error[E0283]: type annotations needed
--> t.rs:12:22
|
12 | assert!(red() == Borrow::borrow(&green()))
| -- ^^^^^^^^^^^^^^ cannot infer type of the type parameter `Borrowed` declared on the trait `Borrow`
| |
| type must be known at this point
|
= note: multiple `impl`s satisfying `CStr: PartialEq<_>` found in the following crates: `alloc`, `core`:
- impl PartialEq for CStr;
- impl PartialEq<&CStr> for CStr;
- impl PartialEq<CString> for CStr;
- impl PartialEq<Cow<'_, CStr>> for CStr;
= note: required for `&CStr` to implement `PartialEq<&_>`
help: consider specifying the generic argument
|
12 | assert!(red() == Borrow::<Borrowed>::borrow(&green()))
| ++++++++++++
Some errors have detailed explanations: E0283, E0790.
For more information about an error, try `rustc --explain E0283`.
error: could not compile `rustix` (example "t") due to 2 previous errors
changed the title [-]New "type annotations needed" erorr in Rust nightly-2025-06-24[/-][+]New "type annotations needed" error in Rust nightly-2025-06-24[/+]on Jun 29, 2025
The crater results show only 1 regression in the tests of yash-builtin. Considering that this and rustix's tests are the only regressions that have been discovered, @rust-lang/libs considers this acceptable breakage due to type/trait inference as per our stability policy. As such, we don't plan on reverting this.
Activity
Pin CI to Rust nightly-2025-06-23.
Pin CI to Rust nightly-2025-06-23. (#1486)
workingjubilee commentedon Jun 28, 2025
Regression arises from #137268
I notice in that crater run there were an unusually high number of
error -> errorcases for a crater...[-]New "type annotations needed" erorr in Rust nightly-2025-06-24[/-][+]New "type annotations needed" error in Rust nightly-2025-06-24[/+]lqd commentedon Jun 29, 2025
Crater has regularly (or always) been showing 160K errors / failures to prepare for at least 6 months, unfortunately.
workingjubilee commentedon Jun 29, 2025
we've had 15k within the last 6 months, I swear.
6 remaining items
craterbot commentedon Jul 30, 2025
the8472 commentedon Jul 30, 2025
@craterbot run start=master#36b21637e93b038453924d3c66821089e71d8baa end=master#3129d37ef7075ee3cbaa3d6cbe1b5794f67192b0 mode=check-only
craterbot commentedon Jul 30, 2025
👌 Experiment
pr-143164created and queued.🔍 You can check out the queue and this experiment's details.
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more
craterbot commentedon Jul 31, 2025
🚧 Experiment
pr-143164is now runningℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more
craterbot commentedon Aug 1, 2025
🎉 Experiment
pr-143164is completed!📊 26 regressed and 7 fixed (674135 total)
📰 Open the summary report.
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more
Amanieu commentedon Aug 13, 2025
The crater results show only 1 regression in the tests of
yash-builtin. Considering that this and rustix's tests are the only regressions that have been discovered, @rust-lang/libs considers this acceptable breakage due to type/trait inference as per our stability policy. As such, we don't plan on reverting this.Tests: Work around type inference error
Tests: Work around type inference error
Tests: Work around type inference error