diff --git a/.gitignore b/.gitignore index 77f4d9fb..8fae43e1 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ localdata/ # Editor-local configuration .vscode/ + +# Unnecessary test data +test_crates/*/*/Cargo.lock diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4b33cda8..84362033 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -116,12 +116,9 @@ Lints are written as queries for the `trustfall` ["query everything" engine](ht Checklist: - Choose an appropriate name for your query. We'll refer to it as ``. - Add the query file: `src/lints/.ron`. -- Add a `` feature to `test_crates/Cargo.toml`. -- Add a `.rs` file in `test_crates/src/test_cases`. -- Add code to that file that demonstrates that semver issue: write the "baseline" first, - and then use `#[cfg(feature = )]` and `#[cfg(not(feature = ))]` as - necessary to alter that baseline into a shape that causes the semver issue - your query looks for. +- Create a new testing crate pair (by copy-pasting `test_crates/template` + to `test_crates/` and changing the names in its `Cargo.toml`s to ``) + and add code in both the `new/` and `old/` crates that demonstrates that semver issue. - Add test code for false-positives and/or true-but-unintended-positives your query might report. For example, a true-but-unintended output would be if a query that looks for removal of public fields were to report that a struct was removed. This is unintended @@ -129,6 +126,7 @@ Checklist: specifically reports the removal of the struct rather than all its fields separately. - Add the outputs you expect your query to produce over your test case in a new file: `test_outputs/.output.run`. + The test output generation process is described in `test_crates/README.md`. - Add `` to the list of queries used by the `add_lints!()` macro near the bottom of `src/query.rs`. It includes the query content and also creates a new test function named `` that compares the output of running this query on `test_crates/` diff --git a/scripts/regenerate_test_rustdocs.sh b/scripts/regenerate_test_rustdocs.sh index 58595e6c..1a077e1a 100755 --- a/scripts/regenerate_test_rustdocs.sh +++ b/scripts/regenerate_test_rustdocs.sh @@ -3,12 +3,10 @@ # Fail on first error, on undefined variables, and on failures in pipelines. set -euo pipefail -# Go to the test_crates directory. -cd "$(git rev-parse --show-toplevel)/test_crates" - export CARGO_TARGET_DIR=/tmp/test_crates -RUSTDOC_OUTPUT="$CARGO_TARGET_DIR/doc/test_crates.json" -TARGET_DIR="$(git rev-parse --show-toplevel)/localdata/test_data" +RUSTDOC_OUTPUT_DIR="$CARGO_TARGET_DIR/doc" +TOPLEVEL="$(git rev-parse --show-toplevel)" +TARGET_DIR="$TOPLEVEL/localdata/test_data" # Allow setting an explicit toolchain, like +nightly or +beta. set +u @@ -16,21 +14,21 @@ TOOLCHAIN="$1" set -u RUSTDOC_CMD="cargo $TOOLCHAIN rustdoc" -# Ensure the target test data directory exists. -mkdir -p "$TARGET_DIR" - -# Make the baseline configuration file. -echo "Generating: baseline" -RUSTC_BOOTSTRAP=1 $RUSTDOC_CMD -- -Zunstable-options --output-format json -mv "$RUSTDOC_OUTPUT" "$TARGET_DIR/baseline.json" - -# For each feature, re-run rustdoc with it enabled. -features="$(cargo metadata --format-version 1 | \ - jq --exit-status -r '.packages[] | select(.name = "test_crates") | .features | keys[]')" -while IFS= read -r feat; do - echo "Generating: $feat" - RUSTC_BOOTSTRAP=1 $RUSTDOC_CMD --features "$feat" -- -Zunstable-options --output-format json - mv "$RUSTDOC_OUTPUT" "$TARGET_DIR/$feat.json" -done <<< "$features" +# Run rustdoc on test_crates/*/{new,old}/ +for crate_pair in $(find "$TOPLEVEL/test_crates/" -maxdepth 1 -mindepth 1 -type d); do + # Removing path prefix, leaving only the directory name without forward slashes + crate_pair=${crate_pair#"$TOPLEVEL/test_crates/"} + + for crate_version in "new" "old"; do + crate="$crate_pair/$crate_version" + echo "Generating: $crate" + + pushd "$TOPLEVEL/test_crates/$crate" + RUSTC_BOOTSTRAP=1 $RUSTDOC_CMD -- -Zunstable-options --output-format json + mkdir -p "$TARGET_DIR/$crate" + mv "$RUSTDOC_OUTPUT_DIR/$crate_pair.json" "$TARGET_DIR/$crate/rustdoc.json" + popd + done +done unset CARGO_TARGET_DIR diff --git a/src/query.rs b/src/query.rs index b84a5b51..db5f0681 100644 --- a/src/query.rs +++ b/src/query.rs @@ -100,16 +100,26 @@ mod tests { use anyhow::Context; use trustfall_core::ir::TransparentValue; use trustfall_core::{frontend::parse, ir::FieldValue}; - use trustfall_rustdoc::{load_rustdoc, VersionedIndexedCrate, VersionedRustdocAdapter}; + use trustfall_rustdoc::{ + load_rustdoc, VersionedCrate, VersionedIndexedCrate, VersionedRustdocAdapter, + }; use crate::query::SemverQuery; use crate::templating::make_handlebars_registry; + fn load_pregenerated_rustdoc(crate_pair: &str, crate_version: &str) -> VersionedCrate { + let path = format!( + "./localdata/test_data/{}/{}/rustdoc.json", + crate_pair, crate_version + ); + load_rustdoc(Path::new(&path)) + .with_context(|| format!("Could not load {} file, did you forget to run ./scripts/regenerate_test_rustdocs.sh ?", path)) + .expect("failed to load baseline rustdoc") + } + #[test] fn all_queries_parse_correctly() { - let current_crate = load_rustdoc(Path::new("./localdata/test_data/baseline.json")) - .with_context(|| "Could not load localdata/test_data/baseline.json file, did you forget to run ./scripts/regenerate_test_rustdocs.sh ?") - .expect("failed to load baseline rustdoc"); + let current_crate = load_pregenerated_rustdoc("template", "new"); let indexed_crate = VersionedIndexedCrate::new(¤t_crate); let adapter = VersionedRustdocAdapter::new(&indexed_crate, None).expect("failed to create adapter"); @@ -122,10 +132,7 @@ mod tests { #[test] fn pub_use_handling() { - let current_crate = load_rustdoc(Path::new("./localdata/test_data/baseline.json")) - .with_context(|| "Could not load localdata/test_data/baseline.json file, did you forget to run ./scripts/regenerate_test_rustdocs.sh ?") - .expect("failed to load baseline rustdoc"); - + let current_crate = load_pregenerated_rustdoc("pub_use_handling", "new"); let current = VersionedIndexedCrate::new(¤t_crate); let query = r#" @@ -159,13 +166,8 @@ mod tests { .map(|res| res.into_iter().map(|(k, v)| (k.to_string(), v)).collect()) .collect(); - let expected_result: FieldValue = vec![ - "test_crates", - "import_handling", - "inner", - "CheckPubUseHandling", - ] - .into(); + let expected_result: FieldValue = + vec!["pub_use_handling", "inner", "CheckPubUseHandling"].into(); assert_eq!(1, actual_results.len(), "{actual_results:?}"); assert_eq!( expected_result, actual_results[0]["canonical_path"], @@ -178,31 +180,40 @@ mod tests { actual_paths.sort_unstable(); let expected_paths = vec![ - vec!["test_crates", "CheckPubUseHandling"], - vec!["test_crates", "import_handling", "CheckPubUseHandling"], - vec![ - "test_crates", - "import_handling", - "inner", - "CheckPubUseHandling", - ], + vec!["pub_use_handling", "CheckPubUseHandling"], + vec!["pub_use_handling", "inner", "CheckPubUseHandling"], ]; assert_eq!(expected_paths, actual_paths); } - pub(in crate::query) fn check_query_execution(query_name: &str) { - // Ensure the rustdocs JSON outputs have been regenerated. - let baseline_crate = load_rustdoc(Path::new("./localdata/test_data/baseline.json")) - .with_context(|| "Could not load localdata/test_data/baseline.json file, did you forget to run ./scripts/regenerate_test_rustdocs.sh ?") - .expect("failed to load baseline rustdoc"); - let current_crate = - load_rustdoc(Path::new(&format!("./localdata/test_data/{}.json", query_name))) - .with_context(|| format!("Could not load localdata/test_data/{}.json file, did you forget to run ./scripts/regenerate_test_rustdocs.sh ?", query_name)) - .expect("failed to load rustdoc under test"); - - let baseline = VersionedIndexedCrate::new(&baseline_crate); - let current = VersionedIndexedCrate::new(¤t_crate); + fn get_test_crate_names() -> Vec { + std::fs::read_dir("./test_crates/") + .expect("directory test_crates/ not found") + .map(|dir_entry| dir_entry.expect("failed to list test_crates/")) + .filter(|dir_entry| { + dir_entry + .metadata() + .expect("failed to retrieve test_crates/* metadata") + .is_dir() + }) + .map(|dir_entry| { + String::from( + String::from( + dir_entry + .path() + .to_str() + .expect("failed to convert dir_entry to String"), + ) + .strip_prefix("./test_crates/") + .expect( + "the dir_entry doesn't start with './test_crates/', which is unexpected", + ), + ) + }) + .collect() + } + pub(in crate::query) fn check_query_execution(query_name: &str) { let query_text = std::fs::read_to_string(&format!("./src/lints/{}.ron", query_name)).unwrap(); let semver_query: SemverQuery = ron::from_str(&query_text).unwrap(); @@ -211,38 +222,77 @@ mod tests { std::fs::read_to_string(&format!("./test_outputs/{}.output.ron", query_name)) .with_context(|| format!("Could not load test_outputs/{}.output.ron expected-outputs file, did you forget to add it?", query_name)) .expect("failed to load expected outputs"); - let mut expected_results: Vec> = + let mut expected_results: BTreeMap>> = ron::from_str(&expected_result_text) .expect("could not parse expected outputs as ron format"); - let adapter = VersionedRustdocAdapter::new(¤t, Some(&baseline)) - .expect("could not create adapter"); - let results_iter = adapter - .run_query(&semver_query.query, semver_query.arguments.clone()) - .unwrap(); - - let mut actual_results: Vec> = results_iter - .map(|res| res.into_iter().map(|(k, v)| (k.to_string(), v)).collect()) + let mut actual_results: BTreeMap>> = get_test_crate_names() + .into_iter() + .map(|crate_pair| { + let crate_new = load_pregenerated_rustdoc(&crate_pair, "new"); + let crate_old = load_pregenerated_rustdoc(&crate_pair, "old"); + let indexed_crate_new = VersionedIndexedCrate::new(&crate_new); + let indexed_crate_old = VersionedIndexedCrate::new(&crate_old); + + let adapter = + VersionedRustdocAdapter::new(&indexed_crate_new, Some(&indexed_crate_old)) + .expect("could not create adapter"); + let results_iter = adapter + .run_query(&semver_query.query, semver_query.arguments.clone()) + .unwrap(); + ( + format!("./test_crates/{}/", crate_pair), + results_iter + .map(|res| res.into_iter().map(|(k, v)| (k.to_string(), v)).collect()) + .collect::>>(), + ) + }) + .filter(|(_crate_pair, output)| !output.is_empty()) .collect(); // Reorder both vectors of results into a deterministic order that will compensate for // nondeterminism in how the results are ordered. - let key_func = |elem: &BTreeMap| { - ( - elem["span_filename"].as_str().unwrap().to_owned(), - elem["span_begin_line"].as_usize().unwrap(), - ) + let sort_individual_outputs = |results: &mut BTreeMap>| { + let key_func = |elem: &BTreeMap| { + ( + elem["span_filename"].as_str().unwrap().to_owned(), + elem["span_begin_line"].as_usize().unwrap(), + ) + }; + for value in results.values_mut() { + value.sort_unstable_by_key(key_func); + } }; - expected_results.sort_unstable_by_key(key_func); - actual_results.sort_unstable_by_key(key_func); - - assert_eq!(expected_results, actual_results); + sort_individual_outputs(&mut expected_results); + sort_individual_outputs(&mut actual_results); + + if expected_results != actual_results { + let results_to_string = |name, results| { + format!( + "{}:\n{}", + name, + ron::ser::to_string_pretty(&results, ron::ser::PrettyConfig::default()) + .unwrap() + ) + }; + let messages = vec![ + format!("Query {} produced incorrect output (./src/lints/{}.ron).", &query_name, &query_name), + results_to_string(format!("Expected output (./test_outputs/{}.output.ron)", &query_name), &expected_results), + results_to_string("Actual output".to_string(), &actual_results), + "Note that the individual outputs might have been deliberately reordered. Also, remember about running ./scripts/regenerate_test_rustdocs.sh when needed.".to_string(), + ]; + panic!("\n{}\n", messages.join("\n\n")); + } let registry = make_handlebars_registry(); if let Some(template) = semver_query.per_result_error_template { assert!(!actual_results.is_empty()); - for semver_violation_result in actual_results { + let flattened_actual_results: Vec<_> = actual_results + .into_iter() + .flat_map(|(_key, value)| value) + .collect(); + for semver_violation_result in flattened_actual_results { let pretty_result: BTreeMap = semver_violation_result .into_iter() .map(|(k, v)| (k, v.into())) diff --git a/test_crates/Cargo.lock b/test_crates/Cargo.lock deleted file mode 100644 index 42c3a7e6..00000000 --- a/test_crates/Cargo.lock +++ /dev/null @@ -1,7 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "test_crates" -version = "0.1.0" diff --git a/test_crates/Cargo.toml b/test_crates/Cargo.toml deleted file mode 100644 index 73d127a3..00000000 --- a/test_crates/Cargo.toml +++ /dev/null @@ -1,32 +0,0 @@ -[package] -name = "test_crates" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] - -[features] -auto_trait_impl_removed = [] -derive_trait_impl_removed = [] -enum_marked_non_exhaustive = [] -enum_missing = [] -enum_repr_int_changed = [] -enum_repr_int_removed = [] -enum_repr_c_removed = [] -enum_variant_added = [] -enum_variant_missing = [] -enum_struct_variant_field_missing = [] -function_missing = [] -function_parameter_count_changed = [] -inherent_method_missing = [] -method_parameter_count_changed = [] -sized_impl_removed = [] -struct_marked_non_exhaustive = [] -struct_missing = [] -struct_pub_field_missing = [] -struct_repr_c_removed = [] -struct_repr_transparent_removed = [] -unit_struct_changed_kind = [] -variant_marked_non_exhaustive = [] diff --git a/test_crates/README.md b/test_crates/README.md new file mode 100644 index 00000000..99255e11 --- /dev/null +++ b/test_crates/README.md @@ -0,0 +1,9 @@ +# How the testing crate pairs work + +In the tests, each lint is ran on _all_ crate pairs from this directory. +Then, the output of a lint (saved in the `../test_outputs` directory) +is a map from the crate pair path to the (sorted) list of query output. + +The output of a lint on a crate pair (a pair is a `new` and `old` crate) +is the raw output of a query. The current crate is the `new` one, +and the baseline crate is the `old` one. diff --git a/test_crates/auto_trait_impl_removed/new/Cargo.toml b/test_crates/auto_trait_impl_removed/new/Cargo.toml new file mode 100644 index 00000000..504f7207 --- /dev/null +++ b/test_crates/auto_trait_impl_removed/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "auto_trait_impl_removed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/src/test_cases/auto_trait_impl_removed.rs b/test_crates/auto_trait_impl_removed/new/src/lib.rs similarity index 59% rename from test_crates/src/test_cases/auto_trait_impl_removed.rs rename to test_crates/auto_trait_impl_removed/new/src/lib.rs index 7b47a1f0..55d72896 100644 --- a/test_crates/src/test_cases/auto_trait_impl_removed.rs +++ b/test_crates/auto_trait_impl_removed/new/src/lib.rs @@ -3,15 +3,8 @@ use std::{ marker::PhantomPinned, panic::{AssertUnwindSafe, UnwindSafe}, rc::Rc, - sync::Arc, }; -#[cfg(not(feature = "auto_trait_impl_removed"))] -pub struct SyncStruct { - bar: usize, -} - -#[cfg(feature = "auto_trait_impl_removed")] pub struct SyncStruct { // RefCell is Send if T is Send, but it is never Sync. // We need AssertUnwindSafe in order to keep this struct RefUnwindSafe. @@ -19,36 +12,17 @@ pub struct SyncStruct { bar: AssertUnwindSafe>, } -#[cfg(not(feature = "auto_trait_impl_removed"))] -pub struct SendStruct { - // RefCell is Send if T is Send, but it is never Sync. - bar: RefCell, -} - -#[cfg(feature = "auto_trait_impl_removed")] pub struct SendStruct { // This is just a silly type that is neither Send nor Sync. // It's not actually useful for anything. bar: RefCell>, } -#[cfg(not(feature = "auto_trait_impl_removed"))] -pub struct UnwindSafeStruct<'a> { - bar: &'a i64, -} - -#[cfg(feature = "auto_trait_impl_removed")] pub struct UnwindSafeStruct<'a> { // &mut T is not UnwindSafe unless T is AssertUnwindSafe. bar: &'a mut i64, } -#[cfg(not(feature = "auto_trait_impl_removed"))] -pub struct RefUnwindSafeStruct { - bar: Rc, -} - -#[cfg(feature = "auto_trait_impl_removed")] pub struct RefUnwindSafeStruct { bar: Rc>, } @@ -60,15 +34,8 @@ pub struct RefUnwindSafeStruct { // Manually put the UnwindSafe trait back in, so that our test case tests // only for RefUnwindSafe being removed. UnwindSafe was tested earlier // in this file. -#[cfg(feature = "auto_trait_impl_removed")] impl UnwindSafe for RefUnwindSafeStruct {} -#[cfg(not(feature = "auto_trait_impl_removed"))] -pub struct UnpinStruct { - bar: i64, -} - -#[cfg(feature = "auto_trait_impl_removed")] pub struct UnpinStruct { bar: i64, _marker: PhantomPinned, diff --git a/test_crates/auto_trait_impl_removed/old/Cargo.toml b/test_crates/auto_trait_impl_removed/old/Cargo.toml new file mode 100644 index 00000000..504f7207 --- /dev/null +++ b/test_crates/auto_trait_impl_removed/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "auto_trait_impl_removed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/auto_trait_impl_removed/old/src/lib.rs b/test_crates/auto_trait_impl_removed/old/src/lib.rs new file mode 100644 index 00000000..d53e90f8 --- /dev/null +++ b/test_crates/auto_trait_impl_removed/old/src/lib.rs @@ -0,0 +1,22 @@ +use std::{cell::RefCell, rc::Rc}; + +pub struct SyncStruct { + bar: usize, +} + +pub struct SendStruct { + // RefCell is Send if T is Send, but it is never Sync. + bar: RefCell, +} + +pub struct UnwindSafeStruct<'a> { + bar: &'a i64, +} + +pub struct RefUnwindSafeStruct { + bar: Rc, +} + +pub struct UnpinStruct { + bar: i64, +} diff --git a/test_crates/derive_trait_impl_removed/new/Cargo.toml b/test_crates/derive_trait_impl_removed/new/Cargo.toml new file mode 100644 index 00000000..e3650141 --- /dev/null +++ b/test_crates/derive_trait_impl_removed/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "derive_trait_impl_removed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/derive_trait_impl_removed/new/src/lib.rs b/test_crates/derive_trait_impl_removed/new/src/lib.rs new file mode 100644 index 00000000..4ccff47c --- /dev/null +++ b/test_crates/derive_trait_impl_removed/new/src/lib.rs @@ -0,0 +1,18 @@ +#[derive(Clone)] +pub struct DebugFoo; + +#[derive(Clone)] +pub enum CopyBar { + Var, +} + +#[derive(PartialEq)] +pub struct EqFoo; + +// The following is not a semver issue: it's not breaking to replace +// a derived impl with a hand-impl of the same trait. + +#[derive(PartialEq)] +pub struct ManualEqFoo; + +impl Eq for ManualEqFoo {} diff --git a/test_crates/derive_trait_impl_removed/old/Cargo.toml b/test_crates/derive_trait_impl_removed/old/Cargo.toml new file mode 100644 index 00000000..e3650141 --- /dev/null +++ b/test_crates/derive_trait_impl_removed/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "derive_trait_impl_removed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/derive_trait_impl_removed/old/src/lib.rs b/test_crates/derive_trait_impl_removed/old/src/lib.rs new file mode 100644 index 00000000..d9af2e9d --- /dev/null +++ b/test_crates/derive_trait_impl_removed/old/src/lib.rs @@ -0,0 +1,16 @@ +#[derive(Debug, Clone)] +pub struct DebugFoo; + +#[derive(Clone, Copy)] +pub enum CopyBar { + Var, +} + +#[derive(PartialEq, Eq)] +pub struct EqFoo; + +// The following is not a semver issue: it's not breaking to replace +// a derived impl with a hand-impl of the same trait. + +#[derive(PartialEq, Eq)] +pub struct ManualEqFoo; diff --git a/test_crates/enum_missing/new/Cargo.toml b/test_crates/enum_missing/new/Cargo.toml new file mode 100644 index 00000000..5e3f45c7 --- /dev/null +++ b/test_crates/enum_missing/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "enum_missing" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/enum_missing/new/src/lib.rs b/test_crates/enum_missing/new/src/lib.rs new file mode 100644 index 00000000..c5cad53b --- /dev/null +++ b/test_crates/enum_missing/new/src/lib.rs @@ -0,0 +1,3 @@ +pub mod my_pub_mod { + pub enum PubUseRemovedEnum {} +} diff --git a/test_crates/enum_missing/old/Cargo.toml b/test_crates/enum_missing/old/Cargo.toml new file mode 100644 index 00000000..5e3f45c7 --- /dev/null +++ b/test_crates/enum_missing/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "enum_missing" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/enum_missing/old/src/lib.rs b/test_crates/enum_missing/old/src/lib.rs new file mode 100644 index 00000000..6b83c599 --- /dev/null +++ b/test_crates/enum_missing/old/src/lib.rs @@ -0,0 +1,7 @@ +pub enum WillBeRemovedEnum {} + +pub mod my_pub_mod { + pub enum PubUseRemovedEnum {} +} + +pub use my_pub_mod::PubUseRemovedEnum; diff --git a/test_crates/enum_repr_c_removed/new/Cargo.toml b/test_crates/enum_repr_c_removed/new/Cargo.toml new file mode 100644 index 00000000..918254dc --- /dev/null +++ b/test_crates/enum_repr_c_removed/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "enum_repr_c_removed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/enum_repr_c_removed/new/src/lib.rs b/test_crates/enum_repr_c_removed/new/src/lib.rs new file mode 100644 index 00000000..48518baf --- /dev/null +++ b/test_crates/enum_repr_c_removed/new/src/lib.rs @@ -0,0 +1,3 @@ +pub enum Foo { + Bar, +} diff --git a/test_crates/enum_repr_c_removed/old/Cargo.toml b/test_crates/enum_repr_c_removed/old/Cargo.toml new file mode 100644 index 00000000..918254dc --- /dev/null +++ b/test_crates/enum_repr_c_removed/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "enum_repr_c_removed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/enum_repr_c_removed/old/src/lib.rs b/test_crates/enum_repr_c_removed/old/src/lib.rs new file mode 100644 index 00000000..914fbf44 --- /dev/null +++ b/test_crates/enum_repr_c_removed/old/src/lib.rs @@ -0,0 +1,4 @@ +#[repr(C)] +pub enum Foo { + Bar, +} diff --git a/test_crates/enum_repr_int_changed/new/Cargo.toml b/test_crates/enum_repr_int_changed/new/Cargo.toml new file mode 100644 index 00000000..2f773236 --- /dev/null +++ b/test_crates/enum_repr_int_changed/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "enum_repr_int_changed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/enum_repr_int_changed/new/src/lib.rs b/test_crates/enum_repr_int_changed/new/src/lib.rs new file mode 100644 index 00000000..5f76e18d --- /dev/null +++ b/test_crates/enum_repr_int_changed/new/src/lib.rs @@ -0,0 +1,47 @@ +#[repr(u16)] +pub enum U8ToU16Enum { + Bar, + Baz, +} + +#[repr(i8)] +pub enum I32ToI8Enum { + Bar, + Baz, +} + +#[repr(u32)] +pub enum I32ToU32Enum { + Bar, + Baz, +} + +#[repr(usize)] +pub enum IsizeToUsizeEnum { + Bar, + Baz, +} + +// The following enums have *removals* of repr(i*) and repr(u*), +// not changes to another repr(i*) or repr(u*). +// They should not be reported by this rule, because they have their own rule. + +pub enum U8Enum { + Bar, + Baz, +} + +pub enum I32Enum { + Bar, + Baz, +} + +pub enum IsizeEnum { + Bar, + Baz, +} + +pub enum UsizeEnum { + Bar, + Baz, +} diff --git a/test_crates/enum_repr_int_changed/old/Cargo.toml b/test_crates/enum_repr_int_changed/old/Cargo.toml new file mode 100644 index 00000000..2f773236 --- /dev/null +++ b/test_crates/enum_repr_int_changed/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "enum_repr_int_changed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/enum_repr_int_changed/old/src/lib.rs b/test_crates/enum_repr_int_changed/old/src/lib.rs new file mode 100644 index 00000000..54ce478c --- /dev/null +++ b/test_crates/enum_repr_int_changed/old/src/lib.rs @@ -0,0 +1,51 @@ +#[repr(u8)] +pub enum U8ToU16Enum { + Bar, + Baz, +} + +#[repr(i32)] +pub enum I32ToI8Enum { + Bar, + Baz, +} + +#[repr(i32)] +pub enum I32ToU32Enum { + Bar, + Baz, +} + +#[repr(isize)] +pub enum IsizeToUsizeEnum { + Bar, + Baz, +} + +// The following enums have *removals* of repr(i*) and repr(u*), +// not changes to another repr(i*) or repr(u*). +// They should not be reported by this rule, because they have their own rule. + +#[repr(u8)] +pub enum U8Enum { + Bar, + Baz, +} + +#[repr(i32)] +pub enum I32Enum { + Bar, + Baz, +} + +#[repr(isize)] +pub enum IsizeEnum { + Bar, + Baz, +} + +#[repr(usize)] +pub enum UsizeEnum { + Bar, + Baz, +} diff --git a/test_crates/enum_repr_int_removed/new/Cargo.toml b/test_crates/enum_repr_int_removed/new/Cargo.toml new file mode 100644 index 00000000..d2ae2d73 --- /dev/null +++ b/test_crates/enum_repr_int_removed/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "enum_repr_int_removed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/enum_repr_int_removed/new/src/lib.rs b/test_crates/enum_repr_int_removed/new/src/lib.rs new file mode 100644 index 00000000..e75892c2 --- /dev/null +++ b/test_crates/enum_repr_int_removed/new/src/lib.rs @@ -0,0 +1,19 @@ +pub enum U8Enum { + Bar, + Baz, +} + +pub enum I32Enum { + Bar, + Baz, +} + +pub enum IsizeEnum { + Bar, + Baz, +} + +pub enum UsizeEnum { + Bar, + Baz, +} diff --git a/test_crates/enum_repr_int_removed/old/Cargo.toml b/test_crates/enum_repr_int_removed/old/Cargo.toml new file mode 100644 index 00000000..d2ae2d73 --- /dev/null +++ b/test_crates/enum_repr_int_removed/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "enum_repr_int_removed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/enum_repr_int_removed/old/src/lib.rs b/test_crates/enum_repr_int_removed/old/src/lib.rs new file mode 100644 index 00000000..3a5352ed --- /dev/null +++ b/test_crates/enum_repr_int_removed/old/src/lib.rs @@ -0,0 +1,22 @@ +#[repr(u8)] +pub enum U8Enum { + Bar, + Baz, +} +#[repr(i32)] +pub enum I32Enum { + Bar, + Baz, +} + +#[repr(isize)] +pub enum IsizeEnum { + Bar, + Baz, +} + +#[repr(usize)] +pub enum UsizeEnum { + Bar, + Baz, +} diff --git a/test_crates/enum_struct_variant_field_missing/new/Cargo.toml b/test_crates/enum_struct_variant_field_missing/new/Cargo.toml new file mode 100644 index 00000000..4a296648 --- /dev/null +++ b/test_crates/enum_struct_variant_field_missing/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "enum_struct_variant_field_missing" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/enum_struct_variant_field_missing/new/src/lib.rs b/test_crates/enum_struct_variant_field_missing/new/src/lib.rs new file mode 100644 index 00000000..4e4a49f7 --- /dev/null +++ b/test_crates/enum_struct_variant_field_missing/new/src/lib.rs @@ -0,0 +1,5 @@ +pub enum Enum { + FieldWillBeMissing { foo: usize }, +} + +pub enum IgnoredEnum {} diff --git a/test_crates/enum_struct_variant_field_missing/old/Cargo.toml b/test_crates/enum_struct_variant_field_missing/old/Cargo.toml new file mode 100644 index 00000000..4a296648 --- /dev/null +++ b/test_crates/enum_struct_variant_field_missing/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "enum_struct_variant_field_missing" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/src/test_cases/enum_struct_variant_field_missing.rs b/test_crates/enum_struct_variant_field_missing/old/src/lib.rs similarity index 69% rename from test_crates/src/test_cases/enum_struct_variant_field_missing.rs rename to test_crates/enum_struct_variant_field_missing/old/src/lib.rs index 26aa59c9..99f191c6 100644 --- a/test_crates/src/test_cases/enum_struct_variant_field_missing.rs +++ b/test_crates/enum_struct_variant_field_missing/old/src/lib.rs @@ -3,17 +3,13 @@ pub enum Enum { foo: usize, /// Testing: - #[cfg(not(feature = "enum_struct_variant_field_missing"))] bar: usize, - } + }, } /// This struct variant should not be reported by the `enum_struct_variant_field_missing` rule: /// it will be removed altogether, so the correct rule to catch it is /// the `enum_variant_missing` rule and not the rule for missing fields. pub enum IgnoredEnum { - #[cfg(not(feature = "enum_struct_variant_field_missing"))] - StructVariantWillBeMissing { - foo: usize, - } + StructVariantWillBeMissing { foo: usize }, } diff --git a/test_crates/enum_variant_added/new/Cargo.toml b/test_crates/enum_variant_added/new/Cargo.toml new file mode 100644 index 00000000..d50d8d8c --- /dev/null +++ b/test_crates/enum_variant_added/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "enum_variant_added" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/src/test_cases/enum_variant_added.rs b/test_crates/enum_variant_added/new/src/lib.rs similarity index 77% rename from test_crates/src/test_cases/enum_variant_added.rs rename to test_crates/enum_variant_added/new/src/lib.rs index e80361b5..15ec2c31 100644 --- a/test_crates/src/test_cases/enum_variant_added.rs +++ b/test_crates/enum_variant_added/new/src/lib.rs @@ -1,7 +1,6 @@ pub enum EnumWithNewVariant { OldVariant, - #[cfg(feature = "enum_variant_added")] NewVariant, } @@ -11,6 +10,5 @@ pub enum EnumWithNewVariant { pub enum NonExhaustiveEnumWithNewVariant { OldVariant, - #[cfg(feature = "enum_variant_added")] NewVariant, } diff --git a/test_crates/enum_variant_added/old/Cargo.toml b/test_crates/enum_variant_added/old/Cargo.toml new file mode 100644 index 00000000..d50d8d8c --- /dev/null +++ b/test_crates/enum_variant_added/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "enum_variant_added" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/enum_variant_added/old/src/lib.rs b/test_crates/enum_variant_added/old/src/lib.rs new file mode 100644 index 00000000..f8e31301 --- /dev/null +++ b/test_crates/enum_variant_added/old/src/lib.rs @@ -0,0 +1,10 @@ +pub enum EnumWithNewVariant { + OldVariant, +} + +/// This enum should not be reported by the `enum_variant_added` rule, +/// since it is non-exhaustive so adding new variants is not breaking. +#[non_exhaustive] +pub enum NonExhaustiveEnumWithNewVariant { + OldVariant, +} diff --git a/test_crates/enum_variant_missing/new/Cargo.toml b/test_crates/enum_variant_missing/new/Cargo.toml new file mode 100644 index 00000000..87d9982a --- /dev/null +++ b/test_crates/enum_variant_missing/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "enum_variant_missing" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/enum_variant_missing/new/src/lib.rs b/test_crates/enum_variant_missing/new/src/lib.rs new file mode 100644 index 00000000..9e519bbb --- /dev/null +++ b/test_crates/enum_variant_missing/new/src/lib.rs @@ -0,0 +1,3 @@ +pub enum VariantWillBeRemoved { + Foo, +} diff --git a/test_crates/enum_variant_missing/old/Cargo.toml b/test_crates/enum_variant_missing/old/Cargo.toml new file mode 100644 index 00000000..87d9982a --- /dev/null +++ b/test_crates/enum_variant_missing/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "enum_variant_missing" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/src/test_cases/enum_variant_missing.rs b/test_crates/enum_variant_missing/old/src/lib.rs similarity index 80% rename from test_crates/src/test_cases/enum_variant_missing.rs rename to test_crates/enum_variant_missing/old/src/lib.rs index 3f566838..a136c7c3 100644 --- a/test_crates/src/test_cases/enum_variant_missing.rs +++ b/test_crates/enum_variant_missing/old/src/lib.rs @@ -2,14 +2,12 @@ pub enum VariantWillBeRemoved { Foo, /// Testing: - #[cfg(not(feature = "enum_variant_missing"))] Bar, } /// This enum should not be reported by the `enum_variant_missing` rule: /// it will be removed altogether, so the correct rule to catch it is /// the `enum_missing` rule and not the rule for missing variants. -#[cfg(not(feature = "enum_variant_missing"))] pub enum ShouldNotMatch { Foo, } diff --git a/test_crates/function_missing/new/Cargo.toml b/test_crates/function_missing/new/Cargo.toml new file mode 100644 index 00000000..3fa40934 --- /dev/null +++ b/test_crates/function_missing/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "function_missing" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/function_missing/new/src/lib.rs b/test_crates/function_missing/new/src/lib.rs new file mode 100644 index 00000000..9835a78b --- /dev/null +++ b/test_crates/function_missing/new/src/lib.rs @@ -0,0 +1,3 @@ +pub mod my_pub_mod { + pub fn pub_use_removed_fn() {} +} diff --git a/test_crates/function_missing/old/Cargo.toml b/test_crates/function_missing/old/Cargo.toml new file mode 100644 index 00000000..3fa40934 --- /dev/null +++ b/test_crates/function_missing/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "function_missing" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/function_missing/old/src/lib.rs b/test_crates/function_missing/old/src/lib.rs new file mode 100644 index 00000000..aac14c24 --- /dev/null +++ b/test_crates/function_missing/old/src/lib.rs @@ -0,0 +1,7 @@ +pub fn will_be_removed_fn() {} + +pub mod my_pub_mod { + pub fn pub_use_removed_fn() {} +} + +pub use my_pub_mod::pub_use_removed_fn; diff --git a/test_crates/inherent_method_missing/new/Cargo.toml b/test_crates/inherent_method_missing/new/Cargo.toml new file mode 100644 index 00000000..0f8a952d --- /dev/null +++ b/test_crates/inherent_method_missing/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "inherent_method_missing" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/inherent_method_missing/new/src/lib.rs b/test_crates/inherent_method_missing/new/src/lib.rs new file mode 100644 index 00000000..13eb456e --- /dev/null +++ b/test_crates/inherent_method_missing/new/src/lib.rs @@ -0,0 +1,15 @@ +pub struct Foo {} + +impl Foo {} + +// Moving an inherent method to an implemented trait should not be a breaking change, +// both when the method is defined inside the trait and when it's implemented externally. +pub trait Bar { + fn moved_trait_provided_method(&self) {} + + fn moved_method(&self); +} + +impl Bar for Foo { + fn moved_method(&self) {} +} diff --git a/test_crates/inherent_method_missing/old/Cargo.toml b/test_crates/inherent_method_missing/old/Cargo.toml new file mode 100644 index 00000000..0f8a952d --- /dev/null +++ b/test_crates/inherent_method_missing/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "inherent_method_missing" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/inherent_method_missing/old/src/lib.rs b/test_crates/inherent_method_missing/old/src/lib.rs new file mode 100644 index 00000000..a8911f45 --- /dev/null +++ b/test_crates/inherent_method_missing/old/src/lib.rs @@ -0,0 +1,14 @@ +// Test that associated function removal: +// - is caught and reported by `inherent_method_missing` +// - is not caught by `function_missing`. +pub struct Foo {} + +impl Foo { + pub fn will_be_removed_associated_fn() {} + + pub fn will_be_removed_method(&self) {} + + pub fn moved_trait_provided_method(&self) {} + + pub fn moved_method(&self) {} +} diff --git a/test_crates/item_relocation/new/Cargo.toml b/test_crates/item_relocation/new/Cargo.toml new file mode 100644 index 00000000..4d2c8798 --- /dev/null +++ b/test_crates/item_relocation/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "item_relocation" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/item_relocation/new/src/lib.rs b/test_crates/item_relocation/new/src/lib.rs new file mode 100644 index 00000000..b89dd7b1 --- /dev/null +++ b/test_crates/item_relocation/new/src/lib.rs @@ -0,0 +1,22 @@ +/// Testing that items exposed via `pub use` aren't falsely flagged as removed +/// when they are relocated. +/// +/// Items here are moved from `mod a` to `mod b`, which is fine because +/// they are only exposed via `pub use` and those paths don't change. +pub mod safe_relocation { + mod a {} + + mod b { + pub struct RelocatedPubUseStruct; + + pub enum RelocatedPubUseEnum {} + + pub fn relocated_pub_use_fn() {} + } + + pub use b::RelocatedPubUseStruct; + + pub use b::RelocatedPubUseEnum; + + pub use b::relocated_pub_use_fn; +} diff --git a/test_crates/item_relocation/old/Cargo.toml b/test_crates/item_relocation/old/Cargo.toml new file mode 100644 index 00000000..4d2c8798 --- /dev/null +++ b/test_crates/item_relocation/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "item_relocation" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/item_relocation/old/src/lib.rs b/test_crates/item_relocation/old/src/lib.rs new file mode 100644 index 00000000..70b0c35b --- /dev/null +++ b/test_crates/item_relocation/old/src/lib.rs @@ -0,0 +1,22 @@ +/// Testing that items exposed via `pub use` aren't falsely flagged as removed +/// when they are relocated. +/// +/// Items here are moved from `mod a` to `mod b`, which is fine because +/// they are only exposed via `pub use` and those paths don't change. +pub mod safe_relocation { + mod a { + pub struct RelocatedPubUseStruct; + + pub enum RelocatedPubUseEnum {} + + pub fn relocated_pub_use_fn() {} + } + + mod b {} + + pub use a::RelocatedPubUseStruct; + + pub use a::RelocatedPubUseEnum; + + pub use a::relocated_pub_use_fn; +} diff --git a/test_crates/non_exhaustive/new/Cargo.toml b/test_crates/non_exhaustive/new/Cargo.toml new file mode 100644 index 00000000..dbce7d56 --- /dev/null +++ b/test_crates/non_exhaustive/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "non_exhaustive" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/src/test_cases/non_exhaustive.rs b/test_crates/non_exhaustive/new/src/lib.rs similarity index 52% rename from test_crates/src/test_cases/non_exhaustive.rs rename to test_crates/non_exhaustive/new/src/lib.rs index 49747cff..6f5b54d0 100644 --- a/test_crates/src/test_cases/non_exhaustive.rs +++ b/test_crates/non_exhaustive/new/src/lib.rs @@ -8,26 +8,12 @@ /// """ /// From: -#[cfg(not(feature = "struct_marked_non_exhaustive"))] -pub struct UnitStruct; - -#[cfg(feature = "struct_marked_non_exhaustive")] #[non_exhaustive] pub struct UnitStruct; -#[cfg(not(feature = "struct_marked_non_exhaustive"))] -pub struct TupleStruct(pub u64); - -#[cfg(feature = "struct_marked_non_exhaustive")] #[non_exhaustive] pub struct TupleStruct(pub u64); -#[cfg(not(feature = "struct_marked_non_exhaustive"))] -pub struct ExternallyConstructibleStruct { - pub foo: u64, -} - -#[cfg(feature = "struct_marked_non_exhaustive")] #[non_exhaustive] pub struct ExternallyConstructibleStruct { pub foo: u64, @@ -35,23 +21,9 @@ pub struct ExternallyConstructibleStruct { // The private field within means this struct cannot be constructed // outside this crate, so #[non_exhaustive] won't change anything here. -#[cfg(not(feature = "struct_marked_non_exhaustive"))] -pub struct NonExternallyConstructibleTupleStruct(u64); - -#[cfg(feature = "struct_marked_non_exhaustive")] #[non_exhaustive] pub struct NonExternallyConstructibleTupleStruct(u64); -#[cfg(not(feature = "struct_marked_non_exhaustive"))] -pub struct NonExternallyConstructibleStruct { - pub foo: u64, - - // This private field means this struct cannot be constructed with a struct literal - // from outside of this crate. - bar: u64, -} - -#[cfg(feature = "struct_marked_non_exhaustive")] #[non_exhaustive] pub struct NonExternallyConstructibleStruct { pub foo: u64, @@ -61,14 +33,6 @@ pub struct NonExternallyConstructibleStruct { bar: u64, } -#[cfg(not(feature = "variant_marked_non_exhaustive"))] -pub enum MyEnum { - UnitVariant, - TupleVariant(u64), - StructVariant { a: u64 }, -} - -#[cfg(feature = "variant_marked_non_exhaustive")] pub enum MyEnum { #[non_exhaustive] UnitVariant, @@ -80,13 +44,6 @@ pub enum MyEnum { StructVariant { a: u64 }, } -#[cfg(not(feature = "enum_marked_non_exhaustive"))] -pub enum SimpleEnum { - Foo, - Bar, -} - -#[cfg(feature = "enum_marked_non_exhaustive")] #[non_exhaustive] pub enum SimpleEnum { Foo, diff --git a/test_crates/non_exhaustive/old/Cargo.toml b/test_crates/non_exhaustive/old/Cargo.toml new file mode 100644 index 00000000..dbce7d56 --- /dev/null +++ b/test_crates/non_exhaustive/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "non_exhaustive" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/non_exhaustive/old/src/lib.rs b/test_crates/non_exhaustive/old/src/lib.rs new file mode 100644 index 00000000..1d1facc8 --- /dev/null +++ b/test_crates/non_exhaustive/old/src/lib.rs @@ -0,0 +1,40 @@ +//! Adding `non_exhaustive` to a struct, enum or enum variant is breaking because +//! those items cannot be constructed outside of their defining crate: +//! +//! """ +/// Non-exhaustive types cannot be constructed outside of the defining crate: +/// - Non-exhaustive variants (struct or enum variant) cannot be constructed with +/// a StructExpression (including with functional update syntax). +/// """ +/// From: + +pub struct UnitStruct; + +pub struct TupleStruct(pub u64); + +pub struct ExternallyConstructibleStruct { + pub foo: u64, +} + +// The private field within means this struct cannot be constructed +// outside this crate, so #[non_exhaustive] won't change anything here. +pub struct NonExternallyConstructibleTupleStruct(u64); + +pub struct NonExternallyConstructibleStruct { + pub foo: u64, + + // This private field means this struct cannot be constructed with a struct literal + // from outside of this crate. + bar: u64, +} + +pub enum MyEnum { + UnitVariant, + TupleVariant(u64), + StructVariant { a: u64 }, +} + +pub enum SimpleEnum { + Foo, + Bar, +} diff --git a/test_crates/parameter_count_changed/new/Cargo.toml b/test_crates/parameter_count_changed/new/Cargo.toml new file mode 100644 index 00000000..95a5f0ba --- /dev/null +++ b/test_crates/parameter_count_changed/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "parameter_count_changed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/parameter_count_changed/new/src/lib.rs b/test_crates/parameter_count_changed/new/src/lib.rs new file mode 100644 index 00000000..a8ba452a --- /dev/null +++ b/test_crates/parameter_count_changed/new/src/lib.rs @@ -0,0 +1,57 @@ +pub fn function_with_a_parameter_added(_: (), _: ()) {} + +pub fn function_with_parameters_removed() {} + +fn private_function_with_a_parameter_added(_: (), _: ()) {} + +pub struct StructWithMethods {} + +impl StructWithMethods { + pub fn associated_function_with_a_parameter_added(_: ()) {} + + pub fn method_with_a_parameter_added(&self, _: ()) {} + + pub fn method_with_a_parameter_removed(&self, _: (), _: ()) {} +} + +pub trait Bar { + fn moved_trait_provided_method(&self, _: (), _: ()) {} + + fn moved_trait_provided_method_with_unchanged_signature(&self, _: ()) {} + + fn moved_method(&self); + + fn moved_method_with_unchanged_signature(&self, _: ()); +} + +impl Bar for StructWithMethods { + fn moved_method(&self) {} + + fn moved_method_with_unchanged_signature(&self, _: ()) {} +} + +struct PrivateStruct {} + +impl PrivateStruct { + pub fn method_with_a_parameter_added(_: ()) {} +} + +// Ensure there are no false-positives in cases with +// multiple methods with the same name but different signatures. +// Here, the struct defines an inherent method `duplicate()`, +// and also has `::duplicate()` available with a different signature. +// +// In https://github.com/obi1kenobi/cargo-semver-checks/issues/193 this sort of setup +// matched the `method_parameter_count_changed` lint and was a false-positive. +// It should obviously not match since no change happened. +pub struct DuplicateMethodNames {} + +impl DuplicateMethodNames { + pub fn duplicate(&self) {} +} + +trait DuplicateMethodTrait { + fn duplicate(&self, _: ()) {} +} + +impl DuplicateMethodTrait for DuplicateMethodNames {} diff --git a/test_crates/parameter_count_changed/old/Cargo.toml b/test_crates/parameter_count_changed/old/Cargo.toml new file mode 100644 index 00000000..95a5f0ba --- /dev/null +++ b/test_crates/parameter_count_changed/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "parameter_count_changed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/parameter_count_changed/old/src/lib.rs b/test_crates/parameter_count_changed/old/src/lib.rs new file mode 100644 index 00000000..c0449a8e --- /dev/null +++ b/test_crates/parameter_count_changed/old/src/lib.rs @@ -0,0 +1,49 @@ +pub fn function_with_a_parameter_added(_: ()) {} + +pub fn function_with_parameters_removed(_: (), _: ()) {} + +fn private_function_with_a_parameter_added(_: ()) {} + +pub struct StructWithMethods {} + +impl StructWithMethods { + pub fn associated_function_with_a_parameter_added() {} + + pub fn method_with_a_parameter_added(&self) {} + + pub fn method_with_a_parameter_removed(&self, _: (), _: (), _: ()) {} + + pub fn moved_trait_provided_method(&self, _: ()) {} + + pub fn moved_trait_provided_method_with_unchanged_signature(&self, _: ()) {} + + pub fn moved_method(&self, _: ()) {} + + pub fn moved_method_with_unchanged_signature(&self, _: ()) {} +} + +struct PrivateStruct {} + +impl PrivateStruct { + pub fn method_with_a_parameter_added() {} +} + +// Ensure there are no false-positives in cases with +// multiple methods with the same name but different signatures. +// Here, the struct defines an inherent method `duplicate()`, +// and also has `::duplicate()` available with a different signature. +// +// In https://github.com/obi1kenobi/cargo-semver-checks/issues/193 this sort of setup +// matched the `method_parameter_count_changed` lint and was a false-positive. +// It should obviously not match since no change happened. +pub struct DuplicateMethodNames {} + +impl DuplicateMethodNames { + pub fn duplicate(&self) {} +} + +trait DuplicateMethodTrait { + fn duplicate(&self, _: ()) {} +} + +impl DuplicateMethodTrait for DuplicateMethodNames {} diff --git a/test_crates/pub_use_handling/new/Cargo.toml b/test_crates/pub_use_handling/new/Cargo.toml new file mode 100644 index 00000000..f506824f --- /dev/null +++ b/test_crates/pub_use_handling/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "pub_use_handling" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/src/import_handling/inner.rs b/test_crates/pub_use_handling/new/src/inner.rs similarity index 100% rename from test_crates/src/import_handling/inner.rs rename to test_crates/pub_use_handling/new/src/inner.rs diff --git a/test_crates/src/import_handling/mod.rs b/test_crates/pub_use_handling/new/src/lib.rs similarity index 66% rename from test_crates/src/import_handling/mod.rs rename to test_crates/pub_use_handling/new/src/lib.rs index c9f77fd3..c5dcc099 100644 --- a/test_crates/src/import_handling/mod.rs +++ b/test_crates/pub_use_handling/new/src/lib.rs @@ -1,4 +1,2 @@ pub mod inner; -pub mod item_relocation; - pub use inner::CheckPubUseHandling; diff --git a/test_crates/pub_use_handling/old/Cargo.toml b/test_crates/pub_use_handling/old/Cargo.toml new file mode 100644 index 00000000..f506824f --- /dev/null +++ b/test_crates/pub_use_handling/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "pub_use_handling" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/pub_use_handling/old/src/inner.rs b/test_crates/pub_use_handling/old/src/inner.rs new file mode 100644 index 00000000..ffe6a94f --- /dev/null +++ b/test_crates/pub_use_handling/old/src/inner.rs @@ -0,0 +1 @@ +pub struct CheckPubUseHandling; diff --git a/test_crates/pub_use_handling/old/src/lib.rs b/test_crates/pub_use_handling/old/src/lib.rs new file mode 100644 index 00000000..c5dcc099 --- /dev/null +++ b/test_crates/pub_use_handling/old/src/lib.rs @@ -0,0 +1,2 @@ +pub mod inner; +pub use inner::CheckPubUseHandling; diff --git a/test_crates/sized_impl_removed/new/Cargo.toml b/test_crates/sized_impl_removed/new/Cargo.toml new file mode 100644 index 00000000..f0fbbf6b --- /dev/null +++ b/test_crates/sized_impl_removed/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "sized_impl_removed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/sized_impl_removed/new/src/lib.rs b/test_crates/sized_impl_removed/new/src/lib.rs new file mode 100644 index 00000000..6bb1f8c1 --- /dev/null +++ b/test_crates/sized_impl_removed/new/src/lib.rs @@ -0,0 +1,4 @@ +pub struct SizedStruct { + // Slices are not Sized. + bar: [usize], +} diff --git a/test_crates/sized_impl_removed/old/Cargo.toml b/test_crates/sized_impl_removed/old/Cargo.toml new file mode 100644 index 00000000..f0fbbf6b --- /dev/null +++ b/test_crates/sized_impl_removed/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "sized_impl_removed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/sized_impl_removed/old/src/lib.rs b/test_crates/sized_impl_removed/old/src/lib.rs new file mode 100644 index 00000000..530af361 --- /dev/null +++ b/test_crates/sized_impl_removed/old/src/lib.rs @@ -0,0 +1,3 @@ +pub struct SizedStruct { + bar: [usize; 1], +} diff --git a/test_crates/src/import_handling/item_relocation.rs b/test_crates/src/import_handling/item_relocation.rs deleted file mode 100644 index 5d728539..00000000 --- a/test_crates/src/import_handling/item_relocation.rs +++ /dev/null @@ -1,46 +0,0 @@ -/// Testing that items exposed via `pub use` aren't falsely flagged as removed -/// when they are relocated. -/// -/// Items here are moved from `mod a` to `mod b`, which is fine because -/// they are only exposed via `pub use` and those paths don't change. -pub mod safe_relocation { - mod a { - #[cfg(not(feature = "struct_missing"))] - pub struct RelocatedPubUseStruct; - - #[cfg(not(feature = "enum_missing"))] - pub enum RelocatedPubUseEnum {} - - #[cfg(not(feature = "function_missing"))] - pub fn relocated_pub_use_fn() {} - } - - mod b { - #[cfg(feature = "struct_missing")] - pub struct RelocatedPubUseStruct; - - #[cfg(feature = "enum_missing")] - pub enum RelocatedPubUseEnum {} - - #[cfg(feature = "function_missing")] - pub fn relocated_pub_use_fn() {} - } - - #[cfg(not(feature = "struct_missing"))] - pub use a::RelocatedPubUseStruct; - - #[cfg(feature = "struct_missing")] - pub use b::RelocatedPubUseStruct; - - #[cfg(not(feature = "enum_missing"))] - pub use a::RelocatedPubUseEnum; - - #[cfg(feature = "enum_missing")] - pub use b::RelocatedPubUseEnum; - - #[cfg(not(feature = "function_missing"))] - pub use a::relocated_pub_use_fn; - - #[cfg(feature = "function_missing")] - pub use b::relocated_pub_use_fn; -} diff --git a/test_crates/src/main.rs b/test_crates/src/main.rs deleted file mode 100644 index be95de5c..00000000 --- a/test_crates/src/main.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![allow(dead_code)] - -pub mod import_handling; -pub mod test_cases; - -pub use import_handling::CheckPubUseHandling; - -fn main() {} diff --git a/test_crates/src/test_cases/derive_trait_impl_removed.rs b/test_crates/src/test_cases/derive_trait_impl_removed.rs deleted file mode 100644 index 61cd64d0..00000000 --- a/test_crates/src/test_cases/derive_trait_impl_removed.rs +++ /dev/null @@ -1,41 +0,0 @@ -#[cfg(not(feature = "derive_trait_impl_removed"))] -#[derive(Debug, Clone)] -pub struct DebugFoo; - -#[cfg(feature = "derive_trait_impl_removed")] -#[derive(Clone)] -pub struct DebugFoo; - -#[cfg(not(feature = "derive_trait_impl_removed"))] -#[derive(Clone, Copy)] -pub enum CopyBar { - Var -} - -#[cfg(feature = "derive_trait_impl_removed")] -#[derive(Clone)] -pub enum CopyBar { - Var -} - -#[cfg(not(feature = "derive_trait_impl_removed"))] -#[derive(PartialEq, Eq)] -pub struct EqFoo; - -#[cfg(feature = "derive_trait_impl_removed")] -#[derive(PartialEq)] -pub struct EqFoo; - -// The following is not a semver issue: it's not breaking to replace -// a derived impl with a hand-impl of the same trait. - -#[cfg(not(feature = "derive_trait_impl_removed"))] -#[derive(PartialEq, Eq)] -pub struct ManualEqFoo; - -#[cfg(feature = "derive_trait_impl_removed")] -#[derive(PartialEq)] -pub struct ManualEqFoo; - -#[cfg(feature = "derive_trait_impl_removed")] -impl Eq for ManualEqFoo {} diff --git a/test_crates/src/test_cases/enum_repr_c_removed.rs b/test_crates/src/test_cases/enum_repr_c_removed.rs deleted file mode 100644 index afb0542a..00000000 --- a/test_crates/src/test_cases/enum_repr_c_removed.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[cfg(not(feature = "enum_repr_c_removed"))] -#[repr(C)] -pub enum Foo { - Bar, -} - -#[cfg(feature = "enum_repr_c_removed")] -pub enum Foo { - Bar, -} diff --git a/test_crates/src/test_cases/enum_repr_int_changed.rs b/test_crates/src/test_cases/enum_repr_int_changed.rs deleted file mode 100644 index e377fb0e..00000000 --- a/test_crates/src/test_cases/enum_repr_int_changed.rs +++ /dev/null @@ -1,111 +0,0 @@ -#[cfg(not(feature = "enum_repr_int_changed"))] -#[repr(u8)] -pub enum U8ToU16Enum { - Bar, - Baz, -} - -#[cfg(feature = "enum_repr_int_changed")] -#[repr(u16)] -pub enum U8ToU16Enum { - Bar, - Baz, -} - -#[cfg(not(feature = "enum_repr_int_changed"))] -#[repr(i32)] -pub enum I32ToI8Enum { - Bar, - Baz, -} - -#[cfg(feature = "enum_repr_int_changed")] -#[repr(i8)] -pub enum I32ToI8Enum { - Bar, - Baz, -} - -#[cfg(not(feature = "enum_repr_int_changed"))] -#[repr(i32)] -pub enum I32ToU32Enum { - Bar, - Baz, -} - -#[cfg(feature = "enum_repr_int_changed")] -#[repr(u32)] -pub enum I32ToU32Enum { - Bar, - Baz, -} - -#[cfg(not(feature = "enum_repr_int_changed"))] -#[repr(isize)] -pub enum IsizeToUsizeEnum { - Bar, - Baz, -} - -#[cfg(feature = "enum_repr_int_changed")] -#[repr(usize)] -pub enum IsizeToUsizeEnum { - Bar, - Baz, -} - -// The following enums have *removals* of repr(i*) and repr(u*), -// not changes to another repr(i*) or repr(u*). -// They should not be reported by this rule, because they have their own rule. - -#[cfg(not(feature = "enum_repr_int_changed"))] -#[repr(u8)] -pub enum U8Enum { - Bar, - Baz, -} - -#[cfg(feature = "enum_repr_int_changed")] -pub enum U8Enum { - Bar, - Baz, -} - -#[cfg(not(feature = "enum_repr_int_changed"))] -#[repr(i32)] -pub enum I32Enum { - Bar, - Baz, -} - -#[cfg(feature = "enum_repr_int_changed")] -pub enum I32Enum { - Bar, - Baz, -} - -#[cfg(not(feature = "enum_repr_int_changed"))] -#[repr(isize)] -pub enum IsizeEnum { - Bar, - Baz, -} - -#[cfg(feature = "enum_repr_int_changed")] -pub enum IsizeEnum { - Bar, - Baz, -} - -#[cfg(not(feature = "enum_repr_int_changed"))] -#[repr(usize)] -pub enum UsizeEnum { - Bar, - Baz, -} - -#[cfg(feature = "enum_repr_int_changed")] -pub enum UsizeEnum { - Bar, - Baz, -} diff --git a/test_crates/src/test_cases/enum_repr_int_removed.rs b/test_crates/src/test_cases/enum_repr_int_removed.rs deleted file mode 100644 index d2297f0d..00000000 --- a/test_crates/src/test_cases/enum_repr_int_removed.rs +++ /dev/null @@ -1,51 +0,0 @@ -#[cfg(not(feature = "enum_repr_int_removed"))] -#[repr(u8)] -pub enum U8Enum { - Bar, - Baz, -} - -#[cfg(feature = "enum_repr_int_removed")] -pub enum U8Enum { - Bar, - Baz, -} - -#[cfg(not(feature = "enum_repr_int_removed"))] -#[repr(i32)] -pub enum I32Enum { - Bar, - Baz, -} - -#[cfg(feature = "enum_repr_int_removed")] -pub enum I32Enum { - Bar, - Baz, -} - -#[cfg(not(feature = "enum_repr_int_removed"))] -#[repr(isize)] -pub enum IsizeEnum { - Bar, - Baz, -} - -#[cfg(feature = "enum_repr_int_removed")] -pub enum IsizeEnum { - Bar, - Baz, -} - -#[cfg(not(feature = "enum_repr_int_removed"))] -#[repr(usize)] -pub enum UsizeEnum { - Bar, - Baz, -} - -#[cfg(feature = "enum_repr_int_removed")] -pub enum UsizeEnum { - Bar, - Baz, -} diff --git a/test_crates/src/test_cases/item_missing.rs b/test_crates/src/test_cases/item_missing.rs deleted file mode 100644 index c01e6e61..00000000 --- a/test_crates/src/test_cases/item_missing.rs +++ /dev/null @@ -1,61 +0,0 @@ -//! Testing: - -#[cfg(not(feature = "struct_missing"))] -pub struct WillBeRemovedStruct; - -#[cfg(not(feature = "enum_missing"))] -pub enum WillBeRemovedEnum {} - -#[cfg(not(feature = "function_missing"))] -pub fn will_be_removed_fn() {} - -// Test that associated function removal: -// - is caught and reported by `inherent_method_missing` -// - is not caught by `function_missing`. -pub struct Foo {} - -impl Foo { - #[cfg(not(feature = "function_missing"))] - #[cfg(not(feature = "inherent_method_missing"))] - pub fn will_be_removed_associated_fn() {} - - #[cfg(not(feature = "inherent_method_missing"))] - pub fn will_be_removed_method(&self) {} - - #[cfg(not(feature = "inherent_method_missing"))] - pub fn moved_trait_provided_method(&self) {} - - #[cfg(not(feature = "inherent_method_missing"))] - pub fn moved_method(&self) {} -} - -pub mod my_pub_mod { - pub struct PubUseRemovedStruct; - - pub enum PubUseRemovedEnum {} - - pub fn pub_use_removed_fn() {} -} - -#[cfg(not(feature = "struct_missing"))] -pub use my_pub_mod::PubUseRemovedStruct; - -#[cfg(not(feature = "enum_missing"))] -pub use my_pub_mod::PubUseRemovedEnum; - -#[cfg(not(feature = "function_missing"))] -pub use my_pub_mod::pub_use_removed_fn; - -// Moving an inherent method to an implemented trait should not be a breaking change, -// both when the method is defined inside the trait and when it's implemented externally. -#[cfg(feature = "inherent_method_missing")] -pub trait Bar { - fn moved_trait_provided_method(&self) {} - - fn moved_method(&self); -} - -#[cfg(feature = "inherent_method_missing")] -impl Bar for Foo { - fn moved_method(&self) {} -} diff --git a/test_crates/src/test_cases/mod.rs b/test_crates/src/test_cases/mod.rs deleted file mode 100644 index c56a2302..00000000 --- a/test_crates/src/test_cases/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -pub mod auto_trait_impl_removed; -pub mod derive_trait_impl_removed; -pub mod enum_repr_c_removed; -pub mod enum_repr_int_changed; -pub mod enum_repr_int_removed; -pub mod enum_variant_added; -pub mod enum_variant_missing; -pub mod enum_struct_variant_field_missing; -pub mod item_missing; -pub mod non_exhaustive; -pub mod parameter_count_changed; -pub mod sized_impl_removed; -pub mod struct_pub_field_missing; -pub mod struct_repr_c_removed; -pub mod struct_repr_transparent_removed; -pub mod unit_struct_changed_kind; diff --git a/test_crates/src/test_cases/parameter_count_changed.rs b/test_crates/src/test_cases/parameter_count_changed.rs deleted file mode 100644 index c9a9ab9c..00000000 --- a/test_crates/src/test_cases/parameter_count_changed.rs +++ /dev/null @@ -1,99 +0,0 @@ -#[cfg(not(feature = "function_parameter_count_changed"))] -pub fn function_with_a_parameter_added(_: ()) {} - -#[cfg(feature = "function_parameter_count_changed")] -pub fn function_with_a_parameter_added(_: (), _: ()) {} - -#[cfg(not(feature = "function_parameter_count_changed"))] -pub fn function_with_parameters_removed(_: (), _: ()) {} - -#[cfg(feature = "function_parameter_count_changed")] -pub fn function_with_parameters_removed() {} - -#[cfg(not(feature = "function_parameter_count_changed"))] -fn private_function_with_a_parameter_added(_: ()) {} - -#[cfg(feature = "function_parameter_count_changed")] -fn private_function_with_a_parameter_added(_: (), _: ()) {} - -pub struct StructWithMethods {} - -impl StructWithMethods { - #[cfg(not(feature = "method_parameter_count_changed"))] - pub fn associated_function_with_a_parameter_added() {} - - #[cfg(feature = "method_parameter_count_changed")] - pub fn associated_function_with_a_parameter_added(_: ()) {} - - #[cfg(not(feature = "method_parameter_count_changed"))] - pub fn method_with_a_parameter_added(&self) {} - - #[cfg(feature = "method_parameter_count_changed")] - pub fn method_with_a_parameter_added(&self, _: ()) {} - - #[cfg(not(feature = "method_parameter_count_changed"))] - pub fn method_with_a_parameter_removed(&self, _: (), _: (), _: ()) {} - - #[cfg(feature = "method_parameter_count_changed")] - pub fn method_with_a_parameter_removed(&self, _: (), _: ()) {} - - #[cfg(not(feature = "method_parameter_count_changed"))] - pub fn moved_trait_provided_method(&self, _: ()) {} - - #[cfg(not(feature = "method_parameter_count_changed"))] - pub fn moved_trait_provided_method_with_unchanged_signature(&self, _: ()) {} - - #[cfg(not(feature = "method_parameter_count_changed"))] - pub fn moved_method(&self, _: ()) {} - - #[cfg(not(feature = "method_parameter_count_changed"))] - pub fn moved_method_with_unchanged_signature(&self, _: ()) {} -} - -#[cfg(feature = "method_parameter_count_changed")] -pub trait Bar { - fn moved_trait_provided_method(&self, _: (), _: ()) {} - - fn moved_trait_provided_method_with_unchanged_signature(&self, _: ()) {} - - fn moved_method(&self); - - fn moved_method_with_unchanged_signature(&self, _: ()); -} - -#[cfg(feature = "method_parameter_count_changed")] -impl Bar for StructWithMethods { - fn moved_method(&self) {} - - fn moved_method_with_unchanged_signature(&self, _: ()) {} -} - -struct PrivateStruct {} - -impl PrivateStruct { - #[cfg(not(feature = "method_parameter_count_changed"))] - pub fn method_with_a_parameter_added() {} - - #[cfg(feature = "method_parameter_count_changed")] - pub fn method_with_a_parameter_added(_: ()) {} -} - -// Ensure there are no false-positives in cases with -// multiple methods with the same name but different signatures. -// Here, the struct defines an inherent method `duplicate()`, -// and also has `::duplicate()` available with a different signature. -// -// In https://github.com/obi1kenobi/cargo-semver-checks/issues/193 this sort of setup -// matched the `method_parameter_count_changed` lint and was a false-positive. -// It should obviously not match since no change happened. -pub struct DuplicateMethodNames {} - -impl DuplicateMethodNames { - pub fn duplicate(&self) {} -} - -trait DuplicateMethodTrait { - fn duplicate(&self, _: ()) {} -} - -impl DuplicateMethodTrait for DuplicateMethodNames {} diff --git a/test_crates/src/test_cases/sized_impl_removed.rs b/test_crates/src/test_cases/sized_impl_removed.rs deleted file mode 100644 index 58652fb6..00000000 --- a/test_crates/src/test_cases/sized_impl_removed.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[cfg(not(feature = "sized_impl_removed"))] -pub struct SizedStruct { - bar: [usize; 1], -} - -#[cfg(feature = "sized_impl_removed")] -pub struct SizedStruct { - // Slices are not Sized. - bar: [usize], -} diff --git a/test_crates/src/test_cases/struct_repr_c_removed.rs b/test_crates/src/test_cases/struct_repr_c_removed.rs deleted file mode 100644 index e57f3b13..00000000 --- a/test_crates/src/test_cases/struct_repr_c_removed.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[cfg(not(feature = "struct_repr_c_removed"))] -#[repr(C)] -pub struct Foo { - pub bar: usize, -} - -#[cfg(feature = "struct_repr_c_removed")] -pub struct Foo { - pub bar: usize, -} diff --git a/test_crates/src/test_cases/struct_repr_transparent_removed.rs b/test_crates/src/test_cases/struct_repr_transparent_removed.rs deleted file mode 100644 index 7d017bb2..00000000 --- a/test_crates/src/test_cases/struct_repr_transparent_removed.rs +++ /dev/null @@ -1,138 +0,0 @@ -#[cfg(not(feature = "struct_repr_transparent_removed"))] -#[repr(transparent)] -pub struct Foo { - pub bar: usize, -} - -#[cfg(feature = "struct_repr_transparent_removed")] -pub struct Foo { - pub bar: usize, -} - -#[cfg(not(feature = "struct_repr_transparent_removed"))] -#[repr(transparent)] -pub struct Bar(pub usize); - -#[cfg(feature = "struct_repr_transparent_removed")] -pub struct Bar(pub usize); - -#[cfg(not(feature = "struct_repr_transparent_removed"))] -#[repr(transparent)] -pub struct WithZeroSizedData { - pub bar: usize, - _marker: std::marker::PhantomData, -} - -#[cfg(feature = "struct_repr_transparent_removed")] -pub struct WithZeroSizedData { - pub bar: usize, - _marker: std::marker::PhantomData, -} - -#[cfg(not(feature = "struct_repr_transparent_removed"))] -#[repr(transparent)] -pub struct TupleWithZeroSizedData(pub usize, core::marker::PhantomData); - -#[cfg(feature = "struct_repr_transparent_removed")] -pub struct TupleWithZeroSizedData(pub usize, core::marker::PhantomData); - -#[cfg(not(feature = "struct_repr_transparent_removed"))] -#[repr(transparent)] -pub struct WithPubZeroSizedData { - pub bar: usize, - pub _marker: std::marker::PhantomData, -} - -#[cfg(feature = "struct_repr_transparent_removed")] -pub struct WithPubZeroSizedData { - pub bar: usize, - pub _marker: std::marker::PhantomData, -} - -#[cfg(not(feature = "struct_repr_transparent_removed"))] -#[repr(transparent)] -pub struct WithSpecificZeroSizedData { - pub bar: usize, - _marker: std::marker::PhantomData<&'static usize>, -} - -#[cfg(feature = "struct_repr_transparent_removed")] -pub struct WithSpecificZeroSizedData { - pub bar: usize, - _marker: std::marker::PhantomData<&'static usize>, -} - -#[cfg(not(feature = "struct_repr_transparent_removed"))] -#[repr(transparent)] -pub struct WithFoo { - pub bar: Foo, - _marker: std::marker::PhantomData<&'static usize>, -} - -#[cfg(feature = "struct_repr_transparent_removed")] -pub struct WithFoo { - pub bar: Foo, - _marker: std::marker::PhantomData<&'static usize>, -} - -#[cfg(not(feature = "struct_repr_transparent_removed"))] -#[repr(transparent)] -pub struct WithRef { - pub bar: &'static usize, - _marker: std::marker::PhantomData<&'static usize>, -} - -#[cfg(feature = "struct_repr_transparent_removed")] -pub struct WithRef { - pub bar: &'static usize, - _marker: std::marker::PhantomData<&'static usize>, -} - -#[cfg(not(feature = "struct_repr_transparent_removed"))] -#[repr(transparent)] -pub struct WithTuple { - pub bar: (usize, i64), - _marker: std::marker::PhantomData<&'static usize>, -} - -#[cfg(feature = "struct_repr_transparent_removed")] -pub struct WithTuple { - pub bar: (usize, i64), - _marker: std::marker::PhantomData<&'static usize>, -} - -#[cfg(not(feature = "struct_repr_transparent_removed"))] -#[repr(transparent)] -pub struct WithGeneric { - pub bar: WithZeroSizedData, - _marker: std::marker::PhantomData<&'static usize>, -} - -#[cfg(feature = "struct_repr_transparent_removed")] -pub struct WithGeneric { - pub bar: WithZeroSizedData, - _marker: std::marker::PhantomData<&'static usize>, -} - -// Per https://doc.rust-lang.org/nomicon/other-reprs.html#reprtransparent -// `repr(transparent)` is only part of the public ABI if the single non-zero-sized field -// within the struct is public. In the following structs, the field is not public, -// so removing `repr(transparent)` is not a breaking change since it was never public ABI. - -#[cfg(not(feature = "struct_repr_transparent_removed"))] -#[repr(transparent)] -pub struct FieldNotPublicSoNotPublicAbi { - pub(crate) bar: usize, -} - -#[cfg(feature = "struct_repr_transparent_removed")] -pub struct FieldNotPublicSoNotPublicAbi { - pub(crate) bar: usize, -} - -#[cfg(not(feature = "struct_repr_transparent_removed"))] -#[repr(transparent)] -pub struct TupleFieldNotPublicSoNotPublicAbi(pub(crate) usize); - -#[cfg(feature = "struct_repr_transparent_removed")] -pub struct TupleFieldNotPublicSoNotPublicAbi(pub(crate) usize); diff --git a/test_crates/src/test_cases/unit_struct_changed_kind.rs b/test_crates/src/test_cases/unit_struct_changed_kind.rs deleted file mode 100644 index 6a292f73..00000000 --- a/test_crates/src/test_cases/unit_struct_changed_kind.rs +++ /dev/null @@ -1,13 +0,0 @@ -#[cfg(not(feature = "unit_struct_changed_kind"))] -pub struct UnitStructToPlain; - -#[cfg(feature = "unit_struct_changed_kind")] -pub struct UnitStructToPlain {} - -#[cfg(not(feature = "unit_struct_changed_kind"))] -#[non_exhaustive] -pub struct NonExhaustiveUnitStructToPlain; - -#[cfg(feature = "unit_struct_changed_kind")] -#[non_exhaustive] -pub struct NonExhaustiveUnitStructToPlain {} diff --git a/test_crates/struct_missing/new/Cargo.toml b/test_crates/struct_missing/new/Cargo.toml new file mode 100644 index 00000000..dd5c5f31 --- /dev/null +++ b/test_crates/struct_missing/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "struct_missing" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/struct_missing/new/src/lib.rs b/test_crates/struct_missing/new/src/lib.rs new file mode 100644 index 00000000..8cc148bc --- /dev/null +++ b/test_crates/struct_missing/new/src/lib.rs @@ -0,0 +1,3 @@ +pub mod my_pub_mod { + pub struct PubUseRemovedStruct; +} diff --git a/test_crates/struct_missing/old/Cargo.toml b/test_crates/struct_missing/old/Cargo.toml new file mode 100644 index 00000000..dd5c5f31 --- /dev/null +++ b/test_crates/struct_missing/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "struct_missing" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/struct_missing/old/src/lib.rs b/test_crates/struct_missing/old/src/lib.rs new file mode 100644 index 00000000..143b8388 --- /dev/null +++ b/test_crates/struct_missing/old/src/lib.rs @@ -0,0 +1,7 @@ +pub struct WillBeRemovedStruct; + +pub mod my_pub_mod { + pub struct PubUseRemovedStruct; +} + +pub use my_pub_mod::PubUseRemovedStruct; diff --git a/test_crates/struct_pub_field_missing/new/Cargo.toml b/test_crates/struct_pub_field_missing/new/Cargo.toml new file mode 100644 index 00000000..59bf1a49 --- /dev/null +++ b/test_crates/struct_pub_field_missing/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "struct_pub_field_missing" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/struct_pub_field_missing/new/src/lib.rs b/test_crates/struct_pub_field_missing/new/src/lib.rs new file mode 100644 index 00000000..cc348309 --- /dev/null +++ b/test_crates/struct_pub_field_missing/new/src/lib.rs @@ -0,0 +1,3 @@ +pub struct FieldWillBeRemoved { + pub foo: usize, +} diff --git a/test_crates/struct_pub_field_missing/old/Cargo.toml b/test_crates/struct_pub_field_missing/old/Cargo.toml new file mode 100644 index 00000000..59bf1a49 --- /dev/null +++ b/test_crates/struct_pub_field_missing/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "struct_pub_field_missing" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/src/test_cases/struct_pub_field_missing.rs b/test_crates/struct_pub_field_missing/old/src/lib.rs similarity index 80% rename from test_crates/src/test_cases/struct_pub_field_missing.rs rename to test_crates/struct_pub_field_missing/old/src/lib.rs index ce3ba1ac..c0afddfa 100644 --- a/test_crates/src/test_cases/struct_pub_field_missing.rs +++ b/test_crates/struct_pub_field_missing/old/src/lib.rs @@ -2,14 +2,12 @@ pub struct FieldWillBeRemoved { pub foo: usize, /// Testing: - #[cfg(not(feature = "struct_pub_field_missing"))] pub bar: usize, } /// This struct should not be reported by the `struct_pub_field_missing` rule: /// it will be removed altogether, so the correct rule to catch it is /// the `struct_missing` rule and not the rule for missing fields. -#[cfg(not(feature = "struct_pub_field_missing"))] pub struct StructRemoved { pub foo: usize, } diff --git a/test_crates/struct_repr_c_removed/new/Cargo.toml b/test_crates/struct_repr_c_removed/new/Cargo.toml new file mode 100644 index 00000000..ab54c21c --- /dev/null +++ b/test_crates/struct_repr_c_removed/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "struct_repr_c_removed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/struct_repr_c_removed/new/src/lib.rs b/test_crates/struct_repr_c_removed/new/src/lib.rs new file mode 100644 index 00000000..ff789f9a --- /dev/null +++ b/test_crates/struct_repr_c_removed/new/src/lib.rs @@ -0,0 +1,3 @@ +pub struct Foo { + pub bar: usize, +} diff --git a/test_crates/struct_repr_c_removed/old/Cargo.toml b/test_crates/struct_repr_c_removed/old/Cargo.toml new file mode 100644 index 00000000..ab54c21c --- /dev/null +++ b/test_crates/struct_repr_c_removed/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "struct_repr_c_removed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/struct_repr_c_removed/old/src/lib.rs b/test_crates/struct_repr_c_removed/old/src/lib.rs new file mode 100644 index 00000000..2fe70e93 --- /dev/null +++ b/test_crates/struct_repr_c_removed/old/src/lib.rs @@ -0,0 +1,4 @@ +#[repr(C)] +pub struct Foo { + pub bar: usize, +} diff --git a/test_crates/struct_repr_transparent_removed/new/Cargo.toml b/test_crates/struct_repr_transparent_removed/new/Cargo.toml new file mode 100644 index 00000000..2a195e55 --- /dev/null +++ b/test_crates/struct_repr_transparent_removed/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "struct_repr_transparent_removed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/struct_repr_transparent_removed/new/src/lib.rs b/test_crates/struct_repr_transparent_removed/new/src/lib.rs new file mode 100644 index 00000000..1129d346 --- /dev/null +++ b/test_crates/struct_repr_transparent_removed/new/src/lib.rs @@ -0,0 +1,48 @@ +pub struct Foo { + pub bar: usize, +} + +pub struct Bar(pub usize); + +pub struct WithZeroSizedData { + pub bar: usize, + _marker: std::marker::PhantomData, +} + +pub struct TupleWithZeroSizedData(pub usize, core::marker::PhantomData); + +pub struct WithPubZeroSizedData { + pub bar: usize, + pub _marker: std::marker::PhantomData, +} + +pub struct WithSpecificZeroSizedData { + pub bar: usize, + _marker: std::marker::PhantomData<&'static usize>, +} + +pub struct WithFoo { + pub bar: Foo, + _marker: std::marker::PhantomData<&'static usize>, +} + +pub struct WithRef { + pub bar: &'static usize, + _marker: std::marker::PhantomData<&'static usize>, +} + +pub struct WithTuple { + pub bar: (usize, i64), + _marker: std::marker::PhantomData<&'static usize>, +} + +pub struct WithGeneric { + pub bar: WithZeroSizedData, + _marker: std::marker::PhantomData<&'static usize>, +} + +pub struct FieldNotPublicSoNotPublicAbi { + pub(crate) bar: usize, +} + +pub struct TupleFieldNotPublicSoNotPublicAbi(pub(crate) usize); diff --git a/test_crates/struct_repr_transparent_removed/old/Cargo.toml b/test_crates/struct_repr_transparent_removed/old/Cargo.toml new file mode 100644 index 00000000..2a195e55 --- /dev/null +++ b/test_crates/struct_repr_transparent_removed/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "struct_repr_transparent_removed" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/struct_repr_transparent_removed/old/src/lib.rs b/test_crates/struct_repr_transparent_removed/old/src/lib.rs new file mode 100644 index 00000000..f4590f43 --- /dev/null +++ b/test_crates/struct_repr_transparent_removed/old/src/lib.rs @@ -0,0 +1,65 @@ +#[repr(transparent)] +pub struct Foo { + pub bar: usize, +} + +#[repr(transparent)] +pub struct Bar(pub usize); + +#[repr(transparent)] +pub struct WithZeroSizedData { + pub bar: usize, + _marker: std::marker::PhantomData, +} + +#[repr(transparent)] +pub struct TupleWithZeroSizedData(pub usize, core::marker::PhantomData); + +#[repr(transparent)] +pub struct WithPubZeroSizedData { + pub bar: usize, + pub _marker: std::marker::PhantomData, +} + +#[repr(transparent)] +pub struct WithSpecificZeroSizedData { + pub bar: usize, + _marker: std::marker::PhantomData<&'static usize>, +} + +#[repr(transparent)] +pub struct WithFoo { + pub bar: Foo, + _marker: std::marker::PhantomData<&'static usize>, +} + +#[repr(transparent)] +pub struct WithRef { + pub bar: &'static usize, + _marker: std::marker::PhantomData<&'static usize>, +} + +#[repr(transparent)] +pub struct WithTuple { + pub bar: (usize, i64), + _marker: std::marker::PhantomData<&'static usize>, +} + +#[repr(transparent)] +pub struct WithGeneric { + pub bar: WithZeroSizedData, + _marker: std::marker::PhantomData<&'static usize>, +} + +// Per https://doc.rust-lang.org/nomicon/other-reprs.html#reprtransparent +// `repr(transparent)` is only part of the public ABI if the single non-zero-sized field +// within the struct is public. In the following structs, the field is not public, +// so removing `repr(transparent)` is not a breaking change since it was never public ABI. + +#[repr(transparent)] +pub struct FieldNotPublicSoNotPublicAbi { + pub(crate) bar: usize, +} + +#[repr(transparent)] +pub struct TupleFieldNotPublicSoNotPublicAbi(pub(crate) usize); diff --git a/test_crates/template/new/Cargo.toml b/test_crates/template/new/Cargo.toml new file mode 100644 index 00000000..8374e475 --- /dev/null +++ b/test_crates/template/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "template" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/template/new/src/lib.rs b/test_crates/template/new/src/lib.rs new file mode 100644 index 00000000..e7a11a96 --- /dev/null +++ b/test_crates/template/new/src/lib.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/test_crates/template/old/Cargo.toml b/test_crates/template/old/Cargo.toml new file mode 100644 index 00000000..8374e475 --- /dev/null +++ b/test_crates/template/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "template" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/template/old/src/lib.rs b/test_crates/template/old/src/lib.rs new file mode 100644 index 00000000..e7a11a96 --- /dev/null +++ b/test_crates/template/old/src/lib.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/test_crates/unit_struct_changed_kind/new/Cargo.toml b/test_crates/unit_struct_changed_kind/new/Cargo.toml new file mode 100644 index 00000000..8bdecae9 --- /dev/null +++ b/test_crates/unit_struct_changed_kind/new/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "unit_struct_changed_kind" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/unit_struct_changed_kind/new/src/lib.rs b/test_crates/unit_struct_changed_kind/new/src/lib.rs new file mode 100644 index 00000000..c3b0f96c --- /dev/null +++ b/test_crates/unit_struct_changed_kind/new/src/lib.rs @@ -0,0 +1,4 @@ +pub struct UnitStructToPlain {} + +#[non_exhaustive] +pub struct NonExhaustiveUnitStructToPlain {} diff --git a/test_crates/unit_struct_changed_kind/old/Cargo.toml b/test_crates/unit_struct_changed_kind/old/Cargo.toml new file mode 100644 index 00000000..8bdecae9 --- /dev/null +++ b/test_crates/unit_struct_changed_kind/old/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "unit_struct_changed_kind" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/unit_struct_changed_kind/old/src/lib.rs b/test_crates/unit_struct_changed_kind/old/src/lib.rs new file mode 100644 index 00000000..8c9f23aa --- /dev/null +++ b/test_crates/unit_struct_changed_kind/old/src/lib.rs @@ -0,0 +1,4 @@ +pub struct UnitStructToPlain; + +#[non_exhaustive] +pub struct NonExhaustiveUnitStructToPlain; diff --git a/test_outputs/auto_trait_impl_removed.output.ron b/test_outputs/auto_trait_impl_removed.output.ron index 528751da..577565a5 100644 --- a/test_outputs/auto_trait_impl_removed.output.ron +++ b/test_outputs/auto_trait_impl_removed.output.ron @@ -1,94 +1,86 @@ -[ - { - "name": String("SyncStruct"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("auto_trait_impl_removed"), - String("SyncStruct"), - ]), - "span_filename": String("src/test_cases/auto_trait_impl_removed.rs"), - "span_begin_line": Uint64(15), - "auto_trait": String("Sync"), - "auto_trait_path": List([ - String("core"), - String("marker"), - String("Sync"), - ]), - "visibility_limit": String("public"), - }, - { - "name": String("SendStruct"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("auto_trait_impl_removed"), - String("SendStruct"), - ]), - "span_filename": String("src/test_cases/auto_trait_impl_removed.rs"), - "span_begin_line": Uint64(29), - "auto_trait": String("Send"), - "auto_trait_path": List([ - String("core"), - String("marker"), - String("Send"), - ]), - "visibility_limit": String("public"), - }, - { - "name": String("UnwindSafeStruct"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("auto_trait_impl_removed"), - String("UnwindSafeStruct"), - ]), - "span_filename": String("src/test_cases/auto_trait_impl_removed.rs"), - "span_begin_line": Uint64(41), - "auto_trait": String("UnwindSafe"), - "auto_trait_path": List([ - String("core"), - String("panic"), - String("unwind_safe"), - String("UnwindSafe"), - ]), - "visibility_limit": String("public"), - }, - { - "name": String("RefUnwindSafeStruct"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("auto_trait_impl_removed"), - String("RefUnwindSafeStruct"), - ]), - "span_filename": String("src/test_cases/auto_trait_impl_removed.rs"), - "span_begin_line": Uint64(52), - "auto_trait": String("RefUnwindSafe"), - "auto_trait_path": List([ - String("core"), - String("panic"), - String("unwind_safe"), - String("RefUnwindSafe"), - ]), - "visibility_limit": String("public"), - }, - { - "name": String("UnpinStruct"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("auto_trait_impl_removed"), - String("UnpinStruct"), - ]), - "span_filename": String("src/test_cases/auto_trait_impl_removed.rs"), - "span_begin_line": Uint64(72), - "auto_trait": String("Unpin"), - "auto_trait_path": List([ - String("core"), - String("marker"), - String("Unpin"), - ]), - "visibility_limit": String("public"), - } -] +{ + "./test_crates/auto_trait_impl_removed/": [ + { + "auto_trait": String("Sync"), + "auto_trait_path": List([ + String("core"), + String("marker"), + String("Sync"), + ]), + "name": String("SyncStruct"), + "path": List([ + String("auto_trait_impl_removed"), + String("SyncStruct"), + ]), + "span_begin_line": Uint64(8), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "auto_trait": String("Send"), + "auto_trait_path": List([ + String("core"), + String("marker"), + String("Send"), + ]), + "name": String("SendStruct"), + "path": List([ + String("auto_trait_impl_removed"), + String("SendStruct"), + ]), + "span_begin_line": Uint64(15), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "auto_trait": String("UnwindSafe"), + "auto_trait_path": List([ + String("core"), + String("panic"), + String("unwind_safe"), + String("UnwindSafe"), + ]), + "name": String("UnwindSafeStruct"), + "path": List([ + String("auto_trait_impl_removed"), + String("UnwindSafeStruct"), + ]), + "span_begin_line": Uint64(21), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "auto_trait": String("RefUnwindSafe"), + "auto_trait_path": List([ + String("core"), + String("panic"), + String("unwind_safe"), + String("RefUnwindSafe"), + ]), + "name": String("RefUnwindSafeStruct"), + "path": List([ + String("auto_trait_impl_removed"), + String("RefUnwindSafeStruct"), + ]), + "span_begin_line": Uint64(26), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "auto_trait": String("Unpin"), + "auto_trait_path": List([ + String("core"), + String("marker"), + String("Unpin"), + ]), + "name": String("UnpinStruct"), + "path": List([ + String("auto_trait_impl_removed"), + String("UnpinStruct"), + ]), + "span_begin_line": Uint64(39), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/derive_trait_impl_removed.output.ron b/test_outputs/derive_trait_impl_removed.output.ron index 1b5785eb..fed3962f 100644 --- a/test_outputs/derive_trait_impl_removed.output.ron +++ b/test_outputs/derive_trait_impl_removed.output.ron @@ -1,56 +1,52 @@ -[ - { - "name": String("DebugFoo"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("derive_trait_impl_removed"), - String("DebugFoo"), - ]), - "span_filename": String("src/test_cases/derive_trait_impl_removed.rs"), - "span_begin_line": Uint64(7), - "trait_name": String("Debug"), - "trait_path": List([ - String("core"), - String("fmt"), - String("Debug"), - ]), - "visibility_limit": String("public"), - }, - { - "name": String("CopyBar"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("derive_trait_impl_removed"), - String("CopyBar"), - ]), - "span_filename": String("src/test_cases/derive_trait_impl_removed.rs"), - "span_begin_line": Uint64(17), - "trait_name": String("Copy"), - "trait_path": List([ - String("core"), - String("marker"), - String("Copy"), - ]), - "visibility_limit": String("public"), - }, - { - "name": String("EqFoo"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("derive_trait_impl_removed"), - String("EqFoo"), - ]), - "span_filename": String("src/test_cases/derive_trait_impl_removed.rs"), - "span_begin_line": Uint64(27), - "trait_name": String("Eq"), - "trait_path": List([ - String("core"), - String("cmp"), - String("Eq"), - ]), - "visibility_limit": String("public"), - } -] +{ + "./test_crates/derive_trait_impl_removed/": [ + { + "name": String("DebugFoo"), + "path": List([ + String("derive_trait_impl_removed"), + String("DebugFoo"), + ]), + "span_begin_line": Uint64(2), + "span_filename": String("src/lib.rs"), + "trait_name": String("Debug"), + "trait_path": List([ + String("core"), + String("fmt"), + String("Debug"), + ]), + "visibility_limit": String("public"), + }, + { + "name": String("CopyBar"), + "path": List([ + String("derive_trait_impl_removed"), + String("CopyBar"), + ]), + "span_begin_line": Uint64(5), + "span_filename": String("src/lib.rs"), + "trait_name": String("Copy"), + "trait_path": List([ + String("core"), + String("marker"), + String("Copy"), + ]), + "visibility_limit": String("public"), + }, + { + "name": String("EqFoo"), + "path": List([ + String("derive_trait_impl_removed"), + String("EqFoo"), + ]), + "span_begin_line": Uint64(10), + "span_filename": String("src/lib.rs"), + "trait_name": String("Eq"), + "trait_path": List([ + String("core"), + String("cmp"), + String("Eq"), + ]), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/enum_marked_non_exhaustive.output.ron b/test_outputs/enum_marked_non_exhaustive.output.ron index 519a196f..3b4a1e0f 100644 --- a/test_outputs/enum_marked_non_exhaustive.output.ron +++ b/test_outputs/enum_marked_non_exhaustive.output.ron @@ -1,14 +1,14 @@ -[ - { - "name": String("SimpleEnum"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("non_exhaustive"), - String("SimpleEnum"), - ]), - "span_filename": String("src/test_cases/non_exhaustive.rs"), - "span_begin_line": Uint64(91), - "visibility_limit": String("public"), - }, -] +{ + "./test_crates/non_exhaustive/": [ + { + "name": String("SimpleEnum"), + "path": List([ + String("non_exhaustive"), + String("SimpleEnum"), + ]), + "span_begin_line": Uint64(48), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/enum_missing.output.ron b/test_outputs/enum_missing.output.ron index 5e4ca125..5a94813c 100644 --- a/test_outputs/enum_missing.output.ron +++ b/test_outputs/enum_missing.output.ron @@ -1,26 +1,36 @@ -[ - { - "name": String("WillBeRemovedEnum"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("item_missing"), - String("WillBeRemovedEnum"), - ]), - "visibility_limit": String("public"), - "span_filename": String("src/test_cases/item_missing.rs"), - "span_begin_line": Uint64(7), - }, - { - "name": String("PubUseRemovedEnum"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("item_missing"), - String("PubUseRemovedEnum"), - ]), - "visibility_limit": String("public"), - "span_filename": String("src/test_cases/item_missing.rs"), - "span_begin_line": Uint64(35), - } -] +{ + "./test_crates/enum_missing/": [ + { + "name": String("WillBeRemovedEnum"), + "path": List([ + String("enum_missing"), + String("WillBeRemovedEnum"), + ]), + "span_begin_line": Uint64(1), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "name": String("PubUseRemovedEnum"), + "path": List([ + String("enum_missing"), + String("PubUseRemovedEnum"), + ]), + "span_begin_line": Uint64(4), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], + "./test_crates/enum_variant_missing/": [ + { + "name": String("ShouldNotMatch"), + "path": List([ + String("enum_variant_missing"), + String("ShouldNotMatch"), + ]), + "span_begin_line": Uint64(11), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/enum_repr_c_removed.output.ron b/test_outputs/enum_repr_c_removed.output.ron index 54daa3e0..49ccabe8 100644 --- a/test_outputs/enum_repr_c_removed.output.ron +++ b/test_outputs/enum_repr_c_removed.output.ron @@ -1,14 +1,14 @@ -[ - { - "name": String("Foo"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("enum_repr_c_removed"), - String("Foo"), - ]), - "span_filename": String("src/test_cases/enum_repr_c_removed.rs"), - "span_begin_line": Uint64(8), - "visibility_limit": String("public"), - } -] +{ + "./test_crates/enum_repr_c_removed/": [ + { + "name": String("Foo"), + "path": List([ + String("enum_repr_c_removed"), + String("Foo"), + ]), + "span_begin_line": Uint64(1), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/enum_repr_int_changed.output.ron b/test_outputs/enum_repr_int_changed.output.ron index dd56e094..7a945530 100644 --- a/test_outputs/enum_repr_int_changed.output.ron +++ b/test_outputs/enum_repr_int_changed.output.ron @@ -1,66 +1,60 @@ -[ - { - "name": String("U8ToU16Enum"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("enum_repr_int_changed"), - String("U8ToU16Enum"), - ]), - "span_filename": String("src/test_cases/enum_repr_int_changed.rs"), - "span_begin_line": Uint64(10), - "old_attr": String("#[repr(u8)]"), - "new_attr": List([ - String("#[repr(u16)]"), - ]), - "visibility_limit": String("public"), - }, - { - "name": String("I32ToI8Enum"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("enum_repr_int_changed"), - String("I32ToI8Enum"), - ]), - "span_filename": String("src/test_cases/enum_repr_int_changed.rs"), - "span_begin_line": Uint64(24), - "old_attr": String("#[repr(i32)]"), - "new_attr": List([ - String("#[repr(i8)]"), - ]), - "visibility_limit": String("public"), - }, - { - "name": String("I32ToU32Enum"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("enum_repr_int_changed"), - String("I32ToU32Enum"), - ]), - "span_filename": String("src/test_cases/enum_repr_int_changed.rs"), - "span_begin_line": Uint64(38), - "old_attr": String("#[repr(i32)]"), - "new_attr": List([ - String("#[repr(u32)]"), - ]), - "visibility_limit": String("public"), - }, - { - "name": String("IsizeToUsizeEnum"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("enum_repr_int_changed"), - String("IsizeToUsizeEnum"), - ]), - "span_filename": String("src/test_cases/enum_repr_int_changed.rs"), - "span_begin_line": Uint64(52), - "old_attr": String("#[repr(isize)]"), - "new_attr": List([ - String("#[repr(usize)]"), - ]), - "visibility_limit": String("public"), - } -] +{ + "./test_crates/enum_repr_int_changed/": [ + { + "name": String("U8ToU16Enum"), + "new_attr": List([ + String("#[repr(u16)]"), + ]), + "old_attr": String("#[repr(u8)]"), + "path": List([ + String("enum_repr_int_changed"), + String("U8ToU16Enum"), + ]), + "span_begin_line": Uint64(2), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "name": String("I32ToI8Enum"), + "new_attr": List([ + String("#[repr(i8)]"), + ]), + "old_attr": String("#[repr(i32)]"), + "path": List([ + String("enum_repr_int_changed"), + String("I32ToI8Enum"), + ]), + "span_begin_line": Uint64(8), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "name": String("I32ToU32Enum"), + "new_attr": List([ + String("#[repr(u32)]"), + ]), + "old_attr": String("#[repr(i32)]"), + "path": List([ + String("enum_repr_int_changed"), + String("I32ToU32Enum"), + ]), + "span_begin_line": Uint64(14), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "name": String("IsizeToUsizeEnum"), + "new_attr": List([ + String("#[repr(usize)]"), + ]), + "old_attr": String("#[repr(isize)]"), + "path": List([ + String("enum_repr_int_changed"), + String("IsizeToUsizeEnum"), + ]), + "span_begin_line": Uint64(20), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/enum_repr_int_removed.output.ron b/test_outputs/enum_repr_int_removed.output.ron index 1ad53261..90c9b8bd 100644 --- a/test_outputs/enum_repr_int_removed.output.ron +++ b/test_outputs/enum_repr_int_removed.output.ron @@ -1,50 +1,86 @@ -[ - { - "name": String("U8Enum"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("enum_repr_int_removed"), - String("U8Enum"), - ]), - "span_filename": String("src/test_cases/enum_repr_int_removed.rs"), - "span_begin_line": Uint64(9), - "visibility_limit": String("public"), - }, - { - "name": String("I32Enum"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("enum_repr_int_removed"), - String("I32Enum"), - ]), - "span_filename": String("src/test_cases/enum_repr_int_removed.rs"), - "span_begin_line": Uint64(22), - "visibility_limit": String("public"), - }, - { - "name": String("IsizeEnum"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("enum_repr_int_removed"), - String("IsizeEnum"), - ]), - "span_filename": String("src/test_cases/enum_repr_int_removed.rs"), - "span_begin_line": Uint64(35), - "visibility_limit": String("public"), - }, - { - "name": String("UsizeEnum"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("enum_repr_int_removed"), - String("UsizeEnum"), - ]), - "span_filename": String("src/test_cases/enum_repr_int_removed.rs"), - "span_begin_line": Uint64(48), - "visibility_limit": String("public"), - } -] +{ + "./test_crates/enum_repr_int_changed/": [ + { + "name": String("U8Enum"), + "path": List([ + String("enum_repr_int_changed"), + String("U8Enum"), + ]), + "span_begin_line": Uint64(29), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "name": String("I32Enum"), + "path": List([ + String("enum_repr_int_changed"), + String("I32Enum"), + ]), + "span_begin_line": Uint64(34), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "name": String("IsizeEnum"), + "path": List([ + String("enum_repr_int_changed"), + String("IsizeEnum"), + ]), + "span_begin_line": Uint64(39), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "name": String("UsizeEnum"), + "path": List([ + String("enum_repr_int_changed"), + String("UsizeEnum"), + ]), + "span_begin_line": Uint64(44), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], + "./test_crates/enum_repr_int_removed/": [ + { + "name": String("U8Enum"), + "path": List([ + String("enum_repr_int_removed"), + String("U8Enum"), + ]), + "span_begin_line": Uint64(1), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "name": String("I32Enum"), + "path": List([ + String("enum_repr_int_removed"), + String("I32Enum"), + ]), + "span_begin_line": Uint64(6), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "name": String("IsizeEnum"), + "path": List([ + String("enum_repr_int_removed"), + String("IsizeEnum"), + ]), + "span_begin_line": Uint64(11), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "name": String("UsizeEnum"), + "path": List([ + String("enum_repr_int_removed"), + String("UsizeEnum"), + ]), + "span_begin_line": Uint64(16), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/enum_struct_variant_field_missing.output.ron b/test_outputs/enum_struct_variant_field_missing.output.ron index 5df9901c..d6f32048 100644 --- a/test_outputs/enum_struct_variant_field_missing.output.ron +++ b/test_outputs/enum_struct_variant_field_missing.output.ron @@ -1,15 +1,15 @@ -[ - { - "enum_name": String("Enum"), - "variant_name": String("FieldWillBeMissing"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("enum_struct_variant_field_missing"), - String("Enum"), - ]), - "field_name": String("bar"), - "span_filename": String("src/test_cases/enum_struct_variant_field_missing.rs"), - "span_begin_line": Uint64(7), - } -] +{ + "./test_crates/enum_struct_variant_field_missing/": [ + { + "enum_name": String("Enum"), + "field_name": String("bar"), + "path": List([ + String("enum_struct_variant_field_missing"), + String("Enum"), + ]), + "span_begin_line": Uint64(6), + "span_filename": String("src/lib.rs"), + "variant_name": String("FieldWillBeMissing"), + }, + ], +} diff --git a/test_outputs/enum_variant_added.output.ron b/test_outputs/enum_variant_added.output.ron index 73975976..0408dd3b 100644 --- a/test_outputs/enum_variant_added.output.ron +++ b/test_outputs/enum_variant_added.output.ron @@ -1,15 +1,15 @@ -[ - { - "enum_name": String("EnumWithNewVariant"), - "variant_name": String("NewVariant"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("enum_variant_added"), - String("EnumWithNewVariant"), - ]), - "visibility_limit": String("public"), - "span_filename": String("src/test_cases/enum_variant_added.rs"), - "span_begin_line": Uint64(5), - } -] +{ + "./test_crates/enum_variant_added/": [ + { + "enum_name": String("EnumWithNewVariant"), + "path": List([ + String("enum_variant_added"), + String("EnumWithNewVariant"), + ]), + "span_begin_line": Uint64(4), + "span_filename": String("src/lib.rs"), + "variant_name": String("NewVariant"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/enum_variant_missing.output.ron b/test_outputs/enum_variant_missing.output.ron index a963d4eb..066b67f6 100644 --- a/test_outputs/enum_variant_missing.output.ron +++ b/test_outputs/enum_variant_missing.output.ron @@ -1,15 +1,28 @@ -[ - { - "enum_name": String("VariantWillBeRemoved"), - "variant_name": String("Bar"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("enum_variant_missing"), - String("VariantWillBeRemoved"), - ]), - "visibility_limit": String("public"), - "span_filename": String("src/test_cases/enum_variant_missing.rs"), - "span_begin_line": Uint64(6), - } -] +{ + "./test_crates/enum_struct_variant_field_missing/": [ + { + "enum_name": String("IgnoredEnum"), + "path": List([ + String("enum_struct_variant_field_missing"), + String("IgnoredEnum"), + ]), + "span_begin_line": Uint64(14), + "span_filename": String("src/lib.rs"), + "variant_name": String("StructVariantWillBeMissing"), + "visibility_limit": String("public"), + }, + ], + "./test_crates/enum_variant_missing/": [ + { + "enum_name": String("VariantWillBeRemoved"), + "path": List([ + String("enum_variant_missing"), + String("VariantWillBeRemoved"), + ]), + "span_begin_line": Uint64(5), + "span_filename": String("src/lib.rs"), + "variant_name": String("Bar"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/function_missing.output.ron b/test_outputs/function_missing.output.ron index 2f2e7a2c..000306ac 100644 --- a/test_outputs/function_missing.output.ron +++ b/test_outputs/function_missing.output.ron @@ -1,26 +1,24 @@ -[ - { - "name": String("will_be_removed_fn"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("item_missing"), - String("will_be_removed_fn"), - ]), - "visibility_limit": String("public"), - "span_filename": String("src/test_cases/item_missing.rs"), - "span_begin_line": Uint64(10), - }, - { - "name": String("pub_use_removed_fn"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("item_missing"), - String("pub_use_removed_fn"), - ]), - "visibility_limit": String("public"), - "span_filename": String("src/test_cases/item_missing.rs"), - "span_begin_line": Uint64(37), - } -] +{ + "./test_crates/function_missing/": [ + { + "name": String("will_be_removed_fn"), + "path": List([ + String("function_missing"), + String("will_be_removed_fn"), + ]), + "span_begin_line": Uint64(1), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "name": String("pub_use_removed_fn"), + "path": List([ + String("function_missing"), + String("pub_use_removed_fn"), + ]), + "span_begin_line": Uint64(4), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/function_parameter_count_changed.output.ron b/test_outputs/function_parameter_count_changed.output.ron index 7796c8de..aed93c88 100644 --- a/test_outputs/function_parameter_count_changed.output.ron +++ b/test_outputs/function_parameter_count_changed.output.ron @@ -1,30 +1,28 @@ -[ - { - "current_parameter_count": Uint64(2), - "name": String("function_with_a_parameter_added"), - "old_parameter_count": Uint64(1), - "path": List([ - String("test_crates"), - String("test_cases"), - String("parameter_count_changed"), - String("function_with_a_parameter_added") - ]), - "span_begin_line": Uint64(5), - "span_filename": String("src/test_cases/parameter_count_changed.rs"), - "visibility_limit": String("public") - }, - { - "current_parameter_count": Uint64(0), - "name": String("function_with_parameters_removed"), - "old_parameter_count": Uint64(2), - "path": List([ - String("test_crates"), - String("test_cases"), - String("parameter_count_changed"), - String("function_with_parameters_removed") - ]), - "span_begin_line": Uint64(11), - "span_filename": String("src/test_cases/parameter_count_changed.rs"), - "visibility_limit": String("public") - } -] +{ + "./test_crates/parameter_count_changed/": [ + { + "current_parameter_count": Uint64(2), + "name": String("function_with_a_parameter_added"), + "old_parameter_count": Uint64(1), + "path": List([ + String("parameter_count_changed"), + String("function_with_a_parameter_added"), + ]), + "span_begin_line": Uint64(1), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "current_parameter_count": Uint64(0), + "name": String("function_with_parameters_removed"), + "old_parameter_count": Uint64(2), + "path": List([ + String("parameter_count_changed"), + String("function_with_parameters_removed"), + ]), + "span_begin_line": Uint64(3), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/inherent_method_missing.output.ron b/test_outputs/inherent_method_missing.output.ron index 9556cb5c..20b82d77 100644 --- a/test_outputs/inherent_method_missing.output.ron +++ b/test_outputs/inherent_method_missing.output.ron @@ -1,30 +1,28 @@ -[ - { - "name": String("Foo"), - "method_name": String("will_be_removed_associated_fn"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("item_missing"), - String("Foo"), - ]), - "visibility_limit": String("public"), - "method_visibility": String("public"), - "span_filename": String("src/test_cases/item_missing.rs"), - "span_begin_line": Uint64(20), - }, - { - "name": String("Foo"), - "method_name": String("will_be_removed_method"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("item_missing"), - String("Foo"), - ]), - "visibility_limit": String("public"), - "method_visibility": String("public"), - "span_filename": String("src/test_cases/item_missing.rs"), - "span_begin_line": Uint64(23), - } -] +{ + "./test_crates/inherent_method_missing/": [ + { + "method_name": String("will_be_removed_associated_fn"), + "method_visibility": String("public"), + "name": String("Foo"), + "path": List([ + String("inherent_method_missing"), + String("Foo"), + ]), + "span_begin_line": Uint64(7), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "method_name": String("will_be_removed_method"), + "method_visibility": String("public"), + "name": String("Foo"), + "path": List([ + String("inherent_method_missing"), + String("Foo"), + ]), + "span_begin_line": Uint64(9), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/method_parameter_count_changed.output.ron b/test_outputs/method_parameter_count_changed.output.ron index 04be4eeb..6ec0ad47 100644 --- a/test_outputs/method_parameter_count_changed.output.ron +++ b/test_outputs/method_parameter_count_changed.output.ron @@ -1,92 +1,148 @@ -[ - { - "current_parameter_count": List([Uint64(1)]), - "method_name": String("associated_function_with_a_parameter_added"), - "method_visibility": String("public"), - "name": String("StructWithMethods"), - "non_matching_span_begin_line": List([Uint64(26)]), - "non_matching_span_filename": List([String("src/test_cases/parameter_count_changed.rs")]), - "old_parameter_count": Uint64(0), - "path": List([ - String("test_crates"), - String("test_cases"), - String("parameter_count_changed"), - String("StructWithMethods") - ]), - "span_begin_line": Uint64(23), - "span_filename": String("src/test_cases/parameter_count_changed.rs"), - "visibility_limit": String("public") - }, - { - "current_parameter_count": List([Uint64(2)]), - "method_name": String("method_with_a_parameter_added"), - "method_visibility": String("public"), - "name": String("StructWithMethods"), - "non_matching_span_begin_line": List([Uint64(32)]), - "non_matching_span_filename": List([String("src/test_cases/parameter_count_changed.rs")]), - "old_parameter_count": Uint64(1), - "path": List([ - String("test_crates"), - String("test_cases"), - String("parameter_count_changed"), - String("StructWithMethods") - ]), - "span_begin_line": Uint64(29), - "span_filename": String("src/test_cases/parameter_count_changed.rs"), - "visibility_limit": String("public") - }, - { - "current_parameter_count": List([Uint64(3)]), - "method_name": String("method_with_a_parameter_removed"), - "method_visibility": String("public"), - "name": String("StructWithMethods"), - "non_matching_span_begin_line": List([Uint64(38)]), - "non_matching_span_filename": List([String("src/test_cases/parameter_count_changed.rs")]), - "old_parameter_count": Uint64(4), - "path": List([ - String("test_crates"), - String("test_cases"), - String("parameter_count_changed"), - String("StructWithMethods") - ]), - "span_begin_line": Uint64(35), - "span_filename": String("src/test_cases/parameter_count_changed.rs"), - "visibility_limit": String("public") - }, - { - "current_parameter_count": List([Uint64(3)]), - "method_name": String("moved_trait_provided_method"), - "method_visibility": String("public"), - "name": String("StructWithMethods"), - "non_matching_span_begin_line": List([Uint64(55)]), - "non_matching_span_filename": List([String("src/test_cases/parameter_count_changed.rs")]), - "old_parameter_count": Uint64(2), - "path": List([ - String("test_crates"), - String("test_cases"), - String("parameter_count_changed"), - String("StructWithMethods") - ]), - "span_begin_line": Uint64(41), - "span_filename": String("src/test_cases/parameter_count_changed.rs"), - "visibility_limit": String("public") - }, - { - "current_parameter_count": List([Uint64(1)]), - "method_name": String("moved_method"), - "method_visibility": String("public"), - "name": String("StructWithMethods"), - "non_matching_span_begin_line": List([Uint64(66)]), - "non_matching_span_filename": List([String("src/test_cases/parameter_count_changed.rs")]), - "old_parameter_count": Uint64(2), - "path": List([ - String("test_crates"), - String("test_cases"), - String("parameter_count_changed"), - String("StructWithMethods") - ]), - "span_begin_line": Uint64(47), - "span_filename": String("src/test_cases/parameter_count_changed.rs"), - "visibility_limit": String("public") - } -] +{ + "./test_crates/inherent_method_missing/": [ + { + "current_parameter_count": List([]), + "method_name": String("will_be_removed_associated_fn"), + "method_visibility": String("public"), + "name": String("Foo"), + "non_matching_span_begin_line": List([]), + "non_matching_span_filename": List([]), + "old_parameter_count": Uint64(0), + "path": List([ + String("inherent_method_missing"), + String("Foo"), + ]), + "span_begin_line": Uint64(7), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "current_parameter_count": List([]), + "method_name": String("will_be_removed_method"), + "method_visibility": String("public"), + "name": String("Foo"), + "non_matching_span_begin_line": List([]), + "non_matching_span_filename": List([]), + "old_parameter_count": Uint64(1), + "path": List([ + String("inherent_method_missing"), + String("Foo"), + ]), + "span_begin_line": Uint64(9), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], + "./test_crates/parameter_count_changed/": [ + { + "current_parameter_count": List([ + Uint64(1), + ]), + "method_name": String("associated_function_with_a_parameter_added"), + "method_visibility": String("public"), + "name": String("StructWithMethods"), + "non_matching_span_begin_line": List([ + Uint64(10), + ]), + "non_matching_span_filename": List([ + String("src/lib.rs"), + ]), + "old_parameter_count": Uint64(0), + "path": List([ + String("parameter_count_changed"), + String("StructWithMethods"), + ]), + "span_begin_line": Uint64(10), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "current_parameter_count": List([ + Uint64(2), + ]), + "method_name": String("method_with_a_parameter_added"), + "method_visibility": String("public"), + "name": String("StructWithMethods"), + "non_matching_span_begin_line": List([ + Uint64(12), + ]), + "non_matching_span_filename": List([ + String("src/lib.rs"), + ]), + "old_parameter_count": Uint64(1), + "path": List([ + String("parameter_count_changed"), + String("StructWithMethods"), + ]), + "span_begin_line": Uint64(12), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "current_parameter_count": List([ + Uint64(3), + ]), + "method_name": String("method_with_a_parameter_removed"), + "method_visibility": String("public"), + "name": String("StructWithMethods"), + "non_matching_span_begin_line": List([ + Uint64(14), + ]), + "non_matching_span_filename": List([ + String("src/lib.rs"), + ]), + "old_parameter_count": Uint64(4), + "path": List([ + String("parameter_count_changed"), + String("StructWithMethods"), + ]), + "span_begin_line": Uint64(14), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "current_parameter_count": List([ + Uint64(3), + ]), + "method_name": String("moved_trait_provided_method"), + "method_visibility": String("public"), + "name": String("StructWithMethods"), + "non_matching_span_begin_line": List([ + Uint64(18), + ]), + "non_matching_span_filename": List([ + String("src/lib.rs"), + ]), + "old_parameter_count": Uint64(2), + "path": List([ + String("parameter_count_changed"), + String("StructWithMethods"), + ]), + "span_begin_line": Uint64(16), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + { + "current_parameter_count": List([ + Uint64(1), + ]), + "method_name": String("moved_method"), + "method_visibility": String("public"), + "name": String("StructWithMethods"), + "non_matching_span_begin_line": List([ + Uint64(28), + ]), + "non_matching_span_filename": List([ + String("src/lib.rs"), + ]), + "old_parameter_count": Uint64(2), + "path": List([ + String("parameter_count_changed"), + String("StructWithMethods"), + ]), + "span_begin_line": Uint64(20), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/sized_impl_removed.output.ron b/test_outputs/sized_impl_removed.output.ron index fb728cf5..341751d1 100644 --- a/test_outputs/sized_impl_removed.output.ron +++ b/test_outputs/sized_impl_removed.output.ron @@ -1,14 +1,14 @@ -[ - { - "name": String("SizedStruct"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("sized_impl_removed"), - String("SizedStruct"), - ]), - "span_filename": String("src/test_cases/sized_impl_removed.rs"), - "span_begin_line": Uint64(7), - "visibility_limit": String("public"), - } -] +{ + "./test_crates/sized_impl_removed/": [ + { + "name": String("SizedStruct"), + "path": List([ + String("sized_impl_removed"), + String("SizedStruct"), + ]), + "span_begin_line": Uint64(1), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/struct_marked_non_exhaustive.output.ron b/test_outputs/struct_marked_non_exhaustive.output.ron index 394c0904..4cef9730 100644 --- a/test_outputs/struct_marked_non_exhaustive.output.ron +++ b/test_outputs/struct_marked_non_exhaustive.output.ron @@ -1,41 +1,59 @@ -[ - { - "name": String("UnitStruct"), - "struct_type": String("unit"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("non_exhaustive"), - String("UnitStruct"), - ]), - "span_filename": String("src/test_cases/non_exhaustive.rs"), - "span_begin_line": Uint64(16), - "visibility_limit": String("public"), - }, - { - "name": String("TupleStruct"), - "struct_type": String("tuple"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("non_exhaustive"), - String("TupleStruct"), - ]), - "span_filename": String("src/test_cases/non_exhaustive.rs"), - "span_begin_line": Uint64(23), - "visibility_limit": String("public"), - }, - { - "name": String("ExternallyConstructibleStruct"), - "struct_type": String("plain"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("non_exhaustive"), - String("ExternallyConstructibleStruct"), - ]), - "span_filename": String("src/test_cases/non_exhaustive.rs"), - "span_begin_line": Uint64(32), - "visibility_limit": String("public"), - } -] +{ + "./test_crates/non_exhaustive/": [ + { + "name": String("UnitStruct"), + "path": List([ + String("non_exhaustive"), + String("UnitStruct"), + ]), + "span_begin_line": Uint64(12), + "span_filename": String("src/lib.rs"), + "struct_type": String("unit"), + "visibility_limit": String("public"), + }, + { + "name": String("TupleStruct"), + "path": List([ + String("non_exhaustive"), + String("TupleStruct"), + ]), + "span_begin_line": Uint64(15), + "span_filename": String("src/lib.rs"), + "struct_type": String("tuple"), + "visibility_limit": String("public"), + }, + { + "name": String("ExternallyConstructibleStruct"), + "path": List([ + String("non_exhaustive"), + String("ExternallyConstructibleStruct"), + ]), + "span_begin_line": Uint64(18), + "span_filename": String("src/lib.rs"), + "struct_type": String("plain"), + "visibility_limit": String("public"), + }, + { + "name": String("NonExternallyConstructibleTupleStruct"), + "path": List([ + String("non_exhaustive"), + String("NonExternallyConstructibleTupleStruct"), + ]), + "span_begin_line": Uint64(25), + "span_filename": String("src/lib.rs"), + "struct_type": String("tuple"), + "visibility_limit": String("public"), + }, + { + "name": String("NonExternallyConstructibleStruct"), + "path": List([ + String("non_exhaustive"), + String("NonExternallyConstructibleStruct"), + ]), + "span_begin_line": Uint64(28), + "span_filename": String("src/lib.rs"), + "struct_type": String("plain"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/struct_missing.output.ron b/test_outputs/struct_missing.output.ron index 89e5f92a..450d1a55 100644 --- a/test_outputs/struct_missing.output.ron +++ b/test_outputs/struct_missing.output.ron @@ -1,28 +1,63 @@ -[ - { - "name": String("WillBeRemovedStruct"), - "struct_type": String("unit"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("item_missing"), - String("WillBeRemovedStruct"), - ]), - "visibility_limit": String("public"), - "span_filename": String("src/test_cases/item_missing.rs"), - "span_begin_line": Uint64(4), - }, - { - "name": String("PubUseRemovedStruct"), - "struct_type": String("unit"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("item_missing"), - String("PubUseRemovedStruct"), - ]), - "visibility_limit": String("public"), - "span_filename": String("src/test_cases/item_missing.rs"), - "span_begin_line": Uint64(33), - } -] +{ + "./test_crates/struct_missing/": [ + { + "name": String("WillBeRemovedStruct"), + "path": List([ + String("struct_missing"), + String("WillBeRemovedStruct"), + ]), + "span_begin_line": Uint64(1), + "span_filename": String("src/lib.rs"), + "struct_type": String("unit"), + "visibility_limit": String("public"), + }, + { + "name": String("PubUseRemovedStruct"), + "path": List([ + String("struct_missing"), + String("PubUseRemovedStruct"), + ]), + "span_begin_line": Uint64(4), + "span_filename": String("src/lib.rs"), + "struct_type": String("unit"), + "visibility_limit": String("public"), + }, + ], + "./test_crates/struct_pub_field_missing/": [ + { + "name": String("StructRemoved"), + "path": List([ + String("struct_pub_field_missing"), + String("StructRemoved"), + ]), + "span_begin_line": Uint64(11), + "span_filename": String("src/lib.rs"), + "struct_type": String("plain"), + "visibility_limit": String("public"), + }, + ], + "./test_crates/unit_struct_changed_kind/": [ + { + "name": String("UnitStructToPlain"), + "path": List([ + String("unit_struct_changed_kind"), + String("UnitStructToPlain"), + ]), + "span_begin_line": Uint64(1), + "span_filename": String("src/lib.rs"), + "struct_type": String("unit"), + "visibility_limit": String("public"), + }, + { + "name": String("NonExhaustiveUnitStructToPlain"), + "path": List([ + String("unit_struct_changed_kind"), + String("NonExhaustiveUnitStructToPlain"), + ]), + "span_begin_line": Uint64(4), + "span_filename": String("src/lib.rs"), + "struct_type": String("unit"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/struct_pub_field_missing.output.ron b/test_outputs/struct_pub_field_missing.output.ron index b9c567a3..57676a06 100644 --- a/test_outputs/struct_pub_field_missing.output.ron +++ b/test_outputs/struct_pub_field_missing.output.ron @@ -1,15 +1,15 @@ -[ - { - "struct_name": String("FieldWillBeRemoved"), - "struct_type": String("plain"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("struct_pub_field_missing"), - String("FieldWillBeRemoved"), - ]), - "field_name": String("bar"), - "span_filename": String("src/test_cases/struct_pub_field_missing.rs"), - "span_begin_line": Uint64(6), - } -] +{ + "./test_crates/struct_pub_field_missing/": [ + { + "field_name": String("bar"), + "path": List([ + String("struct_pub_field_missing"), + String("FieldWillBeRemoved"), + ]), + "span_begin_line": Uint64(5), + "span_filename": String("src/lib.rs"), + "struct_name": String("FieldWillBeRemoved"), + "struct_type": String("plain"), + }, + ], +} diff --git a/test_outputs/struct_repr_c_removed.output.ron b/test_outputs/struct_repr_c_removed.output.ron index 91a14fb3..cd5a4faf 100644 --- a/test_outputs/struct_repr_c_removed.output.ron +++ b/test_outputs/struct_repr_c_removed.output.ron @@ -1,14 +1,14 @@ -[ - { - "name": String("Foo"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("struct_repr_c_removed"), - String("Foo"), - ]), - "span_filename": String("src/test_cases/struct_repr_c_removed.rs"), - "span_begin_line": Uint64(8), - "visibility_limit": String("public"), - } -] +{ + "./test_crates/struct_repr_c_removed/": [ + { + "name": String("Foo"), + "path": List([ + String("struct_repr_c_removed"), + String("Foo"), + ]), + "span_begin_line": Uint64(1), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/struct_repr_transparent_removed.output.ron b/test_outputs/struct_repr_transparent_removed.output.ron index d6477963..94d7065b 100644 --- a/test_outputs/struct_repr_transparent_removed.output.ron +++ b/test_outputs/struct_repr_transparent_removed.output.ron @@ -1,132 +1,134 @@ -[ - { - "name": String("Foo"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("struct_repr_transparent_removed"), - String("Foo"), - ]), - "span_filename": String("src/test_cases/struct_repr_transparent_removed.rs"), - "span_begin_line": Uint64(8), - "transparent_field_name": List([String("bar")]), - "visibility_limit": String("public"), - }, - { - "name": String("Bar"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("struct_repr_transparent_removed"), - String("Bar"), - ]), - "span_filename": String("src/test_cases/struct_repr_transparent_removed.rs"), - "span_begin_line": Uint64(17), - "transparent_field_name": List([String("0")]), - "visibility_limit": String("public"), - }, - { - "name": String("WithZeroSizedData"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("struct_repr_transparent_removed"), - String("WithZeroSizedData"), - ]), - "span_filename": String("src/test_cases/struct_repr_transparent_removed.rs"), - "span_begin_line": Uint64(27), - "transparent_field_name": List([String("bar")]), - "visibility_limit": String("public"), - }, - { - "name": String("TupleWithZeroSizedData"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("struct_repr_transparent_removed"), - String("TupleWithZeroSizedData"), - ]), - "span_filename": String("src/test_cases/struct_repr_transparent_removed.rs"), - "span_begin_line": Uint64(37), - "transparent_field_name": List([String("0")]), - "visibility_limit": String("public"), - }, - { - "name": String("WithPubZeroSizedData"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("struct_repr_transparent_removed"), - String("WithPubZeroSizedData"), - ]), - "span_filename": String("src/test_cases/struct_repr_transparent_removed.rs"), - "span_begin_line": Uint64(47), - "transparent_field_name": List([String("bar")]), - "visibility_limit": String("public"), - }, - { - "name": String("WithSpecificZeroSizedData"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("struct_repr_transparent_removed"), - String("WithSpecificZeroSizedData"), - ]), - "span_filename": String("src/test_cases/struct_repr_transparent_removed.rs"), - "span_begin_line": Uint64(60), - "transparent_field_name": List([String("bar")]), - "visibility_limit": String("public"), - }, - { - "name": String("WithFoo"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("struct_repr_transparent_removed"), - String("WithFoo"), - ]), - "span_filename": String("src/test_cases/struct_repr_transparent_removed.rs"), - "span_begin_line": Uint64(73), - "transparent_field_name": List([String("bar")]), - "visibility_limit": String("public"), - }, - { - "name": String("WithRef"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("struct_repr_transparent_removed"), - String("WithRef"), - ]), - "span_filename": String("src/test_cases/struct_repr_transparent_removed.rs"), - "span_begin_line": Uint64(86), - "transparent_field_name": List([String("bar")]), - "visibility_limit": String("public"), - }, - { - "name": String("WithTuple"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("struct_repr_transparent_removed"), - String("WithTuple"), - ]), - "span_filename": String("src/test_cases/struct_repr_transparent_removed.rs"), - "span_begin_line": Uint64(99), - "transparent_field_name": List([String("bar")]), - "visibility_limit": String("public"), - }, - { - "name": String("WithGeneric"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("struct_repr_transparent_removed"), - String("WithGeneric"), - ]), - "span_filename": String("src/test_cases/struct_repr_transparent_removed.rs"), - "span_begin_line": Uint64(112), - "transparent_field_name": List([String("bar")]), - "visibility_limit": String("public"), - }, -] +{ + "./test_crates/struct_repr_transparent_removed/": [ + { + "name": String("Foo"), + "path": List([ + String("struct_repr_transparent_removed"), + String("Foo"), + ]), + "span_begin_line": Uint64(1), + "span_filename": String("src/lib.rs"), + "transparent_field_name": List([ + String("bar"), + ]), + "visibility_limit": String("public"), + }, + { + "name": String("Bar"), + "path": List([ + String("struct_repr_transparent_removed"), + String("Bar"), + ]), + "span_begin_line": Uint64(5), + "span_filename": String("src/lib.rs"), + "transparent_field_name": List([ + String("0"), + ]), + "visibility_limit": String("public"), + }, + { + "name": String("WithZeroSizedData"), + "path": List([ + String("struct_repr_transparent_removed"), + String("WithZeroSizedData"), + ]), + "span_begin_line": Uint64(7), + "span_filename": String("src/lib.rs"), + "transparent_field_name": List([ + String("bar"), + ]), + "visibility_limit": String("public"), + }, + { + "name": String("TupleWithZeroSizedData"), + "path": List([ + String("struct_repr_transparent_removed"), + String("TupleWithZeroSizedData"), + ]), + "span_begin_line": Uint64(12), + "span_filename": String("src/lib.rs"), + "transparent_field_name": List([ + String("0"), + ]), + "visibility_limit": String("public"), + }, + { + "name": String("WithPubZeroSizedData"), + "path": List([ + String("struct_repr_transparent_removed"), + String("WithPubZeroSizedData"), + ]), + "span_begin_line": Uint64(14), + "span_filename": String("src/lib.rs"), + "transparent_field_name": List([ + String("bar"), + ]), + "visibility_limit": String("public"), + }, + { + "name": String("WithSpecificZeroSizedData"), + "path": List([ + String("struct_repr_transparent_removed"), + String("WithSpecificZeroSizedData"), + ]), + "span_begin_line": Uint64(19), + "span_filename": String("src/lib.rs"), + "transparent_field_name": List([ + String("bar"), + ]), + "visibility_limit": String("public"), + }, + { + "name": String("WithFoo"), + "path": List([ + String("struct_repr_transparent_removed"), + String("WithFoo"), + ]), + "span_begin_line": Uint64(24), + "span_filename": String("src/lib.rs"), + "transparent_field_name": List([ + String("bar"), + ]), + "visibility_limit": String("public"), + }, + { + "name": String("WithRef"), + "path": List([ + String("struct_repr_transparent_removed"), + String("WithRef"), + ]), + "span_begin_line": Uint64(29), + "span_filename": String("src/lib.rs"), + "transparent_field_name": List([ + String("bar"), + ]), + "visibility_limit": String("public"), + }, + { + "name": String("WithTuple"), + "path": List([ + String("struct_repr_transparent_removed"), + String("WithTuple"), + ]), + "span_begin_line": Uint64(34), + "span_filename": String("src/lib.rs"), + "transparent_field_name": List([ + String("bar"), + ]), + "visibility_limit": String("public"), + }, + { + "name": String("WithGeneric"), + "path": List([ + String("struct_repr_transparent_removed"), + String("WithGeneric"), + ]), + "span_begin_line": Uint64(39), + "span_filename": String("src/lib.rs"), + "transparent_field_name": List([ + String("bar"), + ]), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/unit_struct_changed_kind.output.ron b/test_outputs/unit_struct_changed_kind.output.ron index f8106eca..b7e3699f 100644 --- a/test_outputs/unit_struct_changed_kind.output.ron +++ b/test_outputs/unit_struct_changed_kind.output.ron @@ -1,14 +1,14 @@ -[ - { - "name": String("UnitStructToPlain"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("unit_struct_changed_kind"), - String("UnitStructToPlain"), - ]), - "visibility_limit": String("public"), - "span_filename": String("src/test_cases/unit_struct_changed_kind.rs"), - "span_begin_line": Uint64(5), - } -] +{ + "./test_crates/unit_struct_changed_kind/": [ + { + "name": String("UnitStructToPlain"), + "path": List([ + String("unit_struct_changed_kind"), + String("UnitStructToPlain"), + ]), + "span_begin_line": Uint64(1), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], +} diff --git a/test_outputs/variant_marked_non_exhaustive.output.ron b/test_outputs/variant_marked_non_exhaustive.output.ron index e9023756..0295845f 100644 --- a/test_outputs/variant_marked_non_exhaustive.output.ron +++ b/test_outputs/variant_marked_non_exhaustive.output.ron @@ -1,41 +1,37 @@ -[ - { - "name": String("MyEnum"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("non_exhaustive"), - String("MyEnum"), - ]), - "variant_name": String("UnitVariant"), - "span_filename": String("src/test_cases/non_exhaustive.rs"), - "span_begin_line": Uint64(74), - "visibility_limit": String("public"), - }, - { - "name": String("MyEnum"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("non_exhaustive"), - String("MyEnum"), - ]), - "variant_name": String("TupleVariant"), - "span_filename": String("src/test_cases/non_exhaustive.rs"), - "span_begin_line": Uint64(77), - "visibility_limit": String("public"), - }, - { - "name": String("MyEnum"), - "path": List([ - String("test_crates"), - String("test_cases"), - String("non_exhaustive"), - String("MyEnum"), - ]), - "variant_name": String("StructVariant"), - "span_filename": String("src/test_cases/non_exhaustive.rs"), - "span_begin_line": Uint64(80), - "visibility_limit": String("public"), - } -] +{ + "./test_crates/non_exhaustive/": [ + { + "name": String("MyEnum"), + "path": List([ + String("non_exhaustive"), + String("MyEnum"), + ]), + "span_begin_line": Uint64(38), + "span_filename": String("src/lib.rs"), + "variant_name": String("UnitVariant"), + "visibility_limit": String("public"), + }, + { + "name": String("MyEnum"), + "path": List([ + String("non_exhaustive"), + String("MyEnum"), + ]), + "span_begin_line": Uint64(41), + "span_filename": String("src/lib.rs"), + "variant_name": String("TupleVariant"), + "visibility_limit": String("public"), + }, + { + "name": String("MyEnum"), + "path": List([ + String("non_exhaustive"), + String("MyEnum"), + ]), + "span_begin_line": Uint64(44), + "span_filename": String("src/lib.rs"), + "variant_name": String("StructVariant"), + "visibility_limit": String("public"), + }, + ], +}