File tree 2 files changed +10
-10
lines changed
librustc_infer/infer/error_reporting
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(
93
93
let unknown_scope =
94
94
|| format ! ( "{}unknown scope: {:?}{}. Please report a bug." , prefix, scope, suffix) ;
95
95
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) ) {
97
98
Some ( Node :: Block ( _) ) => "block" ,
98
99
Some ( Node :: Expr ( expr) ) => match expr. kind {
99
100
hir:: ExprKind :: Call ( ..) => "call" ,
Original file line number Diff line number Diff line change @@ -159,21 +159,20 @@ impl Scope {
159
159
self . id
160
160
}
161
161
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 ( ) } )
167
166
}
168
167
169
168
/// Returns the span of this `Scope`. Note that in general the
170
169
/// returned span may not correspond to the span of any `NodeId` in
171
170
/// the AST.
172
171
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
+ } ;
177
176
let span = tcx. hir ( ) . span ( hir_id) ;
178
177
if let ScopeData :: Remainder ( first_statement_index) = self . data {
179
178
if let Node :: Block ( ref blk) = tcx. hir ( ) . get ( hir_id) {
You can’t perform that action at this time.
0 commit comments