Skip to content

Commit 4beb774

Browse files
committed
don't mark the zst allocation as static
1 parent 080d3e4 commit 4beb774

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/memory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
632632
impl<'a, 'tcx> Memory<'a, 'tcx> {
633633
/// mark an allocation as being the entry point to a static (see `static_alloc` field)
634634
pub fn mark_static(&mut self, alloc_id: AllocId) {
635-
if !self.static_alloc.insert(alloc_id) {
635+
if alloc_id != NEVER_ALLOC_ID && alloc_id != ZST_ALLOC_ID && !self.static_alloc.insert(alloc_id) {
636636
bug!("tried to mark an allocation ({:?}) as static twice", alloc_id);
637637
}
638638
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![allow(unused_variables)]
12+
13+
#![feature(associated_consts)]
14+
15+
#[derive(Clone, Copy, Debug)]
16+
struct Bar;
17+
18+
const BAZ: Bar = Bar;
19+
20+
#[derive(Debug)]
21+
struct Foo([Bar; 1]);
22+
23+
struct Biz;
24+
25+
impl Biz {
26+
const BAZ: Foo = Foo([BAZ; 1]);
27+
}
28+
29+
fn main() {
30+
let foo = Biz::BAZ;
31+
}

0 commit comments

Comments
 (0)