Skip to content

Commit 14027f3

Browse files
committed
Auto merge of rust-lang#73259 - Dylan-DPC:rollup-m6nw1n0, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - rust-lang#73033 (Fix #[thread_local] statics as asm! sym operands) - rust-lang#73036 (std: Enable atomic.fence emission on wasm32) - rust-lang#73163 (Add long error explanation for E0724) - rust-lang#73187 (Remove missed `cfg(bootstrap)`) - rust-lang#73195 (Provide suggestion to convert numeric op LHS rather than unwrapping RHS) - rust-lang#73247 (Add various Zulip notifications for prioritization) - rust-lang#73254 (Add comment about LocalDefId -> DefId) Failed merges: r? @ghost
2 parents a37c32e + 85a48d0 commit 14027f3

File tree

26 files changed

+2278
-112
lines changed

26 files changed

+2278
-112
lines changed

src/libcore/sync/atomic.rs

-8
Original file line numberDiff line numberDiff line change
@@ -2623,15 +2623,7 @@ unsafe fn atomic_umin<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
26232623
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
26242624
#[inline]
26252625
#[stable(feature = "rust1", since = "1.0.0")]
2626-
#[cfg_attr(target_arch = "wasm32", allow(unused_variables))]
26272626
pub fn fence(order: Ordering) {
2628-
// On wasm32 it looks like fences aren't implemented in LLVM yet in that
2629-
// they will cause LLVM to abort. The wasm instruction set doesn't have
2630-
// fences right now. There's discussion online about the best way for tools
2631-
// to conventionally implement fences at
2632-
// https://github.com/WebAssembly/tool-conventions/issues/59. We should
2633-
// follow that discussion and implement a solution when one comes about!
2634-
#[cfg(not(target_arch = "wasm32"))]
26352627
// SAFETY: using an atomic fence is safe.
26362628
unsafe {
26372629
match order {

src/librustc_codegen_ssa/mir/block.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -927,12 +927,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
927927
span_bug!(span, "invalid type for asm sym (fn)");
928928
}
929929
}
930-
mir::InlineAsmOperand::SymStatic { ref value } => {
931-
if let Some(def_id) = value.check_static_ptr(bx.tcx()) {
932-
InlineAsmOperandRef::SymStatic { def_id }
933-
} else {
934-
span_bug!(span, "invalid type for asm sym (static)");
935-
}
930+
mir::InlineAsmOperand::SymStatic { def_id } => {
931+
InlineAsmOperandRef::SymStatic { def_id }
936932
}
937933
})
938934
.collect();

src/librustc_error_codes/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ E0718: include_str!("./error_codes/E0718.md"),
409409
E0719: include_str!("./error_codes/E0719.md"),
410410
E0720: include_str!("./error_codes/E0720.md"),
411411
E0723: include_str!("./error_codes/E0723.md"),
412+
E0724: include_str!("./error_codes/E0724.md"),
412413
E0725: include_str!("./error_codes/E0725.md"),
413414
E0727: include_str!("./error_codes/E0727.md"),
414415
E0728: include_str!("./error_codes/E0728.md"),
@@ -617,7 +618,6 @@ E0762: include_str!("./error_codes/E0762.md"),
617618
E0717, // rustc_promotable without stability attribute
618619
// E0721, // `await` keyword
619620
E0722, // Malformed `#[optimize]` attribute
620-
E0724, // `#[ffi_returns_twice]` is only allowed in foreign functions
621621
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
622622
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
623623
E0755, // `#[ffi_pure]` is only allowed on foreign functions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
`#[ffi_returns_twice]` was used on non-foreign function.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0724
6+
#![feature(ffi_returns_twice)]
7+
#![crate_type = "lib"]
8+
9+
#[ffi_returns_twice] // error!
10+
pub fn foo() {}
11+
```
12+
13+
`#[ffi_returns_twice]` can only be used on foreign function declarations.
14+
For example, we might correct the previous example by declaring
15+
the function inside of an `extern` block.
16+
17+
```
18+
#![feature(ffi_returns_twice)]
19+
20+
extern {
21+
#[ffi_returns_twice] // ok!
22+
pub fn foo();
23+
}
24+
```

src/librustc_middle/mir/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ pub enum InlineAsmOperand<'tcx> {
12431243
value: Box<Constant<'tcx>>,
12441244
},
12451245
SymStatic {
1246-
value: Box<Constant<'tcx>>,
1246+
def_id: DefId,
12471247
},
12481248
}
12491249

@@ -1639,9 +1639,11 @@ impl<'tcx> TerminatorKind<'tcx> {
16391639
InlineAsmOperand::Const { value } => {
16401640
write!(fmt, "const {:?}", value)?;
16411641
}
1642-
InlineAsmOperand::SymFn { value }
1643-
| InlineAsmOperand::SymStatic { value } => {
1644-
write!(fmt, "sym {:?}", value)?;
1642+
InlineAsmOperand::SymFn { value } => {
1643+
write!(fmt, "sym_fn {:?}", value)?;
1644+
}
1645+
InlineAsmOperand::SymStatic { def_id } => {
1646+
write!(fmt, "sym_static {:?}", def_id)?;
16451647
}
16461648
}
16471649
}

src/librustc_middle/mir/visit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -564,10 +564,10 @@ macro_rules! make_mir_visitor {
564564
);
565565
}
566566
}
567-
InlineAsmOperand::SymFn { value }
568-
| InlineAsmOperand::SymStatic { value } => {
567+
InlineAsmOperand::SymFn { value } => {
569568
self.visit_constant(value, source_location);
570569
}
570+
InlineAsmOperand::SymStatic { def_id: _ } => {}
571571
}
572572
}
573573
}

src/librustc_mir/borrow_check/invalidation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
209209
}
210210
}
211211
InlineAsmOperand::SymFn { value: _ }
212-
| InlineAsmOperand::SymStatic { value: _ } => {}
212+
| InlineAsmOperand::SymStatic { def_id: _ } => {}
213213
}
214214
}
215215
}

src/librustc_mir/borrow_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc
760760
}
761761
}
762762
InlineAsmOperand::SymFn { value: _ }
763-
| InlineAsmOperand::SymStatic { value: _ } => {}
763+
| InlineAsmOperand::SymStatic { def_id: _ } => {}
764764
}
765765
}
766766
}

src/librustc_mir/dataflow/move_paths/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
439439
}
440440
}
441441
InlineAsmOperand::SymFn { value: _ }
442-
| InlineAsmOperand::SymStatic { value: _ } => {}
442+
| InlineAsmOperand::SymStatic { def_id: _ } => {}
443443
}
444444
}
445445
}

src/librustc_mir/monomorphize/collector.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,19 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
634634
}
635635
mir::TerminatorKind::InlineAsm { ref operands, .. } => {
636636
for op in operands {
637-
if let mir::InlineAsmOperand::SymFn { value } = op {
638-
let fn_ty = self.monomorphize(value.literal.ty);
639-
visit_fn_use(self.tcx, fn_ty, false, &mut self.output);
637+
match *op {
638+
mir::InlineAsmOperand::SymFn { ref value } => {
639+
let fn_ty = self.monomorphize(value.literal.ty);
640+
visit_fn_use(self.tcx, fn_ty, false, &mut self.output);
641+
}
642+
mir::InlineAsmOperand::SymStatic { def_id } => {
643+
let instance = Instance::mono(self.tcx, def_id);
644+
if should_monomorphize_locally(self.tcx, &instance) {
645+
trace!("collecting asm sym static {:?}", def_id);
646+
self.output.push(MonoItem::Static(def_id));
647+
}
648+
}
649+
_ => {}
640650
}
641651
}
642652
}

src/librustc_mir_build/build/expr/into.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
358358
hair::InlineAsmOperand::SymFn { expr } => {
359359
mir::InlineAsmOperand::SymFn { value: box this.as_constant(expr) }
360360
}
361-
hair::InlineAsmOperand::SymStatic { expr } => {
362-
mir::InlineAsmOperand::SymStatic { value: box this.as_constant(expr) }
361+
hair::InlineAsmOperand::SymStatic { def_id } => {
362+
mir::InlineAsmOperand::SymStatic { def_id }
363363
}
364364
})
365365
.collect();

src/librustc_mir_build/hair/cx/expr.rs

+2-19
Original file line numberDiff line numberDiff line change
@@ -467,25 +467,8 @@ fn make_mirror_unadjusted<'a, 'tcx>(
467467
}
468468
}
469469

470-
Res::Def(DefKind::Static, id) => {
471-
ty = cx.tcx.static_ptr_ty(id);
472-
let ptr = cx.tcx.create_static_alloc(id);
473-
InlineAsmOperand::SymStatic {
474-
expr: Expr {
475-
ty,
476-
temp_lifetime,
477-
span: expr.span,
478-
kind: ExprKind::StaticRef {
479-
literal: ty::Const::from_scalar(
480-
cx.tcx,
481-
Scalar::Ptr(ptr.into()),
482-
ty,
483-
),
484-
def_id: id,
485-
},
486-
}
487-
.to_ref(),
488-
}
470+
Res::Def(DefKind::Static, def_id) => {
471+
InlineAsmOperand::SymStatic { def_id }
489472
}
490473

491474
_ => {

src/librustc_mir_build/hair/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ crate enum InlineAsmOperand<'tcx> {
377377
expr: ExprRef<'tcx>,
378378
},
379379
SymStatic {
380-
expr: ExprRef<'tcx>,
380+
def_id: DefId,
381381
},
382382
}
383383

src/librustc_span/def_id.rs

+2
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ impl rustc_serialize::UseSpecializedDecodable for DefIndex {}
133133

134134
/// A `DefId` identifies a particular *definition*, by combining a crate
135135
/// index and a def index.
136+
///
137+
/// You can create a `DefId` from a `LocalDefId` using `local_def_id.to_def_id()`.
136138
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)]
137139
pub struct DefId {
138140
pub krate: CrateNum,

src/librustc_typeck/check/coercion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
13771377
}
13781378

13791379
if let Some(expr) = expression {
1380-
fcx.emit_coerce_suggestions(&mut err, expr, found, expected);
1380+
fcx.emit_coerce_suggestions(&mut err, expr, found, expected, None);
13811381
}
13821382

13831383
// Error possibly reported in `check_assign` so avoid emitting error again.

0 commit comments

Comments
 (0)