Open
Description
Code
use std::{cell::RefCell, rc::Rc};
struct Wrapper {
// this part is important - if this field is commented out, error disappears
engine: rhai::Engine,
// this is what actually triggers the diagnostic
ctx: Rc<RefCell<()>>,
}
fn main() {
let _ = Wrapper {
engine: rhai::Engine::new_raw(),
ctx: (),
};
}
Current output
error[E0308]: mismatched types
--> src/main.rs:13:14
|
13 | ctx: (),
| ^^ expected `Shared<Locked<()>>`, found `()`
|
= note: expected struct `Rc<Locked<()>>`
found unit type `()`
Desired output
error[E0308]: mismatched types
--> src/main.rs:13:14
|
13 | ctx: (),
| ^^ expected `Rc<RefCell<()>>`, found `()`
|
= note: expected struct `Rc<RefCell<()>>`
found unit type `()`
Rationale and extra context
No response
Other cases
No response
Rust Version
rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-unknown-linux-gnu
release: 1.75.0
LLVM version: 17.0.6
Anything else?
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
rhai
rust-lang/rust-analyzer#16436tguichaoua commentedon Jan 27, 2024
For context,
Shared
andLocked
are re-exports ofRc
andRefCell
(orArc
andRwLock
, based on a feature flag) in therhai
crate.https://github.com/rhaiscript/rhai/blob/8b0a62e6b172abffadea4a5cb404c75c01c3aba9/src/func/native.rs#L31-L53
clubby789 commentedon Jan 27, 2024
Reproduction (doesn't happen if the alias is in the same crate)
rustc dep.rs --crate-type=lib && rustc poc.rs --extern dep=./libdep.rlib
:clubby789 commentedon Jan 27, 2024
Bisects to
#74073 seems more likely, #73834 #73871 seem relevant (the second in particular)
bvanjoi commentedon Jan 30, 2024
I believe this issue was regressed by #105411. More precisely, it was caused by the changes found at https://github.com/rust-lang/rust/pull/105411/files#diff-b56d8c5fa3d7803c5b0e19e1a8854d85c302974484c4c20bf51c76a19556f4a7R376-R382.