Rollup merge of #93892 - compiler-errors:issue-92917, r=jackh726,nikomatsakis
Only mark projection as ambiguous if GAT substs are constrained A slightly more targeted version of #92917, where we only give up with ambiguity if we infer something about the GATs substs when probing for a projection candidate. fixes #93874 also note (but like the previous PR, does not fix) #91762 r? `@jackh726` cc `@nikomatsakis` who reviewed #92917
This commit is contained in:
commit
1e2f63de0a
6 changed files with 100 additions and 43 deletions
|
|
@ -17,7 +17,6 @@ impl<T> UnsafeCopy for T {}
|
|||
fn main() {
|
||||
let b = Box::new(42usize);
|
||||
let copy = <()>::copy(&b);
|
||||
//~^ type annotations needed
|
||||
|
||||
let raw_b = Box::deref(&b) as *const _;
|
||||
let raw_copy = Box::deref(©) as *const _;
|
||||
|
|
|
|||
|
|
@ -27,13 +27,6 @@ help: consider restricting type parameter `T`
|
|||
LL | type Copy<T: std::clone::Clone>: Copy = Box<T>;
|
||||
| +++++++++++++++++++
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/issue-74824.rs:19:16
|
||||
|
|
||||
LL | let copy = <()>::copy(&b);
|
||||
| ^^^^^^^^^^ cannot infer type for type parameter `T` declared on the associated function `copy`
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0282.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
|||
35
src/test/ui/generic-associated-types/issue-93874.rs
Normal file
35
src/test/ui/generic-associated-types/issue-93874.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
pub trait Build {
|
||||
type Output<O>;
|
||||
fn build<O>(self, input: O) -> Self::Output<O>;
|
||||
}
|
||||
|
||||
pub struct IdentityBuild;
|
||||
impl Build for IdentityBuild {
|
||||
type Output<O> = O;
|
||||
fn build<O>(self, input: O) -> Self::Output<O> {
|
||||
input
|
||||
}
|
||||
}
|
||||
|
||||
fn a() {
|
||||
let _x: u8 = IdentityBuild.build(10);
|
||||
}
|
||||
|
||||
fn b() {
|
||||
let _x: Vec<u8> = IdentityBuild.build(Vec::new());
|
||||
}
|
||||
|
||||
fn c() {
|
||||
let mut f = IdentityBuild.build(|| ());
|
||||
(f)();
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
a();
|
||||
b();
|
||||
c();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue