Skip to content

Commit e942e62

Browse files
committed
Remove CloneShim-related logic for TyKind::Array
As of rust-lang/rust#86041, `Clone` impls for array types are now implemented in library code rather than using `clone` shims. As such, the `TyKind::Array` case in the code surrounding `CloneShim`s is now unreachable. This removes the code to simplify things. To prevent future regressions, this adds a test case that `clone`s an array and ensures that it does not emit a `don't know how to build clone shim` warning. Fixes #197.
1 parent 9161454 commit e942e62

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

src/analyz/ty_json.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ impl<'tcx> ToJson<'tcx> for ty::Instance<'tcx> {
389389
}),
390390
ty::InstanceKind::CloneShim(did, ty) => {
391391
let sub_tys = match *ty.kind() {
392-
ty::TyKind::Array(t, _) => vec![t],
393392
ty::TyKind::Tuple(ts) => ts[..].to_owned(),
394393
ty::TyKind::Closure(_closure_did, args) =>
395394
args.as_closure().upvar_tys()[..].to_owned(),

tests/common.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,18 @@ expect_json_contains() {
3333
exit 1
3434
fi
3535
}
36+
37+
expect_output_does_not_contain() {
38+
set +e
39+
output=$("${@:2}" 2>&1)
40+
status=$?
41+
set -e
42+
43+
if echo "$output" | grep -q "$1"; then
44+
echo "Output contains '$1'"
45+
echo "$output"
46+
return 1
47+
fi
48+
49+
echo "Output does not contain '$1'"
50+
}

tests/issues/test0197/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
A test which ensures that `mir-json` can successfully compile a test case that
2+
`clone`s an array without warnings, the subject of
3+
[mir-json#197](https://github.com/GaloisInc/mir-json/issues/197). This used to
4+
require creating a `clone` shim, but as of
5+
https://github.com/rust-lang/rust/pull/86041, `Clone` impls for array types are
6+
now implemented in library code rather using `clone` shims. As such, `mir-json`
7+
no longer needs any `clone` shim logic for arrays, and it should be able to
8+
compile the given test case without issues.

tests/issues/test0197/test.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pub fn f() {
2+
let x = [1, 2, 3];
3+
let y = x.clone();
4+
assert!(x == y);
5+
}

tests/issues/test0197/test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
source "$(dirname "$0")/../../common.sh"
4+
5+
expect_output_does_not_contain "don't know how to build clone shim" \
6+
saw-rustc test.rs \
7+
--target "$(rustc --print host-tuple)"

0 commit comments

Comments
 (0)