about summary refs log tree commit diff
path: root/tests/ui/structs/nonexistent-struct-field-error-5439.rs
diff options
context:
space:
mode:
authorOneirical <manchot@videotron.ca>2025-08-20 14:02:39 -0400
committerOneirical <manchot@videotron.ca>2025-08-27 00:23:26 -0400
commit2e659f58940a31fa625e88f75f78111ed773f32d (patch)
tree7b7574337cfe2a195a94a3c2dd12035e6eb7c136 /tests/ui/structs/nonexistent-struct-field-error-5439.rs
parente8a792daf500b5ff8097896ddb6cc037abe92487 (diff)
downloadrust-2e659f58940a31fa625e88f75f78111ed773f32d.tar.gz
rust-2e659f58940a31fa625e88f75f78111ed773f32d.zip
Add test batch 1
Diffstat (limited to 'tests/ui/structs/nonexistent-struct-field-error-5439.rs')
-rw-r--r--tests/ui/structs/nonexistent-struct-field-error-5439.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/structs/nonexistent-struct-field-error-5439.rs b/tests/ui/structs/nonexistent-struct-field-error-5439.rs
new file mode 100644
index 00000000000..b2b3293ac91
--- /dev/null
+++ b/tests/ui/structs/nonexistent-struct-field-error-5439.rs
@@ -0,0 +1,20 @@
+// https://github.com/rust-lang/rust/issues/5439
+struct Foo {
+    foo: isize,
+}
+
+struct Bar {
+    bar: isize,
+}
+
+impl Bar {
+    fn make_foo (&self, i: isize) -> Box<Foo> {
+        return Box::new(Foo { nonexistent: self, foo: i }); //~ ERROR: no field named
+    }
+}
+
+fn main () {
+    let bar = Bar { bar: 1 };
+    let foo = bar.make_foo(2);
+    println!("{}", foo.foo);
+}