-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
unstable fingerprints error with mockall 0.10 #112430
Comments
First, unstable proc macros should very much not cause incremental problems, proc macros run before incremental kicks in. It does make it way harder to debug though. Do you have a simple way to reproduce it? |
Maybe it shouldn't, but if I use Interestingly, expanding the I managed to remove a few more things. This version doesn't use Crashing code: use paste::paste;
// This constant allows us to rebuild without changing anything in this file.
#[allow(unused)]
const RANDOM: &str = include_str!("rand.txt");
type Callback<T> = Box<dyn FnOnce(&mut T) + 'static>;
// This struct doesn't seem like it should do anything, but removing it stops the crash.
struct MockDaoA;
#[mockall::automock]
trait DaoB {
fn method<'life0, 'life1>(&'life0 self, param: &'life1 usize);
}
// Removing this send constraint stops the crash.
struct Wrapper<M>(Callback<M>)
where
M: Send;
// Expanding this macro by hand stops the crash?
macro_rules! builder_struct {
($($dao_impl:ty),* $(,)?) => {
paste! {
struct Builder{
$(
[< $dao_impl:snake >]: Wrapper<$dao_impl>,
)*
}
#[allow(unused)]
impl Builder {
$(
fn [< with_mock_ $dao_impl:snake>] (
mut self,
config_callback: Callback<$dao_impl>,
) {
self.[< $dao_impl:snake >] = Wrapper(config_callback);
}
)*
}
}
}
}
builder_struct!(MockDaoA, MockDaoB); Non crashing code: // This constant allows us to rebuild without changing anything in this file.
#[allow(unused)]
const RANDOM: &str = include_str!("rand.txt");
type Callback<T> = Box<dyn FnOnce(&mut T) + 'static>;
// This struct doesn't seem like it should do anything, but removing it stops the crash.
struct MockDaoA;
#[mockall::automock]
trait DaoB {
fn method<'life0, 'life1>(&'life0 self, param: &'life1 usize);
}
// Removing this send constraint stops the crash.
struct Wrapper<M>(Callback<M>)
where
M: Send;
struct Builder {
mock_dao_a: Wrapper<MockDaoA>,
mock_dao_b: Wrapper<MockDaoB>,
}
#[allow(unused)]
impl Builder {
fn with_mock_mock_dao_a(mut self, config_callback: Callback<MockDaoA>) {
self.mock_dao_a = Wrapper(config_callback);
}
fn with_mock_mock_dao_b(mut self, config_callback: Callback<MockDaoB>) {
self.mock_dao_b = Wrapper(config_callback);
}
} That paste macro isn't very complicated and has stable output. |
It's definitely related to asomers/mockall#333. I pulled down the mockall code and bisected. asomers/mockall@e2f5285 is the first commit where it doesn't crash. |
the nondeterminism probably exhibits a specific pattern that makes rustc crash. I don't think this is worth your time debugging if it doesn't ICE on beta anymore. It's unlikely that you'll reveal new things about it. it was probably fixed by #11195. |
awesome, thanks! closing it as completed then |
I think this problem is related to asomers/mockall#333. Upgrading to Mockall 0.11.4 is one of the things that prevents it from happening.
I'm not seeing the crash on beta 1.71.0-beta.2, but I can't see a bug for this so I don't know if that's intentional. When I upgraded to 1.70 it seemed like almost every other build I would get a crash. Coworkers downgraded to 1.69 because of it, so to me it seems like a good candidate for backporting if it's not already planned.
Code
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: