Skip to content

Commit

Permalink
Auto merge of rust-lang#73259 - Dylan-DPC:rollup-m6nw1n0, r=Dylan-DPC
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jun 11, 2020
2 parents a37c32e + 85a48d0 commit 14027f3
Show file tree
Hide file tree
Showing 26 changed files with 2,278 additions and 112 deletions.
8 changes: 0 additions & 8 deletions src/libcore/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2623,15 +2623,7 @@ unsafe fn atomic_umin<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(target_arch = "wasm32", allow(unused_variables))]
pub fn fence(order: Ordering) {
// On wasm32 it looks like fences aren't implemented in LLVM yet in that
// they will cause LLVM to abort. The wasm instruction set doesn't have
// fences right now. There's discussion online about the best way for tools
// to conventionally implement fences at
// https://github.com/WebAssembly/tool-conventions/issues/59. We should
// follow that discussion and implement a solution when one comes about!
#[cfg(not(target_arch = "wasm32"))]
// SAFETY: using an atomic fence is safe.
unsafe {
match order {
Expand Down
8 changes: 2 additions & 6 deletions src/librustc_codegen_ssa/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -927,12 +927,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
span_bug!(span, "invalid type for asm sym (fn)");
}
}
mir::InlineAsmOperand::SymStatic { ref value } => {
if let Some(def_id) = value.check_static_ptr(bx.tcx()) {
InlineAsmOperandRef::SymStatic { def_id }
} else {
span_bug!(span, "invalid type for asm sym (static)");
}
mir::InlineAsmOperand::SymStatic { def_id } => {
InlineAsmOperandRef::SymStatic { def_id }
}
})
.collect();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ E0718: include_str!("./error_codes/E0718.md"),
E0719: include_str!("./error_codes/E0719.md"),
E0720: include_str!("./error_codes/E0720.md"),
E0723: include_str!("./error_codes/E0723.md"),
E0724: include_str!("./error_codes/E0724.md"),
E0725: include_str!("./error_codes/E0725.md"),
E0727: include_str!("./error_codes/E0727.md"),
E0728: include_str!("./error_codes/E0728.md"),
Expand Down Expand Up @@ -617,7 +618,6 @@ E0762: include_str!("./error_codes/E0762.md"),
E0717, // rustc_promotable without stability attribute
// E0721, // `await` keyword
E0722, // Malformed `#[optimize]` attribute
E0724, // `#[ffi_returns_twice]` is only allowed in foreign functions
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
// E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`.
E0755, // `#[ffi_pure]` is only allowed on foreign functions
Expand Down
24 changes: 24 additions & 0 deletions src/librustc_error_codes/error_codes/E0724.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
`#[ffi_returns_twice]` was used on non-foreign function.

Erroneous code example:

```compile_fail,E0724
#![feature(ffi_returns_twice)]
#![crate_type = "lib"]
#[ffi_returns_twice] // error!
pub fn foo() {}
```

`#[ffi_returns_twice]` can only be used on foreign function declarations.
For example, we might correct the previous example by declaring
the function inside of an `extern` block.

```
#![feature(ffi_returns_twice)]
extern {
#[ffi_returns_twice] // ok!
pub fn foo();
}
```
10 changes: 6 additions & 4 deletions src/librustc_middle/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ pub enum InlineAsmOperand<'tcx> {
value: Box<Constant<'tcx>>,
},
SymStatic {
value: Box<Constant<'tcx>>,
def_id: DefId,
},
}

Expand Down Expand Up @@ -1639,9 +1639,11 @@ impl<'tcx> TerminatorKind<'tcx> {
InlineAsmOperand::Const { value } => {
write!(fmt, "const {:?}", value)?;
}
InlineAsmOperand::SymFn { value }
| InlineAsmOperand::SymStatic { value } => {
write!(fmt, "sym {:?}", value)?;
InlineAsmOperand::SymFn { value } => {
write!(fmt, "sym_fn {:?}", value)?;
}
InlineAsmOperand::SymStatic { def_id } => {
write!(fmt, "sym_static {:?}", def_id)?;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_middle/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,10 @@ macro_rules! make_mir_visitor {
);
}
}
InlineAsmOperand::SymFn { value }
| InlineAsmOperand::SymStatic { value } => {
InlineAsmOperand::SymFn { value } => {
self.visit_constant(value, source_location);
}
InlineAsmOperand::SymStatic { def_id: _ } => {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/invalidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
}
}
InlineAsmOperand::SymFn { value: _ }
| InlineAsmOperand::SymStatic { value: _ } => {}
| InlineAsmOperand::SymStatic { def_id: _ } => {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc
}
}
InlineAsmOperand::SymFn { value: _ }
| InlineAsmOperand::SymStatic { value: _ } => {}
| InlineAsmOperand::SymStatic { def_id: _ } => {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/dataflow/move_paths/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
}
}
InlineAsmOperand::SymFn { value: _ }
| InlineAsmOperand::SymStatic { value: _ } => {}
| InlineAsmOperand::SymStatic { def_id: _ } => {}
}
}
}
Expand Down
16 changes: 13 additions & 3 deletions src/librustc_mir/monomorphize/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,19 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
}
mir::TerminatorKind::InlineAsm { ref operands, .. } => {
for op in operands {
if let mir::InlineAsmOperand::SymFn { value } = op {
let fn_ty = self.monomorphize(value.literal.ty);
visit_fn_use(self.tcx, fn_ty, false, &mut self.output);
match *op {
mir::InlineAsmOperand::SymFn { ref value } => {
let fn_ty = self.monomorphize(value.literal.ty);
visit_fn_use(self.tcx, fn_ty, false, &mut self.output);
}
mir::InlineAsmOperand::SymStatic { def_id } => {
let instance = Instance::mono(self.tcx, def_id);
if should_monomorphize_locally(self.tcx, &instance) {
trace!("collecting asm sym static {:?}", def_id);
self.output.push(MonoItem::Static(def_id));
}
}
_ => {}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir_build/build/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
hair::InlineAsmOperand::SymFn { expr } => {
mir::InlineAsmOperand::SymFn { value: box this.as_constant(expr) }
}
hair::InlineAsmOperand::SymStatic { expr } => {
mir::InlineAsmOperand::SymStatic { value: box this.as_constant(expr) }
hair::InlineAsmOperand::SymStatic { def_id } => {
mir::InlineAsmOperand::SymStatic { def_id }
}
})
.collect();
Expand Down
21 changes: 2 additions & 19 deletions src/librustc_mir_build/hair/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,25 +467,8 @@ fn make_mirror_unadjusted<'a, 'tcx>(
}
}

Res::Def(DefKind::Static, id) => {
ty = cx.tcx.static_ptr_ty(id);
let ptr = cx.tcx.create_static_alloc(id);
InlineAsmOperand::SymStatic {
expr: Expr {
ty,
temp_lifetime,
span: expr.span,
kind: ExprKind::StaticRef {
literal: ty::Const::from_scalar(
cx.tcx,
Scalar::Ptr(ptr.into()),
ty,
),
def_id: id,
},
}
.to_ref(),
}
Res::Def(DefKind::Static, def_id) => {
InlineAsmOperand::SymStatic { def_id }
}

_ => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/hair/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ crate enum InlineAsmOperand<'tcx> {
expr: ExprRef<'tcx>,
},
SymStatic {
expr: ExprRef<'tcx>,
def_id: DefId,
},
}

Expand Down
2 changes: 2 additions & 0 deletions src/librustc_span/def_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ impl rustc_serialize::UseSpecializedDecodable for DefIndex {}

/// A `DefId` identifies a particular *definition*, by combining a crate
/// index and a def index.
///
/// You can create a `DefId` from a `LocalDefId` using `local_def_id.to_def_id()`.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)]
pub struct DefId {
pub krate: CrateNum,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
}

if let Some(expr) = expression {
fcx.emit_coerce_suggestions(&mut err, expr, found, expected);
fcx.emit_coerce_suggestions(&mut err, expr, found, expected, None);
}

// Error possibly reported in `check_assign` so avoid emitting error again.
Expand Down
Loading

0 comments on commit 14027f3

Please sign in to comment.