@@ -1200,11 +1200,12 @@ impl LangString {
12001200 data. ignore = Ignore :: All ;
12011201 seen_rust_tags = !seen_other_tags;
12021202 }
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;
12081209 }
12091210 LangStringToken :: LangToken ( "rust" ) => {
12101211 data. rust = true ;
@@ -1226,37 +1227,39 @@ impl LangString {
12261227 data. standalone_crate = true ;
12271228 seen_rust_tags = !seen_other_tags || seen_rust_tags;
12281229 }
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 ( ) ;
12311234 }
12321235 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 =>
12341239 {
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+ ) ;
12461248 }
12471249 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 =>
12491253 {
1250- if x [ 1 .. ] . parse :: < u32 > ( ) . is_ok ( ) {
1254+ if error_code . parse :: < u32 > ( ) . is_ok ( ) {
12511255 data. error_codes . push ( x. to_owned ( ) ) ;
12521256 seen_rust_tags = !seen_other_tags || seen_rust_tags;
12531257 } else {
12541258 seen_other_tags = true ;
12551259 }
12561260 }
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 ( ) {
12601263 "compile-fail" | "compile_fail" | "compilefail" => Some (
12611264 "use `compile_fail` to invert the results of this test, so that it \
12621265 passes if it cannot be compiled and fails if it can",
@@ -1273,33 +1276,27 @@ impl LangString {
12731276 "use `test_harness` to run functions marked `#[test]` instead of a \
12741277 potentially-implicit `main` function",
12751278 ) ,
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 \
12821284 separately",
1283- )
1284- } else {
1285- None
1286- }
1285+ )
12871286 }
12881287 _ => None ,
12891288 } {
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, \
12961294 because unknown attributes are treated as markers for \
12971295 code samples written in other programming languages, \
12981296 unless it is also explicitly marked as `rust`",
1299- ) ;
1300- } ,
1301- ) ;
1302- }
1297+ ) ;
1298+ } ,
1299+ ) ;
13031300 }
13041301 seen_other_tags = true ;
13051302 data. unknown . push ( x. to_owned ( ) ) ;
0 commit comments