@@ -1200,11 +1200,12 @@ impl LangString {
1200
1200
data. ignore = Ignore :: All ;
1201
1201
seen_rust_tags = !seen_other_tags;
1202
1202
}
1203
- LangStringToken :: LangToken ( x) if x. starts_with ( "ignore-" ) => {
1204
- if enable_per_target_ignores {
1205
- ignores. push ( x. trim_start_matches ( "ignore-" ) . to_owned ( ) ) ;
1206
- seen_rust_tags = !seen_other_tags;
1207
- }
1203
+ LangStringToken :: LangToken ( x)
1204
+ if let Some ( ignore) = x. strip_prefix ( "ignore-" )
1205
+ && enable_per_target_ignores =>
1206
+ {
1207
+ ignores. push ( ignore. to_owned ( ) ) ;
1208
+ seen_rust_tags = !seen_other_tags;
1208
1209
}
1209
1210
LangStringToken :: LangToken ( "rust" ) => {
1210
1211
data. rust = true ;
@@ -1226,37 +1227,39 @@ impl LangString {
1226
1227
data. standalone_crate = true ;
1227
1228
seen_rust_tags = !seen_other_tags || seen_rust_tags;
1228
1229
}
1229
- LangStringToken :: LangToken ( x) if x. starts_with ( "edition" ) => {
1230
- data. edition = x[ 7 ..] . parse :: < Edition > ( ) . ok ( ) ;
1230
+ LangStringToken :: LangToken ( x)
1231
+ if let Some ( edition) = x. strip_prefix ( "edition" ) =>
1232
+ {
1233
+ data. edition = edition. parse :: < Edition > ( ) . ok ( ) ;
1231
1234
}
1232
1235
LangStringToken :: LangToken ( x)
1233
- if x. starts_with ( "rust" ) && x[ 4 ..] . parse :: < Edition > ( ) . is_ok ( ) =>
1236
+ if let Some ( edition) = x. strip_prefix ( "rust" )
1237
+ && edition. parse :: < Edition > ( ) . is_ok ( )
1238
+ && let Some ( extra) = extra =>
1234
1239
{
1235
- if let Some ( extra) = extra {
1236
- extra. error_invalid_codeblock_attr_with_help (
1237
- format ! ( "unknown attribute `{x}`" ) ,
1238
- |lint| {
1239
- lint. help ( format ! (
1240
- "there is an attribute with a similar name: `edition{}`" ,
1241
- & x[ 4 ..] ,
1242
- ) ) ;
1243
- } ,
1244
- ) ;
1245
- }
1240
+ extra. error_invalid_codeblock_attr_with_help (
1241
+ format ! ( "unknown attribute `{x}`" ) ,
1242
+ |lint| {
1243
+ lint. help ( format ! (
1244
+ "there is an attribute with a similar name: `edition{edition}`"
1245
+ ) ) ;
1246
+ } ,
1247
+ ) ;
1246
1248
}
1247
1249
LangStringToken :: LangToken ( x)
1248
- if allow_error_code_check && x. starts_with ( 'E' ) && x. len ( ) == 5 =>
1250
+ if allow_error_code_check
1251
+ && let Some ( error_code) = x. strip_prefix ( 'E' )
1252
+ && error_code. len ( ) == 4 =>
1249
1253
{
1250
- if x [ 1 .. ] . parse :: < u32 > ( ) . is_ok ( ) {
1254
+ if error_code . parse :: < u32 > ( ) . is_ok ( ) {
1251
1255
data. error_codes . push ( x. to_owned ( ) ) ;
1252
1256
seen_rust_tags = !seen_other_tags || seen_rust_tags;
1253
1257
} else {
1254
1258
seen_other_tags = true ;
1255
1259
}
1256
1260
}
1257
- LangStringToken :: LangToken ( x) if extra. is_some ( ) => {
1258
- let s = x. to_lowercase ( ) ;
1259
- if let Some ( help) = match s. as_str ( ) {
1261
+ LangStringToken :: LangToken ( x) if let Some ( extra) = extra => {
1262
+ if let Some ( help) = match x. to_lowercase ( ) . as_str ( ) {
1260
1263
"compile-fail" | "compile_fail" | "compilefail" => Some (
1261
1264
"use `compile_fail` to invert the results of this test, so that it \
1262
1265
passes if it cannot be compiled and fails if it can",
@@ -1273,33 +1276,27 @@ impl LangString {
1273
1276
"use `test_harness` to run functions marked `#[test]` instead of a \
1274
1277
potentially-implicit `main` function",
1275
1278
) ,
1276
- "standalone" | "standalone_crate" | "standalone-crate" => {
1277
- if let Some ( extra) = extra
1278
- && extra. sp . at_least_rust_2024 ( )
1279
- {
1280
- Some (
1281
- "use `standalone_crate` to compile this code block \
1279
+ "standalone" | "standalone_crate" | "standalone-crate"
1280
+ if extra. sp . at_least_rust_2024 ( ) =>
1281
+ {
1282
+ Some (
1283
+ "use `standalone_crate` to compile this code block \
1282
1284
separately",
1283
- )
1284
- } else {
1285
- None
1286
- }
1285
+ )
1287
1286
}
1288
1287
_ => None ,
1289
1288
} {
1290
- if let Some ( extra) = extra {
1291
- extra. error_invalid_codeblock_attr_with_help (
1292
- format ! ( "unknown attribute `{x}`" ) ,
1293
- |lint| {
1294
- lint. help ( help) . help (
1295
- "this code block may be skipped during testing, \
1289
+ extra. error_invalid_codeblock_attr_with_help (
1290
+ format ! ( "unknown attribute `{x}`" ) ,
1291
+ |lint| {
1292
+ lint. help ( help) . help (
1293
+ "this code block may be skipped during testing, \
1296
1294
because unknown attributes are treated as markers for \
1297
1295
code samples written in other programming languages, \
1298
1296
unless it is also explicitly marked as `rust`",
1299
- ) ;
1300
- } ,
1301
- ) ;
1302
- }
1297
+ ) ;
1298
+ } ,
1299
+ ) ;
1303
1300
}
1304
1301
seen_other_tags = true ;
1305
1302
data. unknown . push ( x. to_owned ( ) ) ;
0 commit comments