about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-10-23 14:58:41 +0200
committerGitHub <noreply@github.com>2021-10-23 14:58:41 +0200
commit2b874f0242ee8e27af9961dd1a8712390832f1ad (patch)
tree0e97a5e0b9723413f371d2b85221b3fd74ae5900 /compiler/rustc_codegen_llvm/src
parent17c602d423b7e881828f027e26357f750d2b0395 (diff)
parenta400f1058e53cf9603e82b7fd00d42df159b8361 (diff)
downloadrust-2b874f0242ee8e27af9961dd1a8712390832f1ad.tar.gz
rust-2b874f0242ee8e27af9961dd1a8712390832f1ad.zip
Rollup merge of #89829 - voidc:assoc-const-variance, r=lcnr
Consider types appearing in const expressions to be invariant

This is an approach to fix #80977.
Currently, a type parameter which is only used in a constant expression is considered bivariant and will trigger error E0392 *"parameter T is never used"*.
Here is a short example:

```rust
pub trait Foo {
    const N: usize;
}

struct Bar<T: Foo>([u8; T::N])
where [(); T::N]:;
```
([playgound](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2015&gist=b51a272853f75925e72efc1597478aa5))

While it is possible to silence this error by adding a `PhantomData<T>` field, I think the better solution would be to make `T` invariant.
This would be analogous to the invariance constraints added for associated types.
However, I'm quite new to the compiler and unsure whether this is the right approach.

r? ``@varkor`` (since you authored #60058)
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions