-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[rustc] ICE in stability_implications: DefId::expect_local called on non-local DefId from core when using reuse with Iterator::fold under staged_api #153599
Copy link
Copy link
Closed
Labels
A-stabilityArea: `#[stable]`, `#[unstable]` etc.Area: `#[stable]`, `#[unstable]` etc.C-bugCategory: This is a bug.Category: This is a bug.F-fn_delegation`#![feature(fn_delegation)]``#![feature(fn_delegation)]`F-staged_api`#![feature(staged_api)]``#![feature(staged_api)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.requires-internal-featuresThis issue requires the use of internal features.This issue requires the use of internal features.
Metadata
Metadata
Assignees
Labels
A-stabilityArea: `#[stable]`, `#[unstable]` etc.Area: `#[stable]`, `#[unstable]` etc.C-bugCategory: This is a bug.Category: This is a bug.F-fn_delegation`#![feature(fn_delegation)]``#![feature(fn_delegation)]`F-staged_api`#![feature(staged_api)]``#![feature(staged_api)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.requires-internal-featuresThis issue requires the use of internal features.This issue requires the use of internal features.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Description
rustcpanics withDefId::expect_local: ... isn't localwhen compiling a crate that uses#![feature(staged_api)]together with#![feature(fn_delegation)]and areusedelegation that includesIterator::fold. Thestability_implicationsquery walks the#[unstable]implications of delegated items and callsexpect_localonIterator::fold's generic type parameterB, which is a non-localDefIdfromcore, triggering an unconditional panic.Reproducer
Command
Expected behavior
The compiler either compiles successfully or emits a graceful diagnostic. It should not panic when computing stability implications for delegated items that reference non-local
DefIds from the standard library.Actual behavior
Root cause
The call chain is:
stability_implicationsiterates over#[unstable]feature implications in the current crate. Whenfn_delegation'sreuse Iterator::{next, fold}is processed, the compiler associates the delegatedfolditem withIterator::fold's generic type parameterB(aDefIdbelonging tocore, not the local crate).stability_implicationsthen callsexpect_localon thisDefIdwithout first checkingDefId::is_local, causing the unconditional panic. The fix should guard theexpect_localcall with anis_localcheck, or ensure thatfn_delegationdoes not register non-localDefIds as implications of local unstable features.Environment
rustc 1.95.0-nightlyx86_64-unknown-linux-gnu9b1f8ff42d110b0ca138116745be921df5dc97e7#![feature(fn_delegation, staged_api)]