Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #114821

Merged
merged 10 commits into from
Aug 14, 2023
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/intrinsicck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
let asm_ty = match *ty.kind() {
// `!` is allowed for input but not for output (issue #87802)
ty::Never if is_input => return None,
ty::Error(_) => return None,
_ if ty.references_error() => return None,
ty::Int(IntTy::I8) | ty::Uint(UintTy::U8) => Some(InlineAsmType::I8),
ty::Int(IntTy::I16) | ty::Uint(UintTy::U16) => Some(InlineAsmType::I16),
ty::Int(IntTy::I32) | ty::Uint(UintTy::U32) => Some(InlineAsmType::I32),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_mir_build/src/thir/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ impl<'tcx> Cx<'tcx> {
let rhs = self.mirror_expr(rhs);
self.overloaded_operator(expr, Box::new([lhs, rhs]))
} else {
// FIXME overflow
match op.node {
hir::BinOpKind::And => ExprKind::LogicalOp {
op: LogicalOp::And,
Expand Down
23 changes: 18 additions & 5 deletions compiler/rustc_smir/src/rustc_smir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use crate::rustc_internal::{self, opaque};
use crate::stable_mir::mir::{CopyNonOverlapping, UserTypeProjection, VariantIdx};
use crate::stable_mir::ty::{
allocation_filter, new_allocation, FloatTy, IntTy, Movability, RigidTy, TyKind, UintTy,
allocation_filter, new_allocation, Const, FloatTy, IntTy, Movability, RigidTy, TyKind, UintTy,
};
use crate::stable_mir::{self, Context};
use rustc_hir as hir;
Expand Down Expand Up @@ -187,7 +187,11 @@ impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> {
use mir::Rvalue::*;
match self {
Use(op) => stable_mir::mir::Rvalue::Use(op.stable(tables)),
Repeat(op, len) => stable_mir::mir::Rvalue::Repeat(op.stable(tables), opaque(len)),
Repeat(op, len) => {
let cnst = ConstantKind::from_const(*len, tables.tcx);
let len = Const { literal: cnst.stable(tables) };
stable_mir::mir::Rvalue::Repeat(op.stable(tables), len)
}
Ref(region, kind, place) => stable_mir::mir::Rvalue::Ref(
opaque(region),
kind.stable(tables),
Expand Down Expand Up @@ -372,7 +376,11 @@ impl<'tcx> Stable<'tcx> for ty::TermKind<'tcx> {
use stable_mir::ty::TermKind;
match self {
ty::TermKind::Ty(ty) => TermKind::Type(tables.intern_ty(*ty)),
ty::TermKind::Const(const_) => TermKind::Const(opaque(const_)),
ty::TermKind::Const(cnst) => {
let cnst = ConstantKind::from_const(*cnst, tables.tcx);
let cnst = Const { literal: cnst.stable(tables) };
TermKind::Const(cnst)
}
}
}
}
Expand Down Expand Up @@ -829,7 +837,10 @@ impl<'tcx> Stable<'tcx> for ty::GenericArgKind<'tcx> {
match self {
ty::GenericArgKind::Lifetime(region) => GenericArgKind::Lifetime(opaque(region)),
ty::GenericArgKind::Type(ty) => GenericArgKind::Type(tables.intern_ty(*ty)),
ty::GenericArgKind::Const(const_) => GenericArgKind::Const(opaque(&const_)),
ty::GenericArgKind::Const(cnst) => {
let cnst = ConstantKind::from_const(*cnst, tables.tcx);
GenericArgKind::Const(stable_mir::ty::Const { literal: cnst.stable(tables) })
}
}
}
}
Expand Down Expand Up @@ -1035,7 +1046,9 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
}
ty::Str => TyKind::RigidTy(RigidTy::Str),
ty::Array(ty, constant) => {
TyKind::RigidTy(RigidTy::Array(tables.intern_ty(*ty), opaque(constant)))
let cnst = ConstantKind::from_const(*constant, tables.tcx);
let cnst = stable_mir::ty::Const { literal: cnst.stable(tables) };
TyKind::RigidTy(RigidTy::Array(tables.intern_ty(*ty), cnst))
}
ty::Slice(ty) => TyKind::RigidTy(RigidTy::Slice(tables.intern_ty(*ty))),
ty::RawPtr(ty::TypeAndMut { ty, mutbl }) => {
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_smir/src/stable_mir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ impl Ty {
}
}

pub(crate) type Const = Opaque;
#[derive(Debug, Clone)]
pub struct Const {
pub literal: ConstantKind,
}

type Ident = Opaque;
pub(crate) type Region = Opaque;
type Span = Opaque;
Expand Down
2 changes: 1 addition & 1 deletion src/doc/embedded-book
2 changes: 1 addition & 1 deletion src/doc/nomicon
Submodule nomicon updated 1 files
+1 −0 src/ffi.md
2 changes: 1 addition & 1 deletion src/doc/reference
26 changes: 26 additions & 0 deletions tests/codegen/method-declaration.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// compile-flags: -g -Cno-prepopulate-passes

// Verify that we added a declaration for a method.

// CHECK: define{{.*}}@method{{.*}} !dbg ![[METHOD_DEF_DBG:[0-9]+]]
// CHECK: define{{.*}}@function{{.*}} !dbg ![[FUNC_DEF_DBG:[0-9]+]]

#![crate_type = "lib"]

// CHECK-DAG: ![[FOO_DBG:[0-9]+]] = !DICompositeType(tag: {{.*}} name: "Foo", {{.*}} identifier:
pub struct Foo;

impl Foo {
// CHECK-DAG: ![[METHOD_DEF_DBG]] = distinct !DISubprogram(name: "method"{{.*}}, scope: ![[FOO_DBG]]{{.*}}DISPFlagDefinition{{.*}}, declaration: ![[METHOD_DECL_DBG:[0-9]+]]
// CHECK-DAG: ![[METHOD_DECL_DBG]] = !DISubprogram(name: "method"{{.*}}, scope: ![[FOO_DBG]]
#[no_mangle]
pub fn method() {}
}

// CHECK: ![[FUNC_DEF_DBG]] = distinct !DISubprogram(name: "function"
// CHECK-NOT: declaration
// CHECK-SAME: DISPFlagDefinition
// CHECK-NOT: declaration
// CHECK-SAME: )
#[no_mangle]
pub fn function() {}
7 changes: 7 additions & 0 deletions tests/ui/asm/issue-113788.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// test that "error: arguments for inline assembly must be copyable" doesn't show up in this code
// needs-asm-support
// only-x86_64
fn main() {
let peb: *const PEB; //~ ERROR cannot find type `PEB` in this scope [E0412]
unsafe { std::arch::asm!("mov {0}, fs:[0x30]", out(reg) peb); }
}
9 changes: 9 additions & 0 deletions tests/ui/asm/issue-113788.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0412]: cannot find type `PEB` in this scope
--> $DIR/issue-113788.rs:5:21
|
LL | let peb: *const PEB;
| ^^^ not found in this scope

error: aborting due to previous error

For more information about this error, try `rustc --explain E0412`.
Loading