-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Regression: Typemap type mismatch in 1.34.0+ #60375
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
Ping: @dpc |
Would it be possible to paste the runtime error? |
@IslandUsurper Did you want to ping the other dpc? 😄 |
cc @Dylan-DPC ^--- |
Same problem while running the example in README of natice-windows-gui .
OS : Windows 10 2016 ltsb (version 1607) The last frame in main is 12 , a nwg_get! macro call, defined as /**
Return controls from the Ui. Panics if one of the controls could not be retrieved.
To avoid the panic, use `ui.get` directly.
Usage:
`let control = nwg_get!(ui; (control ID, control type))`
`let (control1, control2) = nwg_get!(ui; [(control1_ID, control1 type), (control2_ID, control2_type)])`
*/
#[macro_export]
macro_rules! nwg_get {
( $ui:ident; ($n:expr, $t:ty) ) => {
$ui.get::<$t>(&$n).expect("Failed to find a control")
};
( $ui:ident; [ $( ($n:expr, $t:ty) ),* ] ) => {
(
$( $ui.get::<$t>(&$n).expect("Failed to find a control") ),*
)
}
} |
triage: Not quite clear on what is going on here; maybe something with using |
It seems like what is really needed here is to try and narrow this to a standalone test case that is not reliant on |
triage: P-high Behavorial regression, unknown cause, needs help to track down the problem. |
Hey this is my project. I'll try to isolate the problem to make it a bit easier to fix... hopefully. |
Ok I think I've found something. Hopefully it makes sense. It seems like there are two methods named "type_id" (one from For example, this code does not compile: use std::any::Any;
use std::any::TypeId;
trait Resource {
}
trait ResourceT {
fn type_id(&self) -> TypeId;
}
struct TestResourceT {
value: u32
}
impl ResourceT for TestResourceT {
fn type_id(&self) -> TypeId { TypeId::of::<TestResource>() }
}
struct TestResource {}
fn main() {
let test = TestResourceT{ value: 10 };
println!("{:?}", TypeId::of::<TestResource>());
println!("{:?}", test.type_id());
} The compiler will output
That said, if you remove Here's a snippet that run the bogus code from native-windows-gui: https://gist.github.com/gabdube/ef27e073c209b23b06d794dca9982af2 Again, removing |
Triage: latest example still reproduces |
I reduced the failing test case: // This program compiles but asserts when std::any::Any is in scope,
// but compiles and runs successfully when it is not in scope.
use std::any::Any;
use std::any::TypeId;
trait Resource {
fn type_id(&self) -> TypeId;
}
impl Resource for () {
fn type_id(&self) -> TypeId { TypeId::of::<()>() }
}
fn main() {
let tid_orig = TypeId::of::<()>();
let ref_res: &dyn Resource = &();
let tid_from_ref = ref_res.type_id();
let box_res: Box<dyn Resource> = Box::new(());
let tid_from_box = box_res.type_id();
dbg!(tid_orig, tid_from_ref, tid_from_box);
assert_eq!(tid_orig, tid_from_ref); // passes
assert_eq!(tid_orig, tid_from_box); // fails
} Take note of the asserts; the failure only happens on boxed trait objects. It took me a while to realize that So I don't think there's any action to be taken here. The behavior here is a consequence of trait objects, autoderef, and a blanket impl. 1.34 just happened to be the release when |
We reviewed this in today's @rust-lang/libs meeting. Sorry that this took so long for us to get to! This kind of issue is why we don't normally implement methods on |
I first reported this issue at gabdube/native-windows-gui#69, but discussion on Discord led me to file an issue here.
native-windows-ui stores data about the application (form controls, state, etc.) through a typemap. While my program worked on Rust 1.32.0 and 1.33.0, it breaks on 1.34.0 and 1.34.1. Sadly, this is a runtime error, and no backtrace is generated even with the RUST_BACKTRACE flag.
The error that is generated is
native_windows_gui::Error::BadType
.The text was updated successfully, but these errors were encountered: