Skip to content

Commit 18a109e

Browse files
committed
Sync from rust aed2187
2 parents 1122338 + 9a57c63 commit 18a109e

File tree

6 files changed

+22
-16
lines changed

6 files changed

+22
-16
lines changed

example/example.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub fn array_as_slice(arr: &[u8; 3]) -> &[u8] {
149149
arr
150150
}
151151

152-
pub unsafe fn use_ctlz_nonzero(a: u16) -> u16 {
152+
pub unsafe fn use_ctlz_nonzero(a: u16) -> u32 {
153153
intrinsics::ctlz_nonzero(a)
154154
}
155155

example/mini_core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ pub mod intrinsics {
627627
pub fn min_align_of_val<T: ?::Sized>(val: *const T) -> usize;
628628
pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
629629
pub fn transmute<T, U>(e: T) -> U;
630-
pub fn ctlz_nonzero<T>(x: T) -> T;
630+
pub fn ctlz_nonzero<T>(x: T) -> u32;
631631
#[rustc_safe_intrinsic]
632632
pub fn needs_drop<T: ?::Sized>() -> bool;
633633
#[rustc_safe_intrinsic]

example/polymorphize_coroutine.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(coroutines, coroutine_trait)]
1+
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
22

33
use std::ops::Coroutine;
44
use std::pin::Pin;
@@ -8,7 +8,8 @@ fn main() {
88
}
99

1010
fn run_coroutine<T>() {
11-
let mut coroutine = || {
11+
let mut coroutine = #[coroutine]
12+
|| {
1213
yield;
1314
return;
1415
};

example/std_example.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![feature(
22
core_intrinsics,
33
coroutines,
4+
stmt_expr_attributes,
45
coroutine_trait,
56
is_sorted,
67
repr_simd,
@@ -123,9 +124,12 @@ fn main() {
123124
test_simd();
124125
}
125126

126-
Box::pin(move |mut _task_context| {
127-
yield ();
128-
})
127+
Box::pin(
128+
#[coroutine]
129+
move |mut _task_context| {
130+
yield ();
131+
},
132+
)
129133
.as_mut()
130134
.resume(0);
131135

src/debuginfo/line_info.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use cranelift_codegen::binemit::CodeOffset;
77
use cranelift_codegen::MachSrcLoc;
88
use gimli::write::{AttributeValue, FileId, FileInfo, LineProgram, LineString, LineStringTable};
99
use rustc_span::{
10-
FileName, Pos, SourceFile, SourceFileAndLine, SourceFileHash, SourceFileHashAlgorithm,
10+
hygiene, FileName, Pos, SourceFile, SourceFileAndLine, SourceFileHash, SourceFileHashAlgorithm,
1111
};
1212

1313
use crate::debuginfo::emit::address_for_func;
@@ -63,11 +63,8 @@ impl DebugContext {
6363
function_span: Span,
6464
span: Span,
6565
) -> (FileId, u64, u64) {
66-
// Based on https://github.com/rust-lang/rust/blob/e369d87b015a84653343032833d65d0545fd3f26/src/librustc_codegen_ssa/mir/mod.rs#L116-L131
67-
// In order to have a good line stepping behavior in debugger, we overwrite debug
68-
// locations of macro expansions with that of the outermost expansion site (when the macro is
69-
// annotated with `#[collapse_debuginfo]` or when `-Zdebug-macros` is provided).
70-
let span = tcx.collapsed_debuginfo(span, function_span);
66+
// Match behavior of `FunctionCx::adjusted_span_and_dbg_scope`.
67+
let span = hygiene::walk_chain_collapsed(span, function_span);
7168
match tcx.sess.source_map().lookup_line(span.lo()) {
7269
Ok(SourceFileAndLine { sf: file, line }) => {
7370
let file_id = self.add_source_file(&file);

src/intrinsics/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use rustc_span::source_map::Spanned;
2626
use rustc_span::symbol::{sym, Symbol};
2727

2828
pub(crate) use self::llvm::codegen_llvm_intrinsic_call;
29+
use crate::cast::clif_intcast;
2930
use crate::prelude::*;
3031

3132
fn bug_on_incorrect_arg_count(intrinsic: impl std::fmt::Display) -> ! {
@@ -627,7 +628,8 @@ fn codegen_regular_intrinsic_call<'tcx>(
627628

628629
// FIXME trap on `ctlz_nonzero` with zero arg.
629630
let res = fx.bcx.ins().clz(val);
630-
let res = CValue::by_val(res, arg.layout());
631+
let res = clif_intcast(fx, res, types::I32, false);
632+
let res = CValue::by_val(res, ret.layout());
631633
ret.write_cvalue(fx, res);
632634
}
633635
sym::cttz | sym::cttz_nonzero => {
@@ -636,15 +638,17 @@ fn codegen_regular_intrinsic_call<'tcx>(
636638

637639
// FIXME trap on `cttz_nonzero` with zero arg.
638640
let res = fx.bcx.ins().ctz(val);
639-
let res = CValue::by_val(res, arg.layout());
641+
let res = clif_intcast(fx, res, types::I32, false);
642+
let res = CValue::by_val(res, ret.layout());
640643
ret.write_cvalue(fx, res);
641644
}
642645
sym::ctpop => {
643646
intrinsic_args!(fx, args => (arg); intrinsic);
644647
let val = arg.load_scalar(fx);
645648

646649
let res = fx.bcx.ins().popcnt(val);
647-
let res = CValue::by_val(res, arg.layout());
650+
let res = clif_intcast(fx, res, types::I32, false);
651+
let res = CValue::by_val(res, ret.layout());
648652
ret.write_cvalue(fx, res);
649653
}
650654
sym::bitreverse => {

0 commit comments

Comments
 (0)