Give where clauses priority over builtin rules. Fixes #20959.
This commit is contained in:
parent
06e798a881
commit
2b8678cf5d
2 changed files with 31 additions and 0 deletions
|
@ -1166,6 +1166,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
.is_ok()
|
.is_ok()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
(&BuiltinCandidate(_), &ParamCandidate(_)) => {
|
||||||
|
// If we have a where-clause like `Option<K> : Send`,
|
||||||
|
// then we wind up in a situation where there is a
|
||||||
|
// default rule (`Option<K>:Send if K:Send) and the
|
||||||
|
// where-clause that both seem applicable. Just take
|
||||||
|
// the where-clause in that case.
|
||||||
|
true
|
||||||
|
}
|
||||||
(&ProjectionCandidate, &ParamCandidate(_)) => {
|
(&ProjectionCandidate, &ParamCandidate(_)) => {
|
||||||
// FIXME(#20297) -- this gives where clauses precedent
|
// FIXME(#20297) -- this gives where clauses precedent
|
||||||
// over projections. Really these are just two means
|
// over projections. Really these are just two means
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
// Test that we do not error out because of a (False) ambiguity
|
||||||
|
// between the builtin rules for Sized and the where clause. Issue
|
||||||
|
// #20959.
|
||||||
|
|
||||||
|
fn foo<K>(x: Option<K>)
|
||||||
|
where Option<K> : Sized
|
||||||
|
{
|
||||||
|
let _y = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
foo(Some(22));
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue