about summary refs log tree commit diff
path: root/tests/ui/cross-crate/cross-crate-refcell-match.rs
blob: 7e46425612f333445599789e26d8e1a460869d8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//! 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
//@ aux-build:cross-crate-refcell-match.rs

extern crate cross_crate_refcell_match as lib;

use std::cell::RefCell;

struct App {
    i: isize,
}

impl lib::Update for App {
    fn update(&mut self) {
        self.i += 1;
    }
}

fn main() {
    let app = App { i: 5 };
    let window = lib::Window { data: RefCell::new(app) };
    // This specific pattern (RefCell::borrow_mut in match with cross-crate generics)
    // caused the ICE in the original issue
    window.update(1);
}