summaryrefslogtreecommitdiffstats
path: root/src/test/ui/lifetimes/auxiliary
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/lifetimes/auxiliary
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/lifetimes/auxiliary')
-rw-r--r--src/test/ui/lifetimes/auxiliary/issue-91763-aux.rs47
-rw-r--r--src/test/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs11
2 files changed, 58 insertions, 0 deletions
diff --git a/src/test/ui/lifetimes/auxiliary/issue-91763-aux.rs b/src/test/ui/lifetimes/auxiliary/issue-91763-aux.rs
new file mode 100644
index 000000000..0335f72b7
--- /dev/null
+++ b/src/test/ui/lifetimes/auxiliary/issue-91763-aux.rs
@@ -0,0 +1,47 @@
+// force-host
+// no-prefer-dynamic
+
+#![crate_type = "proc-macro"]
+
+//#![feature(proc_macro_diagnostic, proc_macro_span, proc_macro_def_site)]
+
+extern crate proc_macro;
+
+use proc_macro::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree};
+use std::iter::FromIterator;
+
+#[proc_macro_attribute]
+pub fn repro(_args: TokenStream, input: TokenStream) -> TokenStream {
+ let call_site = Span::call_site();
+ let span = input.into_iter().nth(8).unwrap().span();
+
+ //fn f(_: &::std::fmt::Formatter) {}
+ TokenStream::from_iter([
+ TokenTree::Ident(Ident::new("fn", call_site)),
+ TokenTree::Ident(Ident::new("f", call_site)),
+ TokenTree::Group(Group::new(
+ Delimiter::Parenthesis,
+ TokenStream::from_iter([
+ TokenTree::Ident(Ident::new("_", call_site)),
+ TokenTree::Punct(punct(':', Spacing::Alone, call_site)),
+ TokenTree::Punct(punct('&', Spacing::Alone, call_site)),
+ TokenTree::Punct(punct(':', Spacing::Joint, span)),
+ TokenTree::Punct(punct(':', Spacing::Alone, span)),
+ TokenTree::Ident(Ident::new("std", span)),
+ TokenTree::Punct(punct(':', Spacing::Joint, span)),
+ TokenTree::Punct(punct(':', Spacing::Alone, span)),
+ TokenTree::Ident(Ident::new("fmt", span)),
+ TokenTree::Punct(punct(':', Spacing::Joint, span)),
+ TokenTree::Punct(punct(':', Spacing::Alone, span)),
+ TokenTree::Ident(Ident::new("Formatter", span)),
+ ]),
+ )),
+ TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())),
+ ])
+}
+
+fn punct(ch: char, spacing: Spacing, span: Span) -> Punct {
+ let mut punct = Punct::new(ch, spacing);
+ punct.set_span(span);
+ punct
+}
diff --git a/src/test/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs b/src/test/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs
new file mode 100644
index 000000000..58f1b81cf
--- /dev/null
+++ b/src/test/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs
@@ -0,0 +1,11 @@
+#![crate_type = "rlib"]
+
+// Helper for testing that we get suitable warnings when lifetime
+// bound change will cause breakage.
+
+pub fn just_ref(x: &Fn()) {
+}
+
+pub fn ref_obj(x: &Box<Fn()>) {
+ // this will change to &Box<Fn()+'static>...
+}