summary refs log tree commit diff
path: root/tests/ui/contracts
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-02-11 01:02:43 -0500
committerGitHub <noreply@github.com>2025-02-11 01:02:43 -0500
commit4ae214b846655d5132b352b294a806a5aba796e5 (patch)
treefd7d8845c307ec1660bdf66585d1bfa64ef6c2d1 /tests/ui/contracts
parent94bf32e71977a08b113166fbc98f16dd095ef382 (diff)
parent4f18560d0600ae235289a6c4c745c9c4c300a602 (diff)
downloadrust-4ae214b846655d5132b352b294a806a5aba796e5.tar.gz
rust-4ae214b846655d5132b352b294a806a5aba796e5.zip
Rollup merge of #136837 - compiler-errors:contracts-body-lowering, r=celinval
Overhaul how contracts are lowered on fn-like bodies

Consolidates all of the contracts lowering logic into `lower_fn_body`, rather than having it be split between `lower_item_kind` and `lower_fn_body`. This should fix #136683.

r? celinval
Diffstat (limited to 'tests/ui/contracts')
-rw-r--r--tests/ui/contracts/associated-item.rs18
-rw-r--r--tests/ui/contracts/associated-item.stderr11
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/contracts/associated-item.rs b/tests/ui/contracts/associated-item.rs
new file mode 100644
index 00000000000..4a2d05abbc5
--- /dev/null
+++ b/tests/ui/contracts/associated-item.rs
@@ -0,0 +1,18 @@
+// Ensure we don't ICE when lowering contracts on an associated item.
+
+//@ compile-flags: --crate-type=lib
+//@ check-pass
+
+#![feature(contracts)]
+//~^ WARN the feature `contracts` is incomplete and may not be safe to use
+
+extern crate core;
+
+use core::contracts::requires;
+
+struct Foo;
+
+impl Foo {
+    #[requires(align > 0 && (align & (align - 1)) == 0)]
+    pub fn foo(align: i32) {}
+}
diff --git a/tests/ui/contracts/associated-item.stderr b/tests/ui/contracts/associated-item.stderr
new file mode 100644
index 00000000000..20651026b87
--- /dev/null
+++ b/tests/ui/contracts/associated-item.stderr
@@ -0,0 +1,11 @@
+warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/associated-item.rs:6:12
+   |
+LL | #![feature(contracts)]
+   |            ^^^^^^^^^
+   |
+   = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information
+   = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+