This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed
librustc_infer/infer/error_reporting Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,8 @@ pub(super) fn note_and_explain_region(
9393 let unknown_scope =
9494 || format ! ( "{}unknown scope: {:?}{}. Please report a bug." , prefix, scope, suffix) ;
9595 let span = scope. span ( tcx, region_scope_tree) ;
96- let tag = match tcx. hir ( ) . find ( scope. hir_id ( region_scope_tree) ) {
96+ let hir_id = scope. hir_id ( region_scope_tree) ;
97+ let tag = match hir_id. and_then ( |hir_id| tcx. hir ( ) . find ( hir_id) ) {
9798 Some ( Node :: Block ( _) ) => "block" ,
9899 Some ( Node :: Expr ( expr) ) => match expr. kind {
99100 hir:: ExprKind :: Call ( ..) => "call" ,
Original file line number Diff line number Diff line change @@ -159,21 +159,20 @@ impl Scope {
159159 self . id
160160 }
161161
162- pub fn hir_id ( & self , scope_tree : & ScopeTree ) -> hir:: HirId {
163- match scope_tree. root_body {
164- Some ( hir_id) => hir:: HirId { owner : hir_id. owner , local_id : self . item_local_id ( ) } ,
165- None => hir:: DUMMY_HIR_ID ,
166- }
162+ pub fn hir_id ( & self , scope_tree : & ScopeTree ) -> Option < hir:: HirId > {
163+ scope_tree
164+ . root_body
165+ . map ( |hir_id| hir:: HirId { owner : hir_id. owner , local_id : self . item_local_id ( ) } )
167166 }
168167
169168 /// Returns the span of this `Scope`. Note that in general the
170169 /// returned span may not correspond to the span of any `NodeId` in
171170 /// the AST.
172171 pub fn span ( & self , tcx : TyCtxt < ' _ > , scope_tree : & ScopeTree ) -> Span {
173- let hir_id = self . hir_id ( scope_tree) ;
174- if hir_id == hir :: DUMMY_HIR_ID {
175- return DUMMY_SP ;
176- }
172+ let hir_id = match self . hir_id ( scope_tree) {
173+ Some ( hir_id) => hir_id ,
174+ None => return DUMMY_SP ,
175+ } ;
177176 let span = tcx. hir ( ) . span ( hir_id) ;
178177 if let ScopeData :: Remainder ( first_statement_index) = self . data {
179178 if let Node :: Block ( ref blk) = tcx. hir ( ) . get ( hir_id) {
You can’t perform that action at this time.
0 commit comments