File tree 3 files changed +52
-1
lines changed
3 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -239,3 +239,20 @@ fn main() {
239
239
_ => false,
240
240
};
241
241
}
242
+
243
+ // issue #8919, fixed on https://github.com/rust-lang/rust/pull/97312
244
+ mod with_lifetime {
245
+ enum MaybeStaticStr<'a> {
246
+ Static(&'static str),
247
+ Borrowed(&'a str),
248
+ }
249
+
250
+ impl<'a> MaybeStaticStr<'a> {
251
+ fn get(&self) -> &'a str {
252
+ match *self {
253
+ MaybeStaticStr::Borrowed(s) | MaybeStaticStr::Static(s) => s,
254
+ //~^ ERROR: this match arm has an identical body to another arm
255
+ }
256
+ }
257
+ }
258
+ }
Original file line number Diff line number Diff line change @@ -262,3 +262,21 @@ fn main() {
262
262
_ => false ,
263
263
} ;
264
264
}
265
+
266
+ // issue #8919, fixed on https://github.com/rust-lang/rust/pull/97312
267
+ mod with_lifetime {
268
+ enum MaybeStaticStr < ' a > {
269
+ Static ( & ' static str ) ,
270
+ Borrowed ( & ' a str ) ,
271
+ }
272
+
273
+ impl < ' a > MaybeStaticStr < ' a > {
274
+ fn get ( & self ) -> & ' a str {
275
+ match * self {
276
+ MaybeStaticStr :: Static ( s) => s,
277
+ MaybeStaticStr :: Borrowed ( s) => s,
278
+ //~^ ERROR: this match arm has an identical body to another arm
279
+ }
280
+ }
281
+ }
282
+ }
Original file line number Diff line number Diff line change @@ -221,5 +221,21 @@ help: and remove this obsolete arm
221
221
LL - 0 => cfg!(not_enable),
222
222
|
223
223
224
- error: aborting due to 13 previous errors
224
+ error: this match arm has an identical body to another arm
225
+ --> tests/ui/match_same_arms2.rs:277:17
226
+ |
227
+ LL | MaybeStaticStr::Borrowed(s) => s,
228
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
229
+ |
230
+ = help: try changing either arm body
231
+ help: or try merging the arm patterns
232
+ |
233
+ LL | MaybeStaticStr::Borrowed(s) | MaybeStaticStr::Static(s) => s,
234
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235
+ help: and remove this obsolete arm
236
+ |
237
+ LL - MaybeStaticStr::Static(s) => s,
238
+ |
239
+
240
+ error: aborting due to 14 previous errors
225
241
You can’t perform that action at this time.
0 commit comments