Auto merge of #42281 - eddyb:well-adjusted, r=nikomatsakis
Decompose Adjustment into smaller steps and remove the method map. The method map held method callee information for: * actual method calls (`x.f(...)`) * overloaded unary, binary, indexing and call operators * *every overloaded deref adjustment* (many can exist for each expression) That last one was a historical ~~accident~~ hack, and part of the motivation for this PR, along with: * a desire to compose adjustments more freely * containing the autoderef logic better to avoid mutation within an inference snapshot * not creating `TyFnDef` types which are incompatible with the original one * i.e. we used to take a`TyFnDef`'s `for<'a> &'a T -> &'a U` signature and instantiate `'a` using a region inference variable, *then* package the resulting `&'b T -> &'b U` signature in another `TyFnDef`, while keeping *the same* `DefId` and `Substs` * to fix #3548 by explicitly writing autorefs for the RHS of comparison operators Individual commits tell their own story, of "atomic" changes avoiding breaking semantics. Future work based on this PR could include: * removing the signature from `TyFnDef`, now that it's always "canonical" * some questions of variance remain, as subtyping *still* treats the signature differently * moving part of the typeck logic for methods, autoderef and coercion into `rustc::traits` * allowing LUB coercions (joining multiple expressions) to "stack up" many adjustments * transitive coercions (e.g. reify or unsize after multiple steps of autoderef) r? @nikomatsakis
This commit is contained in:
commit
4ed2edaafe
49 changed files with 1470 additions and 2138 deletions
|
|
@ -8,10 +8,10 @@ error[E0308]: mismatched types
|
|||
found type `u32`
|
||||
|
||||
error[E0277]: the trait bound `u32: std::ops::Add<impl Foo>` is not satisfied
|
||||
--> $DIR/equality.rs:34:9
|
||||
--> $DIR/equality.rs:34:11
|
||||
|
|
||||
34 | n + sum_to(n - 1)
|
||||
| ^^^^^^^^^^^^^^^^^ no implementation for `u32 + impl Foo`
|
||||
| ^ no implementation for `u32 + impl Foo`
|
||||
|
|
||||
= help: the trait `std::ops::Add<impl Foo>` is not implemented for `u32`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,56 +1,56 @@
|
|||
error[E0277]: the trait bound `{integer}: std::ops::Add<std::option::Option<{integer}>>` is not satisfied
|
||||
--> $DIR/binops.rs:12:5
|
||||
--> $DIR/binops.rs:12:7
|
||||
|
|
||||
12 | 1 + Some(1);
|
||||
| ^^^^^^^^^^^ no implementation for `{integer} + std::option::Option<{integer}>`
|
||||
| ^ no implementation for `{integer} + std::option::Option<{integer}>`
|
||||
|
|
||||
= help: the trait `std::ops::Add<std::option::Option<{integer}>>` is not implemented for `{integer}`
|
||||
|
||||
error[E0277]: the trait bound `usize: std::ops::Sub<std::option::Option<{integer}>>` is not satisfied
|
||||
--> $DIR/binops.rs:13:5
|
||||
--> $DIR/binops.rs:13:16
|
||||
|
|
||||
13 | 2 as usize - Some(1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ no implementation for `usize - std::option::Option<{integer}>`
|
||||
| ^ no implementation for `usize - std::option::Option<{integer}>`
|
||||
|
|
||||
= help: the trait `std::ops::Sub<std::option::Option<{integer}>>` is not implemented for `usize`
|
||||
|
||||
error[E0277]: the trait bound `{integer}: std::ops::Mul<()>` is not satisfied
|
||||
--> $DIR/binops.rs:14:5
|
||||
--> $DIR/binops.rs:14:7
|
||||
|
|
||||
14 | 3 * ();
|
||||
| ^^^^^^ no implementation for `{integer} * ()`
|
||||
| ^ no implementation for `{integer} * ()`
|
||||
|
|
||||
= help: the trait `std::ops::Mul<()>` is not implemented for `{integer}`
|
||||
|
||||
error[E0277]: the trait bound `{integer}: std::ops::Div<&str>` is not satisfied
|
||||
--> $DIR/binops.rs:15:5
|
||||
--> $DIR/binops.rs:15:7
|
||||
|
|
||||
15 | 4 / "";
|
||||
| ^^^^^^ no implementation for `{integer} / &str`
|
||||
| ^ no implementation for `{integer} / &str`
|
||||
|
|
||||
= help: the trait `std::ops::Div<&str>` is not implemented for `{integer}`
|
||||
|
||||
error[E0277]: the trait bound `{integer}: std::cmp::PartialEq<std::string::String>` is not satisfied
|
||||
--> $DIR/binops.rs:16:5
|
||||
--> $DIR/binops.rs:16:7
|
||||
|
|
||||
16 | 5 < String::new();
|
||||
| ^^^^^^^^^^^^^^^^^ can't compare `{integer}` with `std::string::String`
|
||||
| ^ can't compare `{integer}` with `std::string::String`
|
||||
|
|
||||
= help: the trait `std::cmp::PartialEq<std::string::String>` is not implemented for `{integer}`
|
||||
|
||||
error[E0277]: the trait bound `{integer}: std::cmp::PartialOrd<std::string::String>` is not satisfied
|
||||
--> $DIR/binops.rs:16:5
|
||||
--> $DIR/binops.rs:16:7
|
||||
|
|
||||
16 | 5 < String::new();
|
||||
| ^^^^^^^^^^^^^^^^^ can't compare `{integer}` with `std::string::String`
|
||||
| ^ can't compare `{integer}` with `std::string::String`
|
||||
|
|
||||
= help: the trait `std::cmp::PartialOrd<std::string::String>` is not implemented for `{integer}`
|
||||
|
||||
error[E0277]: the trait bound `{integer}: std::cmp::PartialEq<std::result::Result<{integer}, _>>` is not satisfied
|
||||
--> $DIR/binops.rs:17:5
|
||||
--> $DIR/binops.rs:17:7
|
||||
|
|
||||
17 | 6 == Ok(1);
|
||||
| ^^^^^^^^^^ can't compare `{integer}` with `std::result::Result<{integer}, _>`
|
||||
| ^^ can't compare `{integer}` with `std::result::Result<{integer}, _>`
|
||||
|
|
||||
= help: the trait `std::cmp::PartialEq<std::result::Result<{integer}, _>>` is not implemented for `{integer}`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
error[E0277]: the trait bound `u32: std::ops::Add<()>` is not satisfied
|
||||
--> $DIR/multiline-span-simple.rs:23:9
|
||||
--> $DIR/multiline-span-simple.rs:23:18
|
||||
|
|
||||
23 | foo(1 as u32 +
|
||||
| _________^
|
||||
24 | |
|
||||
25 | | bar(x,
|
||||
26 | |
|
||||
27 | | y),
|
||||
| |______________^ no implementation for `u32 + ()`
|
||||
23 | foo(1 as u32 +
|
||||
| ^ no implementation for `u32 + ()`
|
||||
|
|
||||
= help: the trait `std::ops::Add<()>` is not implemented for `u32`
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue