Open
Description
Consider the following example which (at the time of writing, i.e. #44614) fails:
pub fn main() {
let x = &Some((3, 3));
let _: &i32 = match x {
// Here, each of the patterns are treated independently
//
// FIXME(tschottdorf): make this compile without the actual `|`.
// @nikomatsakis suggested perhaps just removing the code which
// complains but wasn't sure whether it's still required for anything.
// Opinions?
//
// Some((x, 3)) | &Some((ref x, 5)) => x,
// - first binding ^ bound in different ways
/*Some((x, 3)) |*/ &Some((ref x, 5)) => x,
_ => &5i32,
};
}
It's not clear whether the rule that prevents this from compiling is still worthwhile.
@nikomatsakis had this to say:
I suspect we can just remove it but it may be used by some code somewhere
i.e., I'm pretty sure the old trans code (obviated by MIR now) used to rely on that (that each binding had a single "mode") but...
well, maybe MIR builder does too, who knows
honestly maybe not worth supporting
(well, I guess that if we keep the check, we would want to check the inferred mode -- probably better if we ditch it and figure out if we have to change anything else as a result)