diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-09 14:07:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-09 14:07:29 +0200 |
| commit | 714c8ea9b5f1c15fec4211eef2ea04385fe4d386 (patch) | |
| tree | 2a6ba0b6e5280ac86fa97e80c5e4eab237a99d71 /src/test | |
| parent | a03872645fc655125e43e56bd12c335b2fb19c2e (diff) | |
| parent | d9d9246418ae884cb67feb3574832696660b8e2e (diff) | |
| download | rust-714c8ea9b5f1c15fec4211eef2ea04385fe4d386.tar.gz rust-714c8ea9b5f1c15fec4211eef2ea04385fe4d386.zip | |
Rollup merge of #63114 - matthewjasper:hygienic-format-args, r=petrochenkov
Remove gensym in format_args This also fixes some things to allow us to export opaque macros from libcore: * Don't consider items that are only reachable through opaque macros as public/exported (so they aren't linted as needing docs) * Mark private items reachable from the root of libcore as unstable - they are now reachable (in principle) in other crates via macros in libcore r? @petrochenkov
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/definition-reachable/auxiliary/field-method-macro.rs | 23 | ||||
| -rw-r--r-- | src/test/ui/definition-reachable/auxiliary/nested-fn-macro.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/definition-reachable/auxiliary/private-use-macro.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/definition-reachable/field-method.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/definition-reachable/nested-fn.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/definition-reachable/private-non-types.rs | 21 | ||||
| -rw-r--r-- | src/test/ui/definition-reachable/private-types.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/definition-reachable/private-use.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/format-hygiene.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/hygiene/format-args.rs | 12 |
10 files changed, 129 insertions, 8 deletions
diff --git a/src/test/ui/definition-reachable/auxiliary/field-method-macro.rs b/src/test/ui/definition-reachable/auxiliary/field-method-macro.rs new file mode 100644 index 00000000000..30ba70bdfeb --- /dev/null +++ b/src/test/ui/definition-reachable/auxiliary/field-method-macro.rs @@ -0,0 +1,23 @@ +#![feature(decl_macro)] + +mod n { + pub struct B(pub(crate) p::C); + impl B { + pub fn new() -> Self { + B(p::C) + } + } + mod p { + pub struct C; + + impl C { + pub fn foo(&self) -> i32 { + 33 + } + } + } +} + +pub macro m() { + n::B::new().0.foo() +} diff --git a/src/test/ui/definition-reachable/auxiliary/nested-fn-macro.rs b/src/test/ui/definition-reachable/auxiliary/nested-fn-macro.rs new file mode 100644 index 00000000000..a39e8c986c3 --- /dev/null +++ b/src/test/ui/definition-reachable/auxiliary/nested-fn-macro.rs @@ -0,0 +1,11 @@ +#![feature(decl_macro)] + +mod n { + pub(crate) mod p { + pub fn f() -> i32 { 12 } + } +} + +pub macro m() { + n::p::f() +} diff --git a/src/test/ui/definition-reachable/auxiliary/private-use-macro.rs b/src/test/ui/definition-reachable/auxiliary/private-use-macro.rs new file mode 100644 index 00000000000..4f283d9c19c --- /dev/null +++ b/src/test/ui/definition-reachable/auxiliary/private-use-macro.rs @@ -0,0 +1,11 @@ +#![feature(decl_macro)] + +mod n { + pub static S: i32 = 57; +} + +use n::S; + +pub macro m() { + S +} diff --git a/src/test/ui/definition-reachable/field-method.rs b/src/test/ui/definition-reachable/field-method.rs new file mode 100644 index 00000000000..60e895a2f9a --- /dev/null +++ b/src/test/ui/definition-reachable/field-method.rs @@ -0,0 +1,11 @@ +// Check that functions accessible through a field visible to a macro are +// considered reachable + +// aux-build:nested-fn-macro.rs +// run-pass + +extern crate nested_fn_macro; + +fn main() { + assert_eq!(nested_fn_macro::m!(), 12); +} diff --git a/src/test/ui/definition-reachable/nested-fn.rs b/src/test/ui/definition-reachable/nested-fn.rs new file mode 100644 index 00000000000..b596ba8936a --- /dev/null +++ b/src/test/ui/definition-reachable/nested-fn.rs @@ -0,0 +1,11 @@ +// Check that functions visible to macros through paths with >2 segements are +// considered reachable + +// aux-build:field-method-macro.rs +// run-pass + +extern crate field_method_macro; + +fn main() { + assert_eq!(field_method_macro::m!(), 33); +} diff --git a/src/test/ui/definition-reachable/private-non-types.rs b/src/test/ui/definition-reachable/private-non-types.rs new file mode 100644 index 00000000000..a601dabcb0b --- /dev/null +++ b/src/test/ui/definition-reachable/private-non-types.rs @@ -0,0 +1,21 @@ +// Check that we don't require stability annotations for private modules, +// imports and fields that are accessible to opaque macros. + +// check-pass + +#![feature(decl_macro, staged_api)] +#![stable(feature = "test", since = "1.0.0")] + +extern crate std as local_std; +use local_std::marker::Copy as LocalCopy; +mod private_mod { + #[stable(feature = "test", since = "1.0.0")] + pub struct A { + pub(crate) f: i32, + } +} + +#[stable(feature = "test", since = "1.0.0")] +pub macro m() {} + +fn main() {} diff --git a/src/test/ui/definition-reachable/private-types.rs b/src/test/ui/definition-reachable/private-types.rs new file mode 100644 index 00000000000..02c1224f4e1 --- /dev/null +++ b/src/test/ui/definition-reachable/private-types.rs @@ -0,0 +1,19 @@ +// Check that type privacy is taken into account when considering reachability + +// check-pass + +#![feature(decl_macro, staged_api)] +#![stable(feature = "test", since = "1.0.0")] + +// Type privacy should prevent use of these in other crates, so we shouldn't +// need a stability annotation. +fn private_function() {} +struct PrivateStruct { f: () } +enum PrivateEnum { V } +union PrivateUnion { g: () } +trait PrivateTrait {} + +#[stable(feature = "test", since = "1.0.0")] +pub macro m() {} + +fn main() {} diff --git a/src/test/ui/definition-reachable/private-use.rs b/src/test/ui/definition-reachable/private-use.rs new file mode 100644 index 00000000000..02cff0475e5 --- /dev/null +++ b/src/test/ui/definition-reachable/private-use.rs @@ -0,0 +1,10 @@ +// Check that private use statements can be used by + +// run-pass +// aux-build:private-use-macro.rs + +extern crate private_use_macro; + +fn main() { + assert_eq!(private_use_macro::m!(), 57); +} diff --git a/src/test/ui/format-hygiene.rs b/src/test/ui/format-hygiene.rs deleted file mode 100644 index 6bf5ae8bead..00000000000 --- a/src/test/ui/format-hygiene.rs +++ /dev/null @@ -1,8 +0,0 @@ -// run-pass - -#![allow(non_upper_case_globals)] -pub const arg0: u8 = 1; - -pub fn main() { - format!("{}", 1); -} diff --git a/src/test/ui/hygiene/format-args.rs b/src/test/ui/hygiene/format-args.rs new file mode 100644 index 00000000000..d74889b95cc --- /dev/null +++ b/src/test/ui/hygiene/format-args.rs @@ -0,0 +1,12 @@ +// check-pass + +#![allow(non_upper_case_globals)] +#![feature(format_args_nl)] + +static arg0: () = (); + +fn main() { + static arg1: () = (); + format_args!("{} {:?}", 0, 1); + format_args_nl!("{} {:?}", 0, 1); +} |
