diff options
| author | Jonas Schievink <jonasschievink@gmail.com> | 2020-11-23 15:25:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-23 15:25:44 +0100 |
| commit | c7a67209c8abbba40d5736eb10975988d99960bc (patch) | |
| tree | ca9b89360981cd5e633c353465552a07ade4cbe2 /compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp | |
| parent | c58c245e2cc550b69f14595ffe9e967de12411c7 (diff) | |
| parent | cb406848eccc3665dfadb241d94fe27137bd0dcb (diff) | |
| download | rust-c7a67209c8abbba40d5736eb10975988d99960bc.tar.gz rust-c7a67209c8abbba40d5736eb10975988d99960bc.zip | |
Rollup merge of #79287 - jonas-schievink:const-trait-impl, r=oli-obk
Allow using generic trait methods in `const fn`
Next step for https://github.com/rust-lang/rust/issues/67792, this now also allows code like the following:
```rust
struct S;
impl const PartialEq for S {
fn eq(&self, _: &S) -> bool {
true
}
}
const fn equals_self<T: PartialEq>(t: &T) -> bool {
*t == *t
}
pub const EQ: bool = equals_self(&S);
```
This works by threading const-ness of trait predicates through trait selection, in particular through `ParamCandidate`, and exposing it in the resulting `ImplSource`.
Since this change makes two bounds `T: Trait` and `T: ?const Trait` that only differ in their const-ness be treated like different bounds, candidate winnowing has been changed to drop the `?const` candidate in favor of the const candidate, to avoid ambiguities when both a const and a non-const bound is present.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
