Skip to content

Commit 02af3e3

Browse files
committed
Sync from rust 7b4f489
2 parents 0b9e8c6 + 7e23d77 commit 02af3e3

File tree

4 files changed

+15
-27
lines changed

4 files changed

+15
-27
lines changed

example/alloc_system.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
// Copyright 2015 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.
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
// SPDX-FileCopyrightText: The Rust Project Developers (see https://thanks.rust-lang.org)
3+
104
#![no_std]
115

126
pub struct System;

src/allocator.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use crate::prelude::*;
55

66
use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
7+
use rustc_codegen_ssa::base::allocator_kind_for_codegen;
78
use rustc_session::config::OomStrategy;
89
use rustc_span::symbol::sym;
910

@@ -13,24 +14,15 @@ pub(crate) fn codegen(
1314
module: &mut impl Module,
1415
unwind_context: &mut UnwindContext,
1516
) -> bool {
16-
let any_dynamic_crate = tcx.dependency_formats(()).iter().any(|(_, list)| {
17-
use rustc_middle::middle::dependency_format::Linkage;
18-
list.iter().any(|&linkage| linkage == Linkage::Dynamic)
19-
});
20-
if any_dynamic_crate {
21-
false
22-
} else if let Some(kind) = tcx.allocator_kind(()) {
23-
codegen_inner(
24-
module,
25-
unwind_context,
26-
kind,
27-
tcx.alloc_error_handler_kind(()).unwrap(),
28-
tcx.sess.opts.unstable_opts.oom,
29-
);
30-
true
31-
} else {
32-
false
33-
}
17+
let Some(kind) = allocator_kind_for_codegen(tcx) else { return false };
18+
codegen_inner(
19+
module,
20+
unwind_context,
21+
kind,
22+
tcx.alloc_error_handler_kind(()).unwrap(),
23+
tcx.sess.opts.unstable_opts.oom,
24+
);
25+
true
3426
}
3527

3628
fn codegen_inner(

src/base.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ fn codegen_stmt<'tcx>(
815815
| StatementKind::Nop
816816
| StatementKind::FakeRead(..)
817817
| StatementKind::Retag { .. }
818+
| StatementKind::PlaceMention(..)
818819
| StatementKind::AscribeUserType(..) => {}
819820

820821
StatementKind::Coverage { .. } => fx.tcx.sess.fatal("-Zcoverage is unimplemented"),

src/constant.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
529529
| StatementKind::StorageDead(_)
530530
| StatementKind::Retag(_, _)
531531
| StatementKind::AscribeUserType(_, _)
532+
| StatementKind::PlaceMention(..)
532533
| StatementKind::Coverage(_)
533534
| StatementKind::ConstEvalCounter
534535
| StatementKind::Nop => {}

0 commit comments

Comments
 (0)