X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ftools%2Frust-analyzer%2Fcrates%2Ftest-utils%2Fsrc%2Ffixture.rs;h=d1afd0039aa4b0b5d52f9cd65c496b2501dd1236;hb=06e705f13dade399d629dd422e3fc84bddc58db0;hp=c824f5af7258485bb8aa97460ab23fc0f216a647;hpb=8ba2a651fb16f5d0f54c961e0ae925c9bad2fafb;p=rust.git diff --git a/src/tools/rust-analyzer/crates/test-utils/src/fixture.rs b/src/tools/rust-analyzer/crates/test-utils/src/fixture.rs index c824f5af725..d1afd0039aa 100644 --- a/src/tools/rust-analyzer/crates/test-utils/src/fixture.rs +++ b/src/tools/rust-analyzer/crates/test-utils/src/fixture.rs @@ -78,6 +78,7 @@ pub struct Fixture { pub edition: Option, pub env: FxHashMap, pub introduce_new_source_root: Option, + pub target_data_layout: Option, } pub struct MiniCore { @@ -134,11 +135,9 @@ pub fn parse(ra_fixture: &str) -> (Option, Vec, Vec) if line.contains("//-") { assert!( line.starts_with("//-"), - "Metadata line {} has invalid indentation. \ + "Metadata line {ix} has invalid indentation. \ All metadata lines need to have the same indentation.\n\ - The offending line: {:?}", - ix, - line + The offending line: {line:?}" ); } @@ -152,7 +151,7 @@ pub fn parse(ra_fixture: &str) -> (Option, Vec, Vec) && !line.contains('.') && line.chars().all(|it| !it.is_uppercase()) { - panic!("looks like invalid metadata line: {:?}", line); + panic!("looks like invalid metadata line: {line:?}"); } if let Some(entry) = res.last_mut() { @@ -171,7 +170,7 @@ fn parse_meta_line(meta: &str) -> Fixture { let components = meta.split_ascii_whitespace().collect::>(); let path = components[0].to_string(); - assert!(path.starts_with('/'), "fixture path does not start with `/`: {:?}", path); + assert!(path.starts_with('/'), "fixture path does not start with `/`: {path:?}"); let mut krate = None; let mut deps = Vec::new(); @@ -181,10 +180,10 @@ fn parse_meta_line(meta: &str) -> Fixture { let mut cfg_key_values = Vec::new(); let mut env = FxHashMap::default(); let mut introduce_new_source_root = None; + let mut target_data_layout = None; for component in components[1..].iter() { - let (key, value) = component - .split_once(':') - .unwrap_or_else(|| panic!("invalid meta line: {:?}", meta)); + let (key, value) = + component.split_once(':').unwrap_or_else(|| panic!("invalid meta line: {meta:?}")); match key { "crate" => krate = Some(value.to_string()), "deps" => deps = value.split(',').map(|it| it.to_string()).collect(), @@ -213,16 +212,15 @@ fn parse_meta_line(meta: &str) -> Fixture { } } "new_source_root" => introduce_new_source_root = Some(value.to_string()), - _ => panic!("bad component: {:?}", component), + "target_data_layout" => target_data_layout = Some(value.to_string()), + _ => panic!("bad component: {component:?}"), } } for prelude_dep in extern_prelude.iter().flatten() { assert!( deps.contains(prelude_dep), - "extern-prelude {:?} must be a subset of deps {:?}", - extern_prelude, - deps + "extern-prelude {extern_prelude:?} must be a subset of deps {deps:?}" ); } @@ -237,6 +235,7 @@ fn parse_meta_line(meta: &str) -> Fixture { edition, env, introduce_new_source_root, + target_data_layout, } } } @@ -249,7 +248,7 @@ fn has_flag(&self, flag: &str) -> bool { #[track_caller] fn assert_valid_flag(&self, flag: &str) { if !self.valid_flags.iter().any(|it| it == flag) { - panic!("invalid flag: {:?}, valid flags: {:?}", flag, self.valid_flags); + panic!("invalid flag: {flag:?}, valid flags: {:?}", self.valid_flags); } } @@ -259,7 +258,7 @@ fn parse(line: &str) -> MiniCore { let line = line.strip_prefix("//- minicore:").unwrap().trim(); for entry in line.split(", ") { if res.has_flag(entry) { - panic!("duplicate minicore flag: {:?}", entry); + panic!("duplicate minicore flag: {entry:?}"); } res.activated_flags.push(entry.to_owned()); } @@ -345,11 +344,7 @@ pub fn source_code(mut self) -> String { let mut keep = true; for ®ion in &active_regions { - assert!( - !region.starts_with(' '), - "region marker starts with a space: {:?}", - region - ); + assert!(!region.starts_with(' '), "region marker starts with a space: {region:?}"); self.assert_valid_flag(region); seen_regions.push(region); keep &= self.has_flag(region); @@ -365,7 +360,7 @@ pub fn source_code(mut self) -> String { for flag in &self.valid_flags { if !seen_regions.iter().any(|it| it == flag) { - panic!("unused minicore flag: {:?}", flag); + panic!("unused minicore flag: {flag:?}"); } } buf