{"record":{"id":"6f4bb4a963c96149","repo":"rust-lang/rust","slug":"expected-session","errorCode":null,"errorMessage":"expected `Session`","messagePattern":"expected `Session`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_ast_lowering/src/lib.rs","lineNumber":1241,"sourceCode":"        target_hir_id: HirId,\n        target: Target,\n    ) -> Vec<hir::Attribute> {\n        let l = self.span_lowerer();\n        self.attribute_parser.parse_attribute_list(\n            attrs,\n            target_span,\n            target,\n            OmitDoc::Lower,\n            |s| l.lower(s),\n            |lint_id, span, kind| {\n                self.delayed_lints.push(DelayedLint {\n                    lint_id,\n                    id: target_hir_id,\n                    span,\n                    callback: Box::new(move |dcx, level, sess: &dyn std::any::Any| {\n                        let sess = sess\n                            .downcast_ref::<rustc_session::Session>()\n                            .expect(\"expected `Session`\");\n                        (kind.0)(dcx, level, sess)\n                    }),\n                });\n            },\n        )\n    }\n\n    fn alias_attrs(&mut self, id: HirId, target_id: HirId) {\n        assert_eq!(id.owner, self.current_hir_id_owner);\n        assert_eq!(target_id.owner, self.current_hir_id_owner);\n        if let Some(&a) = self.attrs.get(&target_id.local_id) {\n            assert!(!a.is_empty());\n            self.attrs.insert(id.local_id, a);\n        }\n    }\n\n    fn lower_delim_args(&self, args: &DelimArgs) -> DelimArgs {\n        args.clone()","sourceCodeStart":1223,"sourceCodeEnd":1259,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_ast_lowering/src/lib.rs#L1223-L1259","documentation":"lib.rs:1241: in a delayed-lint callback, the compiler downcasts a &dyn std::any::Any to rustc_session::Session via .expect(\"expected `Session`\"). The invariant: the opaque value stored in the DelayedLint is always the compiler Session. A panic here means a delayed lint was registered with a non-Session Any value, a compiler-internal contract violation.","triggerScenarios":"Internal compiler code that pushes a DelayedLint whose callback receives an Any that is not a Session; cannot be triggered by normal user source.","commonSituations":"A regression in the lint-delay mechanism during compiler development; not reachable from ordinary Rust programs.","solutions":["File a rustc ICE report; this is a compiler-internal contract violation.","Bisect the regression with cargo bisect-rustc.","Try stable vs nightly to see if it is a recent regression.","Reduce the triggering crate (often one that exercises rare lint paths) and attach it to the issue."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["This is an internal rustc contract violation, not user-reachable; file an ICE report.","Bisect with cargo bisect-rustc to locate the lint-delay regression.","Compare stable vs nightly to confirm it is a recent regression.","Reduce the triggering crate to the minimum that exercises the affected lint path."],"tags":["rust","compiler-internal","lint","ice"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}