Skip to content

Commit f960bdf

Browse files
committed
Auto merge of rust-lang#114821 - matthiaskrgr:rollup-bahtz9m, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#114745 (Make Const more useful in smir) - rust-lang#114752 (fixed *const [type error] does not implement the Copy trait) - rust-lang#114760 (DebugInfo: Updates test cases that add method declarations.) - rust-lang#114815 (Update books) - rust-lang#114817 (Remove unnecessary FIXME) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4cea2bc + 5f0c17f commit f960bdf

File tree

12 files changed

+71
-13
lines changed

12 files changed

+71
-13
lines changed

compiler/rustc_hir_analysis/src/check/intrinsicck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
6868
let asm_ty = match *ty.kind() {
6969
// `!` is allowed for input but not for output (issue #87802)
7070
ty::Never if is_input => return None,
71-
ty::Error(_) => return None,
71+
_ if ty.references_error() => return None,
7272
ty::Int(IntTy::I8) | ty::Uint(UintTy::U8) => Some(InlineAsmType::I8),
7373
ty::Int(IntTy::I16) | ty::Uint(UintTy::U16) => Some(InlineAsmType::I16),
7474
ty::Int(IntTy::I32) | ty::Uint(UintTy::U32) => Some(InlineAsmType::I32),

compiler/rustc_mir_build/src/thir/cx/expr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,6 @@ impl<'tcx> Cx<'tcx> {
445445
let rhs = self.mirror_expr(rhs);
446446
self.overloaded_operator(expr, Box::new([lhs, rhs]))
447447
} else {
448-
// FIXME overflow
449448
match op.node {
450449
hir::BinOpKind::And => ExprKind::LogicalOp {
451450
op: LogicalOp::And,

compiler/rustc_smir/src/rustc_smir/mod.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use crate::rustc_internal::{self, opaque};
1111
use crate::stable_mir::mir::{CopyNonOverlapping, UserTypeProjection, VariantIdx};
1212
use crate::stable_mir::ty::{
13-
allocation_filter, new_allocation, FloatTy, IntTy, Movability, RigidTy, TyKind, UintTy,
13+
allocation_filter, new_allocation, Const, FloatTy, IntTy, Movability, RigidTy, TyKind, UintTy,
1414
};
1515
use crate::stable_mir::{self, Context};
1616
use rustc_hir as hir;
@@ -187,7 +187,11 @@ impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> {
187187
use mir::Rvalue::*;
188188
match self {
189189
Use(op) => stable_mir::mir::Rvalue::Use(op.stable(tables)),
190-
Repeat(op, len) => stable_mir::mir::Rvalue::Repeat(op.stable(tables), opaque(len)),
190+
Repeat(op, len) => {
191+
let cnst = ConstantKind::from_const(*len, tables.tcx);
192+
let len = Const { literal: cnst.stable(tables) };
193+
stable_mir::mir::Rvalue::Repeat(op.stable(tables), len)
194+
}
191195
Ref(region, kind, place) => stable_mir::mir::Rvalue::Ref(
192196
opaque(region),
193197
kind.stable(tables),
@@ -372,7 +376,11 @@ impl<'tcx> Stable<'tcx> for ty::TermKind<'tcx> {
372376
use stable_mir::ty::TermKind;
373377
match self {
374378
ty::TermKind::Ty(ty) => TermKind::Type(tables.intern_ty(*ty)),
375-
ty::TermKind::Const(const_) => TermKind::Const(opaque(const_)),
379+
ty::TermKind::Const(cnst) => {
380+
let cnst = ConstantKind::from_const(*cnst, tables.tcx);
381+
let cnst = Const { literal: cnst.stable(tables) };
382+
TermKind::Const(cnst)
383+
}
376384
}
377385
}
378386
}
@@ -829,7 +837,10 @@ impl<'tcx> Stable<'tcx> for ty::GenericArgKind<'tcx> {
829837
match self {
830838
ty::GenericArgKind::Lifetime(region) => GenericArgKind::Lifetime(opaque(region)),
831839
ty::GenericArgKind::Type(ty) => GenericArgKind::Type(tables.intern_ty(*ty)),
832-
ty::GenericArgKind::Const(const_) => GenericArgKind::Const(opaque(&const_)),
840+
ty::GenericArgKind::Const(cnst) => {
841+
let cnst = ConstantKind::from_const(*cnst, tables.tcx);
842+
GenericArgKind::Const(stable_mir::ty::Const { literal: cnst.stable(tables) })
843+
}
833844
}
834845
}
835846
}
@@ -1035,7 +1046,9 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
10351046
}
10361047
ty::Str => TyKind::RigidTy(RigidTy::Str),
10371048
ty::Array(ty, constant) => {
1038-
TyKind::RigidTy(RigidTy::Array(tables.intern_ty(*ty), opaque(constant)))
1049+
let cnst = ConstantKind::from_const(*constant, tables.tcx);
1050+
let cnst = stable_mir::ty::Const { literal: cnst.stable(tables) };
1051+
TyKind::RigidTy(RigidTy::Array(tables.intern_ty(*ty), cnst))
10391052
}
10401053
ty::Slice(ty) => TyKind::RigidTy(RigidTy::Slice(tables.intern_ty(*ty))),
10411054
ty::RawPtr(ty::TypeAndMut { ty, mutbl }) => {

compiler/rustc_smir/src/stable_mir/ty.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ impl Ty {
1515
}
1616
}
1717

18-
pub(crate) type Const = Opaque;
18+
#[derive(Debug, Clone)]
19+
pub struct Const {
20+
pub literal: ConstantKind,
21+
}
22+
1923
type Ident = Opaque;
2024
pub(crate) type Region = Opaque;
2125
type Span = Opaque;

src/doc/embedded-book

src/doc/nomicon

Submodule nomicon updated 1 file

tests/codegen/method-declaration.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// compile-flags: -g -Cno-prepopulate-passes
2+
3+
// Verify that we added a declaration for a method.
4+
5+
// CHECK: define{{.*}}@method{{.*}} !dbg ![[METHOD_DEF_DBG:[0-9]+]]
6+
// CHECK: define{{.*}}@function{{.*}} !dbg ![[FUNC_DEF_DBG:[0-9]+]]
7+
8+
#![crate_type = "lib"]
9+
10+
// CHECK-DAG: ![[FOO_DBG:[0-9]+]] = !DICompositeType(tag: {{.*}} name: "Foo", {{.*}} identifier:
11+
pub struct Foo;
12+
13+
impl Foo {
14+
// CHECK-DAG: ![[METHOD_DEF_DBG]] = distinct !DISubprogram(name: "method"{{.*}}, scope: ![[FOO_DBG]]{{.*}}DISPFlagDefinition{{.*}}, declaration: ![[METHOD_DECL_DBG:[0-9]+]]
15+
// CHECK-DAG: ![[METHOD_DECL_DBG]] = !DISubprogram(name: "method"{{.*}}, scope: ![[FOO_DBG]]
16+
#[no_mangle]
17+
pub fn method() {}
18+
}
19+
20+
// CHECK: ![[FUNC_DEF_DBG]] = distinct !DISubprogram(name: "function"
21+
// CHECK-NOT: declaration
22+
// CHECK-SAME: DISPFlagDefinition
23+
// CHECK-NOT: declaration
24+
// CHECK-SAME: )
25+
#[no_mangle]
26+
pub fn function() {}

tests/ui/asm/issue-113788.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// test that "error: arguments for inline assembly must be copyable" doesn't show up in this code
2+
// needs-asm-support
3+
// only-x86_64
4+
fn main() {
5+
let peb: *const PEB; //~ ERROR cannot find type `PEB` in this scope [E0412]
6+
unsafe { std::arch::asm!("mov {0}, fs:[0x30]", out(reg) peb); }
7+
}

tests/ui/asm/issue-113788.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0412]: cannot find type `PEB` in this scope
2+
--> $DIR/issue-113788.rs:5:21
3+
|
4+
LL | let peb: *const PEB;
5+
| ^^^ not found in this scope
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)