Resolve type variables when checking casting to char
auto merge of #12211 : sanxiyn/rust/issue-9918, r=pcwalton

Fix #9918.