From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/span/mut-arg-hint.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/ui/span/mut-arg-hint.rs (limited to 'tests/ui/span/mut-arg-hint.rs') diff --git a/tests/ui/span/mut-arg-hint.rs b/tests/ui/span/mut-arg-hint.rs new file mode 100644 index 000000000..d7ff1f0de --- /dev/null +++ b/tests/ui/span/mut-arg-hint.rs @@ -0,0 +1,22 @@ +trait B { + fn foo(mut a: &String) { + a.push_str("bar"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference + } +} + +pub fn foo<'a>(mut a: &'a String) { + a.push_str("foo"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference +} + +struct A {} + +impl A { + pub fn foo(mut a: &String) { + a.push_str("foo"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference + } +} + +fn main() { + foo(&"a".to_string()); + A::foo(&"a".to_string()); +} -- cgit v1.2.3