X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=tests%2Fcompile-test.rs;h=c10ee969c014620b996dafa32d94367d10db825a;hb=be15e60d0042500595eb133e804a1ba8e6a4789e;hp=9d0320bf065e96a9af9bb5880646853c980a8004;hpb=dc497c82ff1eb7377a0490885f5bbc53c0f1e4e8;p=rust.git diff --git a/tests/compile-test.rs b/tests/compile-test.rs index 9d0320bf065..c10ee969c01 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -111,15 +111,14 @@ .collect(); assert!( not_found.is_empty(), - "dependencies not found in depinfo: {:?}\n\ + "dependencies not found in depinfo: {not_found:?}\n\ help: Make sure the `-Z binary-dep-depinfo` rust flag is enabled\n\ help: Try adding to dev-dependencies in Cargo.toml\n\ help: Be sure to also add `extern crate ...;` to tests/compile-test.rs", - not_found, ); crates .into_iter() - .map(|(name, path)| format!(" --extern {}={}", name, path)) + .map(|(name, path)| format!(" --extern {name}={path}")) .collect() }); @@ -150,9 +149,8 @@ fn base_config(test_dir: &str) -> compiletest::Config { .map(|p| format!(" -L dependency={}", Path::new(p).join("deps").display())) .unwrap_or_default(); config.target_rustcflags = Some(format!( - "--emit=metadata -Dwarnings -Zui-testing -L dependency={}{}{}", + "--emit=metadata -Dwarnings -Zui-testing -L dependency={}{host_libs}{}", deps_path.display(), - host_libs, &*EXTERN_FLAGS, )); @@ -239,7 +237,7 @@ fn run_tests(config: &compiletest::Config, mut tests: Vec Ok(true) => {}, Ok(false) => panic!("Some tests failed"), Err(e) => { - panic!("I/O failure during tests: {:?}", e); + panic!("I/O failure during tests: {e:?}"); }, } } @@ -285,7 +283,7 @@ fn run_tests( env::set_current_dir(&src_path)?; let cargo_toml_path = case.path().join("Cargo.toml"); - let cargo_content = fs::read(&cargo_toml_path)?; + let cargo_content = fs::read(cargo_toml_path)?; let cargo_parsed: toml::Value = toml::from_str( std::str::from_utf8(&cargo_content).expect("`Cargo.toml` is not a valid utf-8 file!"), ) @@ -348,7 +346,7 @@ fn run_tests( Ok(true) => {}, Ok(false) => panic!("Some tests failed"), Err(e) => { - panic!("I/O failure during tests: {:?}", e); + panic!("I/O failure during tests: {e:?}"); }, } } @@ -393,6 +391,7 @@ fn compile_test() { "search_is_some.rs", "single_component_path_imports_nested_first.rs", "string_add.rs", + "suspicious_to_owned.rs", "toplevel_ref_arg_non_rustfix.rs", "unit_arg.rs", "unnecessary_clone.rs", @@ -413,19 +412,20 @@ fn check_rustfix_coverage() { if let Ok(missing_coverage_contents) = std::fs::read_to_string(missing_coverage_path) { assert!(RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS.iter().is_sorted_by_key(Path::new)); - for rs_path in missing_coverage_contents.lines() { - if Path::new(rs_path).starts_with("tests/ui/crashes") { + for rs_file in missing_coverage_contents.lines() { + let rs_path = Path::new(rs_file); + if rs_path.starts_with("tests/ui/crashes") { continue; } - let filename = Path::new(rs_path).strip_prefix("tests/ui/").unwrap(); + assert!(rs_path.starts_with("tests/ui/"), "{rs_file:?}"); + let filename = rs_path.strip_prefix("tests/ui/").unwrap(); assert!( RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS .binary_search_by_key(&filename, Path::new) .is_ok(), - "`{}` runs `MachineApplicable` diagnostics but is missing a `run-rustfix` annotation. \ + "`{rs_file}` runs `MachineApplicable` diagnostics but is missing a `run-rustfix` annotation. \ Please either add `// run-rustfix` at the top of the file or add the file to \ `RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS` in `tests/compile-test.rs`.", - rs_path, ); } } @@ -475,15 +475,13 @@ fn ui_cargo_toml_metadata() { .map(|component| component.as_os_str().to_string_lossy().replace('-', "_")) .any(|s| *s == name) || path.starts_with(&cargo_common_metadata_path), - "{:?} has incorrect package name", - path + "{path:?} has incorrect package name" ); let publish = package.get("publish").and_then(toml::Value::as_bool).unwrap_or(true); assert!( !publish || publish_exceptions.contains(&path.parent().unwrap().to_path_buf()), - "{:?} lacks `publish = false`", - path + "{path:?} lacks `publish = false`" ); } }