summaryrefslogtreecommitdiffstats
path: root/tests/ui/proc-macro
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/proc-macro')
-rw-r--r--tests/ui/proc-macro/auxiliary/api/cmp.rs11
-rw-r--r--tests/ui/proc-macro/auxiliary/assert-span-pos.rs5
-rw-r--r--tests/ui/proc-macro/auxiliary/exports_no_mangle.rs11
-rw-r--r--tests/ui/proc-macro/auxiliary/macro-only-syntax.rs2
-rw-r--r--tests/ui/proc-macro/crt-static.rs1
-rw-r--r--tests/ui/proc-macro/derive-helper-shadowing.rs2
-rw-r--r--tests/ui/proc-macro/derive-helper-shadowing.stderr29
-rw-r--r--tests/ui/proc-macro/no-mangle-in-proc-macro-issue-111888.rs22
-rw-r--r--tests/ui/proc-macro/span-preservation.stderr2
9 files changed, 47 insertions, 38 deletions
diff --git a/tests/ui/proc-macro/auxiliary/api/cmp.rs b/tests/ui/proc-macro/auxiliary/api/cmp.rs
index 5784a6e5d..ec3e637ac 100644
--- a/tests/ui/proc-macro/auxiliary/api/cmp.rs
+++ b/tests/ui/proc-macro/auxiliary/api/cmp.rs
@@ -1,18 +1,9 @@
-use proc_macro::{LineColumn, Punct, Spacing};
+use proc_macro::{Punct, Spacing};
pub fn test() {
- test_line_column_ord();
test_punct_eq();
}
-fn test_line_column_ord() {
- let line0_column0 = LineColumn { line: 0, column: 0 };
- let line0_column1 = LineColumn { line: 0, column: 1 };
- let line1_column0 = LineColumn { line: 1, column: 0 };
- assert!(line0_column0 < line0_column1);
- assert!(line0_column1 < line1_column0);
-}
-
fn test_punct_eq() {
let colon_alone = Punct::new(':', Spacing::Alone);
assert_eq!(colon_alone, ':');
diff --git a/tests/ui/proc-macro/auxiliary/assert-span-pos.rs b/tests/ui/proc-macro/auxiliary/assert-span-pos.rs
index 455c5c7c3..8126470ec 100644
--- a/tests/ui/proc-macro/auxiliary/assert-span-pos.rs
+++ b/tests/ui/proc-macro/auxiliary/assert-span-pos.rs
@@ -26,10 +26,9 @@ pub fn assert_span_pos(input: TokenStream) -> TokenStream {
let line: usize = str1.parse().unwrap();
let col: usize = str2.parse().unwrap();
- let sp1s = sp1.start();
- if (line, col) != (sp1s.line, sp1s.column) {
+ if (line, col) != (sp1.line(), sp1.column()) {
let msg = format!("line/column mismatch: ({}, {}) != ({}, {})", line, col,
- sp1s.line, sp1s.column);
+ sp1.line(), sp1.column());
sp1.error(msg).emit();
}
diff --git a/tests/ui/proc-macro/auxiliary/exports_no_mangle.rs b/tests/ui/proc-macro/auxiliary/exports_no_mangle.rs
new file mode 100644
index 000000000..a8a478ffc
--- /dev/null
+++ b/tests/ui/proc-macro/auxiliary/exports_no_mangle.rs
@@ -0,0 +1,11 @@
+// force-host
+// no-prefer-dynamic
+#![crate_type="lib"]
+
+// Issue 111888: this crate (1.) is imported by a proc-macro crate and (2.)
+// exports a no_mangle function; that combination of acts was broken for some
+// period of time. See further discussion in the test file that imports this
+// crate.
+
+#[no_mangle]
+pub fn some_no_mangle_function() { }
diff --git a/tests/ui/proc-macro/auxiliary/macro-only-syntax.rs b/tests/ui/proc-macro/auxiliary/macro-only-syntax.rs
index c72306c3d..4ca3a0faa 100644
--- a/tests/ui/proc-macro/auxiliary/macro-only-syntax.rs
+++ b/tests/ui/proc-macro/auxiliary/macro-only-syntax.rs
@@ -81,7 +81,7 @@ fn expect_brace(tokens: &mut token_stream::IntoIter) -> token_stream::IntoIter {
fn check_useful_span(token: TokenTree, expected_filename: &str) {
let span = token.span();
- assert!(span.start().column < span.end().column);
+ assert!(span.column() < span.end().column());
let source_path = span.source_file().path();
let filename = source_path.components().last().unwrap();
diff --git a/tests/ui/proc-macro/crt-static.rs b/tests/ui/proc-macro/crt-static.rs
index 020128fa2..78592f827 100644
--- a/tests/ui/proc-macro/crt-static.rs
+++ b/tests/ui/proc-macro/crt-static.rs
@@ -7,6 +7,7 @@
// build-pass
// force-host
// no-prefer-dynamic
+// needs-dynamic-linking
#![crate_type = "proc-macro"]
diff --git a/tests/ui/proc-macro/derive-helper-shadowing.rs b/tests/ui/proc-macro/derive-helper-shadowing.rs
index 80d982d25..4f25b4b0d 100644
--- a/tests/ui/proc-macro/derive-helper-shadowing.rs
+++ b/tests/ui/proc-macro/derive-helper-shadowing.rs
@@ -23,7 +23,7 @@ macro_rules! gen_helper_use {
struct S {
#[empty_helper] // OK, no ambiguity, derive helpers have highest priority
field: [u8; {
- use empty_helper; //~ ERROR `empty_helper` is ambiguous
+ use empty_helper; // OK, no ambiguity, derive helpers have highest priority
#[empty_helper] // OK, no ambiguity, derive helpers have highest priority
struct U;
diff --git a/tests/ui/proc-macro/derive-helper-shadowing.stderr b/tests/ui/proc-macro/derive-helper-shadowing.stderr
index de2c27a87..f284b1c54 100644
--- a/tests/ui/proc-macro/derive-helper-shadowing.stderr
+++ b/tests/ui/proc-macro/derive-helper-shadowing.stderr
@@ -16,9 +16,11 @@ error: cannot find attribute `empty_helper` in this scope
LL | #[derive(GenHelperUse)]
| ^^^^^^^^^^^^
|
- = help: consider importing this attribute macro:
- empty_helper
= note: this error originates in the derive macro `GenHelperUse` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: consider importing this attribute macro through its public re-export
+ |
+LL + use empty_helper;
+ |
error: cannot find attribute `empty_helper` in this scope
--> $DIR/derive-helper-shadowing.rs:14:11
@@ -29,28 +31,11 @@ LL | #[empty_helper]
LL | gen_helper_use!();
| ----------------- in this macro invocation
|
- = help: consider importing this attribute macro:
- crate::empty_helper
= note: this error originates in the macro `gen_helper_use` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error[E0659]: `empty_helper` is ambiguous
- --> $DIR/derive-helper-shadowing.rs:26:13
+help: consider importing this attribute macro through its public re-export
|
-LL | use empty_helper;
- | ^^^^^^^^^^^^ ambiguous name
+LL + use crate::empty_helper;
|
- = note: ambiguous because of multiple potential import sources
-note: `empty_helper` could refer to the derive helper attribute defined here
- --> $DIR/derive-helper-shadowing.rs:22:10
- |
-LL | #[derive(Empty)]
- | ^^^^^
-note: `empty_helper` could also refer to the attribute macro imported here
- --> $DIR/derive-helper-shadowing.rs:10:5
- |
-LL | use test_macros::empty_attr as empty_helper;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- = help: use `crate::empty_helper` to refer to this attribute macro unambiguously
error[E0659]: `empty_helper` is ambiguous
--> $DIR/derive-helper-shadowing.rs:19:3
@@ -84,6 +69,6 @@ LL | #[derive(Empty)]
= note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
= note: `#[warn(legacy_derive_helpers)]` on by default
-error: aborting due to 5 previous errors; 1 warning emitted
+error: aborting due to 4 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0659`.
diff --git a/tests/ui/proc-macro/no-mangle-in-proc-macro-issue-111888.rs b/tests/ui/proc-macro/no-mangle-in-proc-macro-issue-111888.rs
new file mode 100644
index 000000000..4e5208e50
--- /dev/null
+++ b/tests/ui/proc-macro/no-mangle-in-proc-macro-issue-111888.rs
@@ -0,0 +1,22 @@
+// build-pass
+// force-host
+// no-prefer-dynamic
+// aux-build:exports_no_mangle.rs
+#![crate_type = "proc-macro"]
+
+// Issue #111888: this proc-macro crate imports another crate that itself
+// exports a no_mangle function.
+//
+// That combination was broken for a period of time, because:
+//
+// In PR #99944 we *stopped* exporting no_mangle symbols from
+// proc-macro crates. The constructed linker version script still referred
+// to them, but resolving that discrepancy was left as a FIXME in the code.
+//
+// In PR #108017 we started telling the linker to check (via the
+// `--no-undefined-version` linker invocation flag) that every symbol referenced
+// in the "linker version script" is actually present in the linker input. So
+// the unresolved discrepancy from #99944 started surfacing as a compile-time
+// error.
+
+extern crate exports_no_mangle;
diff --git a/tests/ui/proc-macro/span-preservation.stderr b/tests/ui/proc-macro/span-preservation.stderr
index 66c68be2f..8c15cb9de 100644
--- a/tests/ui/proc-macro/span-preservation.stderr
+++ b/tests/ui/proc-macro/span-preservation.stderr
@@ -32,7 +32,7 @@ error[E0560]: struct `Foo` has no field named `b`
LL | let y = Foo { a: 10, b: 10isize };
| ^ `Foo` does not have this field
|
- = note: available fields are: `a`
+ = note: all struct fields are already assigned
error[E0308]: mismatched types
--> $DIR/span-preservation.rs:39:5