Skip to content

Commit 88e9820

Browse files
committed
Fix review comments
1 parent 2e25b58 commit 88e9820

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

compiler/rustc_ast/src/expand/allocator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub fn default_fn_name(base: Symbol) -> String {
1818
pub const ALLOC_ERROR_HANDLER: Symbol = sym::alloc_error_handler;
1919
pub const NO_ALLOC_SHIM_IS_UNSTABLE: &str = "__rust_no_alloc_shim_is_unstable_v2";
2020

21+
/// Argument or return type for methods in the allocator shim
2122
#[derive(Copy, Clone)]
2223
pub enum AllocatorTy {
2324
Layout,

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,8 @@ pub fn allocator_shim_contents(tcx: TyCtxt<'_>, kind: AllocatorKind) -> Vec<Allo
664664
methods.extend(ALLOCATOR_METHODS.into_iter().copied());
665665
}
666666

667-
// If allocator_kind is Some then alloc_error_handler_kind must
668-
// also be Some.
667+
// If the return value of allocator_kind_for_codegen is Some then
668+
// alloc_error_handler_kind must also be Some.
669669
if tcx.alloc_error_handler_kind(()).unwrap() == AllocatorKind::Default {
670670
methods.push(AllocatorMethod {
671671
name: ALLOC_ERROR_HANDLER,

compiler/rustc_metadata/src/creader.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,17 +1087,15 @@ impl CStore {
10871087
}
10881088
spans => !spans.is_empty(),
10891089
};
1090-
self.has_alloc_error_handler =
1091-
match &*fn_spans(krate, Symbol::intern(&global_fn_name(ALLOC_ERROR_HANDLER))) {
1092-
[span1, span2, ..] => {
1093-
tcx.dcx().emit_err(errors::NoMultipleAllocErrorHandler {
1094-
span2: *span2,
1095-
span1: *span1,
1096-
});
1097-
true
1098-
}
1099-
spans => !spans.is_empty(),
1100-
};
1090+
let alloc_error_handler = Symbol::intern(&global_fn_name(ALLOC_ERROR_HANDLER));
1091+
self.has_alloc_error_handler = match &*fn_spans(krate, alloc_error_handler) {
1092+
[span1, span2, ..] => {
1093+
tcx.dcx()
1094+
.emit_err(errors::NoMultipleAllocErrorHandler { span2: *span2, span1: *span1 });
1095+
true
1096+
}
1097+
spans => !spans.is_empty(),
1098+
};
11011099

11021100
// Check to see if we actually need an allocator. This desire comes
11031101
// about through the `#![needs_allocator]` attribute and is typically

0 commit comments

Comments
 (0)