@@ -75,83 +75,73 @@ pub(crate) enum RegionNameHighlight {
75
75
76
76
impl RegionName {
77
77
pub ( crate ) fn was_named ( & self ) -> bool {
78
+ use RegionNameSource :: * ;
78
79
match self . source {
79
- RegionNameSource :: NamedEarlyParamRegion ( ..)
80
- | RegionNameSource :: NamedLateParamRegion ( ..)
81
- | RegionNameSource :: Static => true ,
82
- RegionNameSource :: SynthesizedFreeEnvRegion ( ..)
83
- | RegionNameSource :: AnonRegionFromArgument ( ..)
84
- | RegionNameSource :: AnonRegionFromUpvar ( ..)
85
- | RegionNameSource :: AnonRegionFromOutput ( ..)
86
- | RegionNameSource :: AnonRegionFromYieldTy ( ..)
87
- | RegionNameSource :: AnonRegionFromAsyncFn ( ..)
88
- | RegionNameSource :: AnonRegionFromImplSignature ( ..) => false ,
80
+ NamedEarlyParamRegion ( ..) | NamedLateParamRegion ( ..) | Static => true ,
81
+ SynthesizedFreeEnvRegion ( ..)
82
+ | AnonRegionFromArgument ( ..)
83
+ | AnonRegionFromUpvar ( ..)
84
+ | AnonRegionFromOutput ( ..)
85
+ | AnonRegionFromYieldTy ( ..)
86
+ | AnonRegionFromAsyncFn ( ..)
87
+ | AnonRegionFromImplSignature ( ..) => false ,
89
88
}
90
89
}
91
90
92
91
pub ( crate ) fn span ( & self ) -> Option < Span > {
92
+ use RegionNameSource :: * ;
93
93
match self . source {
94
- RegionNameSource :: Static => None ,
95
- RegionNameSource :: NamedEarlyParamRegion ( span)
96
- | RegionNameSource :: NamedLateParamRegion ( span)
97
- | RegionNameSource :: SynthesizedFreeEnvRegion ( span, _)
98
- | RegionNameSource :: AnonRegionFromUpvar ( span, _)
99
- | RegionNameSource :: AnonRegionFromYieldTy ( span, _)
100
- | RegionNameSource :: AnonRegionFromAsyncFn ( span)
101
- | RegionNameSource :: AnonRegionFromImplSignature ( span, _) => Some ( span) ,
102
- RegionNameSource :: AnonRegionFromArgument ( ref highlight)
103
- | RegionNameSource :: AnonRegionFromOutput ( ref highlight, _) => match * highlight {
104
- RegionNameHighlight :: MatchedHirTy ( span)
105
- | RegionNameHighlight :: MatchedAdtAndSegment ( span)
106
- | RegionNameHighlight :: CannotMatchHirTy ( span, _)
107
- | RegionNameHighlight :: Occluded ( span, _) => Some ( span) ,
108
- } ,
94
+ Static => None ,
95
+ NamedEarlyParamRegion ( span)
96
+ | NamedLateParamRegion ( span)
97
+ | SynthesizedFreeEnvRegion ( span, _)
98
+ | AnonRegionFromUpvar ( span, _)
99
+ | AnonRegionFromYieldTy ( span, _)
100
+ | AnonRegionFromAsyncFn ( span)
101
+ | AnonRegionFromImplSignature ( span, _) => Some ( span) ,
102
+ AnonRegionFromArgument ( ref highlight) | AnonRegionFromOutput ( ref highlight, _) => {
103
+ match * highlight {
104
+ RegionNameHighlight :: MatchedHirTy ( span)
105
+ | RegionNameHighlight :: MatchedAdtAndSegment ( span)
106
+ | RegionNameHighlight :: CannotMatchHirTy ( span, _)
107
+ | RegionNameHighlight :: Occluded ( span, _) => Some ( span) ,
108
+ }
109
+ }
109
110
}
110
111
}
111
112
112
113
pub ( crate ) fn highlight_region_name ( & self , diag : & mut Diag < ' _ > ) {
114
+ use RegionNameSource :: * ;
113
115
match & self . source {
114
- RegionNameSource :: NamedLateParamRegion ( span)
115
- | RegionNameSource :: NamedEarlyParamRegion ( span) => {
116
+ NamedLateParamRegion ( span) | NamedEarlyParamRegion ( span) => {
116
117
diag. span_label ( * span, format ! ( "lifetime `{self}` defined here" ) ) ;
117
118
}
118
- RegionNameSource :: SynthesizedFreeEnvRegion ( span, note) => {
119
+ SynthesizedFreeEnvRegion ( span, note) => {
119
120
diag. span_label ( * span, format ! ( "lifetime `{self}` represents this closure's body" ) ) ;
120
121
diag. note ( * note) ;
121
122
}
122
- RegionNameSource :: AnonRegionFromArgument ( RegionNameHighlight :: CannotMatchHirTy (
123
- span,
124
- type_name,
125
- ) ) => {
123
+ AnonRegionFromArgument ( RegionNameHighlight :: CannotMatchHirTy ( span, type_name) ) => {
126
124
diag. span_label ( * span, format ! ( "has type `{type_name}`" ) ) ;
127
125
}
128
- RegionNameSource :: AnonRegionFromArgument ( RegionNameHighlight :: MatchedHirTy ( span) )
129
- | RegionNameSource :: AnonRegionFromOutput ( RegionNameHighlight :: MatchedHirTy ( span) , _)
130
- | RegionNameSource :: AnonRegionFromAsyncFn ( span) => {
126
+ AnonRegionFromArgument ( RegionNameHighlight :: MatchedHirTy ( span) )
127
+ | AnonRegionFromOutput ( RegionNameHighlight :: MatchedHirTy ( span) , _)
128
+ | AnonRegionFromAsyncFn ( span) => {
131
129
diag. span_label (
132
130
* span,
133
131
format ! ( "let's call the lifetime of this reference `{self}`" ) ,
134
132
) ;
135
133
}
136
- RegionNameSource :: AnonRegionFromArgument (
137
- RegionNameHighlight :: MatchedAdtAndSegment ( span) ,
138
- )
139
- | RegionNameSource :: AnonRegionFromOutput (
140
- RegionNameHighlight :: MatchedAdtAndSegment ( span) ,
141
- _,
142
- ) => {
134
+ AnonRegionFromArgument ( RegionNameHighlight :: MatchedAdtAndSegment ( span) )
135
+ | AnonRegionFromOutput ( RegionNameHighlight :: MatchedAdtAndSegment ( span) , _) => {
143
136
diag. span_label ( * span, format ! ( "let's call this `{self}`" ) ) ;
144
137
}
145
- RegionNameSource :: AnonRegionFromArgument ( RegionNameHighlight :: Occluded (
146
- span,
147
- type_name,
148
- ) ) => {
138
+ AnonRegionFromArgument ( RegionNameHighlight :: Occluded ( span, type_name) ) => {
149
139
diag. span_label (
150
140
* span,
151
141
format ! ( "lifetime `{self}` appears in the type {type_name}" ) ,
152
142
) ;
153
143
}
154
- RegionNameSource :: AnonRegionFromOutput (
144
+ AnonRegionFromOutput (
155
145
RegionNameHighlight :: Occluded ( span, type_name) ,
156
146
mir_description,
157
147
) => {
@@ -162,28 +152,28 @@ impl RegionName {
162
152
) ,
163
153
) ;
164
154
}
165
- RegionNameSource :: AnonRegionFromUpvar ( span, upvar_name) => {
155
+ AnonRegionFromUpvar ( span, upvar_name) => {
166
156
diag. span_label (
167
157
* span,
168
158
format ! ( "lifetime `{self}` appears in the type of `{upvar_name}`" ) ,
169
159
) ;
170
160
}
171
- RegionNameSource :: AnonRegionFromOutput (
161
+ AnonRegionFromOutput (
172
162
RegionNameHighlight :: CannotMatchHirTy ( span, type_name) ,
173
163
mir_description,
174
164
) => {
175
165
diag. span_label ( * span, format ! ( "return type{mir_description} is {type_name}" ) ) ;
176
166
}
177
- RegionNameSource :: AnonRegionFromYieldTy ( span, type_name) => {
167
+ AnonRegionFromYieldTy ( span, type_name) => {
178
168
diag. span_label ( * span, format ! ( "yield type is {type_name}" ) ) ;
179
169
}
180
- RegionNameSource :: AnonRegionFromImplSignature ( span, location) => {
170
+ AnonRegionFromImplSignature ( span, location) => {
181
171
diag. span_label (
182
172
* span,
183
173
format ! ( "lifetime `{self}` appears in the `impl`'s {location}" ) ,
184
174
) ;
185
175
}
186
- RegionNameSource :: Static => { }
176
+ Static => { }
187
177
}
188
178
}
189
179
}
0 commit comments