Files
rust/tests/ui/cross-crate/cross-crate-refcell-match.rs

37 lines
1003 B
Rust
Raw Normal View History

2025-06-13 02:30:47 +05:00
//! Regression test for https://github.com/rust-lang/rust/issues/16822
//
//! ICE when using RefCell::borrow_mut()
//! inside match statement with cross-crate generics.
//!
//! The bug occurred when:
//! - A library defines a generic struct with RefCell<T> and uses borrow_mut() in match
//! - Main crate implements the library trait for its own type
//! - Cross-crate generic constraint causes type inference issues
//!
//! The problematic match statement is in the auxiliary file, this file triggers it.
//@ run-pass
2025-06-13 02:30:47 +05:00
//@ aux-build:cross-crate-refcell-match.rs
2014-12-07 15:22:06 +00:00
2025-06-13 02:30:47 +05:00
extern crate cross_crate_refcell_match as lib;
2014-12-07 15:22:06 +00:00
use std::cell::RefCell;
struct App {
2025-06-13 02:30:47 +05:00
i: isize,
2014-12-07 15:22:06 +00:00
}
impl lib::Update for App {
fn update(&mut self) {
self.i += 1;
}
}
2025-06-13 02:30:47 +05:00
fn main() {
2014-12-07 15:22:06 +00:00
let app = App { i: 5 };
let window = lib::Window { data: RefCell::new(app) };
2025-06-13 02:30:47 +05:00
// This specific pattern (RefCell::borrow_mut in match with cross-crate generics)
// caused the ICE in the original issue
2014-12-07 15:22:06 +00:00
window.update(1);
}