diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-10-04 16:11:01 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-04 16:11:01 +0530 |
| commit | d89d21412bcb2f01b83ed8d2fe5199b6bf1011f5 (patch) | |
| tree | f99254ffe82959a67db624901b3ae5f02a46bf9b /src/test | |
| parent | f24d00d8b3f6a79fdf5b3352fa9fb84003c917d3 (diff) | |
| parent | e1b313af46b74a446d7772a261e006c199a5b2e0 (diff) | |
Rollup merge of #102489 - compiler-errors:issue-102074, r=oli-obk
Normalize substs before resolving instance in `NoopMethodCall` lint Fixes #102074 r? types
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/const-generics/generic_const_exprs/issue-102074.rs | 23 | ||||
| -rw-r--r-- | src/test/ui/lint/noop-method-call.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/lint/noop-method-call.stderr | 12 |
3 files changed, 34 insertions, 2 deletions
diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-102074.rs b/src/test/ui/const-generics/generic_const_exprs/issue-102074.rs new file mode 100644 index 00000000000..66d15cf1215 --- /dev/null +++ b/src/test/ui/const-generics/generic_const_exprs/issue-102074.rs @@ -0,0 +1,23 @@ +// check-pass +// Checks that the NoopMethodCall lint doesn't call Instance::resolve on unresolved consts + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +#[derive(Debug, Clone)] +pub struct Aes128CipherKey([u8; Aes128Cipher::KEY_LEN]); + +impl Aes128CipherKey { + pub fn new(key: &[u8; Aes128Cipher::KEY_LEN]) -> Self { + Self(key.clone()) + } +} + +#[derive(Debug, Clone)] +pub struct Aes128Cipher; + +impl Aes128Cipher { + const KEY_LEN: usize = 16; +} + +fn main() {} diff --git a/src/test/ui/lint/noop-method-call.rs b/src/test/ui/lint/noop-method-call.rs index 9870c813572..89b29663595 100644 --- a/src/test/ui/lint/noop-method-call.rs +++ b/src/test/ui/lint/noop-method-call.rs @@ -46,6 +46,7 @@ fn main() { fn generic<T>(non_clone_type: &PlainType<T>) { non_clone_type.clone(); + //~^ WARNING call to `.clone()` on a reference in this situation does nothing } fn non_generic(non_clone_type: &PlainType<u32>) { diff --git a/src/test/ui/lint/noop-method-call.stderr b/src/test/ui/lint/noop-method-call.stderr index c71de44dc71..6a904d01abc 100644 --- a/src/test/ui/lint/noop-method-call.stderr +++ b/src/test/ui/lint/noop-method-call.stderr @@ -28,12 +28,20 @@ LL | let non_borrow_type_borrow: &PlainType<u32> = non_borrow_type.borrow(); = note: the type `&PlainType<u32>` which `borrow` is being called on is the same as the type returned from `borrow`, so the method call does not do anything and can be removed warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:52:19 + --> $DIR/noop-method-call.rs:48:19 + | +LL | non_clone_type.clone(); + | ^^^^^^^^ unnecessary method call + | + = note: the type `&PlainType<T>` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed + +warning: call to `.clone()` on a reference in this situation does nothing + --> $DIR/noop-method-call.rs:53:19 | LL | non_clone_type.clone(); | ^^^^^^^^ unnecessary method call | = note: the type `&PlainType<u32>` which `clone` is being called on is the same as the type returned from `clone`, so the method call does not do anything and can be removed -warning: 4 warnings emitted +warning: 5 warnings emitted |
