diff options
| author | bors <bors@rust-lang.org> | 2023-08-14 20:01:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-14 20:01:12 +0000 |
| commit | f960bdf1feacad4ab5a079c76ff31053c1799f71 (patch) | |
| tree | 69c0d9ba66b39bdcebb231b85fece5c86337425a | |
| parent | 4cea2bc339db4efdc0fbcf44760c2e9a75d73e31 (diff) | |
| parent | 5f0c17faa7a1f3179292d6aa578ec849904ff60d (diff) | |
| download | rust-f960bdf1feacad4ab5a079c76ff31053c1799f71.tar.gz rust-f960bdf1feacad4ab5a079c76ff31053c1799f71.zip | |
Auto merge of #114821 - matthiaskrgr:rollup-bahtz9m, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #114745 (Make Const more useful in smir) - #114752 (fixed *const [type error] does not implement the Copy trait) - #114760 (DebugInfo: Updates test cases that add method declarations.) - #114815 (Update books) - #114817 (Remove unnecessary FIXME) r? `@ghost` `@rustbot` modify labels: rollup
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/intrinsicck.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/cx/expr.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_smir/src/rustc_smir/mod.rs | 23 | ||||
| -rw-r--r-- | compiler/rustc_smir/src/stable_mir/ty.rs | 6 | ||||
| m--------- | src/doc/book | 0 | ||||
| m--------- | src/doc/embedded-book | 0 | ||||
| m--------- | src/doc/nomicon | 0 | ||||
| m--------- | src/doc/reference | 0 | ||||
| m--------- | src/doc/rustc-dev-guide | 0 | ||||
| -rw-r--r-- | tests/codegen/method-declaration.rs | 26 | ||||
| -rw-r--r-- | tests/ui/asm/issue-113788.rs | 7 | ||||
| -rw-r--r-- | tests/ui/asm/issue-113788.stderr | 9 |
12 files changed, 66 insertions, 8 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs index b0dd5e5787d..945953edd5a 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs @@ -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), diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 994ac8a3286..a96d837b3ad 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -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, diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index bc12422e7d7..06b37008ebe 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -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; @@ -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), @@ -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) + } } } } @@ -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) }) + } } } } @@ -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 }) => { diff --git a/compiler/rustc_smir/src/stable_mir/ty.rs b/compiler/rustc_smir/src/stable_mir/ty.rs index 875d5ae70da..f8ff6741208 100644 --- a/compiler/rustc_smir/src/stable_mir/ty.rs +++ b/compiler/rustc_smir/src/stable_mir/ty.rs @@ -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; diff --git a/src/doc/book b/src/doc/book -Subproject 668c64760b5c7ea654facb4ba5fe9faddfda27c +Subproject 72187f5cd0beaaa9c6f584156bcd88f921871e8 diff --git a/src/doc/embedded-book b/src/doc/embedded-book -Subproject 1e5556dd1b864109985d5871616ae6b9164bcea +Subproject 99ad2847b865e96d8ae7b333d3ee96963557e62 diff --git a/src/doc/nomicon b/src/doc/nomicon -Subproject 302b995bcb24b70fd883980fd174738c3a10b70 +Subproject 388750b081c0893c275044d37203f97709e058b diff --git a/src/doc/reference b/src/doc/reference -Subproject 9cd5c5a6ccbd4c07c65ab5c69a53286280308c9 +Subproject d43038932adeb16ada80e206d4c073d85129810 diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide -Subproject 24eebb6df96d037aad285e4f7793bd0393a6687 +Subproject b123ab4754127d822ffb38349ce0fbf561f1b2f diff --git a/tests/codegen/method-declaration.rs b/tests/codegen/method-declaration.rs new file mode 100644 index 00000000000..4ae332b0107 --- /dev/null +++ b/tests/codegen/method-declaration.rs @@ -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() {} diff --git a/tests/ui/asm/issue-113788.rs b/tests/ui/asm/issue-113788.rs new file mode 100644 index 00000000000..903b444767f --- /dev/null +++ b/tests/ui/asm/issue-113788.rs @@ -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); } +} diff --git a/tests/ui/asm/issue-113788.stderr b/tests/ui/asm/issue-113788.stderr new file mode 100644 index 00000000000..f8e65b6f538 --- /dev/null +++ b/tests/ui/asm/issue-113788.stderr @@ -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`. |
