diff options
| author | bors <bors@rust-lang.org> | 2022-10-04 13:04:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-10-04 13:04:57 +0000 |
| commit | 02cd79afb8080fce8c8ce35533c54d8ecf8f390e (patch) | |
| tree | b8194a8a03bdb4b497e7766ceaf273decda95a6d /compiler/rustc_const_eval/src | |
| parent | ead49f0beb7e36007aeed59f862f10f72b889c59 (diff) | |
| parent | f7ca4652723aa372592d47f495186fb27d10186a (diff) | |
| download | rust-02cd79afb8080fce8c8ce35533c54d8ecf8f390e.tar.gz rust-02cd79afb8080fce8c8ce35533c54d8ecf8f390e.zip | |
Auto merge of #102652 - Dylan-DPC:rollup-6ff8ct8, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #101189 (Implement `Ready::into_inner()`) - #101642 (Fix in-place collection leak when remaining element destructor panic) - #102489 (Normalize substs before resolving instance in `NoopMethodCall` lint) - #102559 (Don't ICE when trying to copy unsized value in const prop) - #102568 (Lint against nested opaque types that don't satisfy associated type bounds) - #102633 (Fix rustdoc ICE in invalid_rust_codeblocks lint) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/place.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index 7a01b85381a..eeeb7d6d3e5 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -640,11 +640,17 @@ where // avoid force_allocation. let src = match self.read_immediate_raw(src)? { Ok(src_val) => { - assert!(!src.layout.is_unsized(), "cannot copy unsized immediates"); - assert!( - !dest.layout.is_unsized(), - "the src is sized, so the dest must also be sized" - ); + // FIXME(const_prop): Const-prop can possibly evaluate an + // unsized copy operation when it thinks that the type is + // actually sized, due to a trivially false where-clause + // predicate like `where Self: Sized` with `Self = dyn Trait`. + // See #102553 for an example of such a predicate. + if src.layout.is_unsized() { + throw_inval!(SizeOfUnsizedType(src.layout.ty)); + } + if dest.layout.is_unsized() { + throw_inval!(SizeOfUnsizedType(dest.layout.ty)); + } assert_eq!(src.layout.size, dest.layout.size); // Yay, we got a value that we can write directly. return if layout_compat { |
