-
Notifications
You must be signed in to change notification settings - Fork 13.3k
incr.comp.: Create Test Case for Incr. Comp. Hash for traits #36681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@michaelwoerister I would like to take this one too. It will take a little longer this time 😐 |
Sure, go ahead! There's no rush either, you can take your time. |
@michaelwoerister
|
You're right. I removed them from the list.
It had something to do with non-public items not being exported and thus not being present in metadata.
That's a very good point. The test would make sense, if the compiler treats |
So, it is OK that changing the type alias does not change the hash of items referencing the alias. That change is detected later during analysis when the alias is resolved. I've added a test case making sure that's really the case: #36932 |
…oerister Test Case for Incr. Comp. Hash for traits #36681. Fixes #36681 Part of #36350 Currently, the following tests fail: Unsafe modifier Extern modifier Extern c to rust-intrinsic Trait unsafety Change type of method parameter (&i32 => &mut i32) Mode of self parameter r? @michaelwoerister
This issue is part of a broader effort to implement comprehensive regression testing for incremental compilation. For the tracking issue go to #36350.
Background
For incremental compilation we need to determine if a given HIR node has changed in between two versions of a program. This is implemented in the calculate_svh module. We compute a hash value for each HIR node that corresponds to a node in the dependency graph and then compare those hash values. We call this hash value the Incremental Compilation Hash (ICH) of the HIR node. It is supposed to be sensitive to any change that might make a semantic difference to the thing being hashed.
Testing Methodology
The auto-tests in the
src/test/incremental
directory all follow the same pattern:--cfg
flag, allowing each version to differ via conditional compilation. Each of these versions we call a revision.#[rustc_clean]
/#[rustc_dirty]
).The ICH-specific tests use this framework by adhering to the following pattern:
#[cfg(cfail1)]
and the second marked with#[cfg(not(cfail1))]
. As a consequence, the first revision will be compiled with the first version of the definition, and all other revisions will be compiled with the second version. The two versions are supposed to differ in exactly one aspect (e.g. the visibility of a field is different, or the return of a function has changed).#[rustc_dirty(label="Hir", cfg="cfail2")]
attribute attached. This attribute makes the test runner check that a change of theHir
dependency node of the definition has been detected between revisionscfail1
andcfail2
. This will effectively test that a different ICH value has been computed for the two versions of the definition.#[rustc_clean(label="Hir", cfg="cfail3")]
attribute. This makes sure that theHir
dependency node (and thus the ICH) of the definition has not changed between revisionscfail2
andcfail3
. That's what we expect, because both revisions use the same version of the definition.#[rustc_metadata_clean]
/#[rustc_metadata_dirty]
attributes and works analogous to theHir
case: We add#[rustc_metadata_dirty(cfg="cfail2")]
to the second definition to make sure that the ICH of the exported metadata is not the same for the different versions of the definition, and we add#[rustc_metadata_dirty(cfg="cfail3")]
to make sure that the ICH is the same for the two identical versions of the definition.Why are the revisions called "cfail"? That's because of reasons internal to how
the test-runner works. Prefixing a revision with "cfail" tells the test runner to treat the test like a "compile-file" test, that is: compile the test case but don't actually run it (which would be the case for an "rpass" revision). For the ICH tests we need to compile "rlibs", so that we can test metadata ICHs. As a consequence we cannot declare them "rpass". In an additional directive (
// must-compile-successfully
), we tell the test runner that we actually expect the file to not produce any errors.Each test case must contain the following test-runner directives and crate attributes at the top:
See src/test/incremental/hashes/struct_defs.rs for a full example of such a ICH regression test.
Trait Specific ICH Testing
Each of the following things should be tested with its own definition pair:
self
parameterunsafe
modifier to methodextern
modifier to methodextern "C"
toextern "rust-intrinsic"
Send
orCopy
)'static
lifetime bound to trait'static
bounds as second boundAdd second type parameter to trait in where clauseAdd second lifetime parameter to trait in where clauseEDIT: Some more cases
use
statementuse
statementuse
statementuse
statementuse
statementuse
statementThe text was updated successfully, but these errors were encountered: