diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/static/auxiliary | |
parent | Initial commit. (diff) | |
download | rustc-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 '')
-rw-r--r-- | src/test/ui/static/auxiliary/extern-statics.rs | 4 | ||||
-rw-r--r-- | src/test/ui/static/auxiliary/issue_24843.rs | 1 | ||||
-rw-r--r-- | src/test/ui/static/auxiliary/nested_item.rs | 30 | ||||
-rw-r--r-- | src/test/ui/static/auxiliary/static-priv-by-default.rs | 27 | ||||
-rw-r--r-- | src/test/ui/static/auxiliary/static_priv_by_default.rs | 51 |
5 files changed, 113 insertions, 0 deletions
diff --git a/src/test/ui/static/auxiliary/extern-statics.rs b/src/test/ui/static/auxiliary/extern-statics.rs new file mode 100644 index 000000000..c090bc79f --- /dev/null +++ b/src/test/ui/static/auxiliary/extern-statics.rs @@ -0,0 +1,4 @@ +extern "C" { + pub static XA: u8; + pub static mut XB: u8; +} diff --git a/src/test/ui/static/auxiliary/issue_24843.rs b/src/test/ui/static/auxiliary/issue_24843.rs new file mode 100644 index 000000000..6ca04f860 --- /dev/null +++ b/src/test/ui/static/auxiliary/issue_24843.rs @@ -0,0 +1 @@ +pub static TEST_STR: &'static str = "Hello world"; diff --git a/src/test/ui/static/auxiliary/nested_item.rs b/src/test/ui/static/auxiliary/nested_item.rs new file mode 100644 index 000000000..9db9d19d6 --- /dev/null +++ b/src/test/ui/static/auxiliary/nested_item.rs @@ -0,0 +1,30 @@ +// original problem +pub fn foo<T>() -> isize { + { + static foo: isize = 2; + foo + } +} + +// issue 8134 +struct Foo; +impl Foo { + pub fn foo<T>(&self) { + static X: usize = 1; + } +} + +// issue 8134 +pub struct Parser<T>(T); +impl<T: std::iter::Iterator<Item=char>> Parser<T> { + fn in_doctype(&mut self) { + static DOCTYPEPattern: [char; 6] = ['O', 'C', 'T', 'Y', 'P', 'E']; + } +} + +struct Bar; +impl Foo { + pub fn bar<T>(&self) { + static X: usize = 1; + } +} diff --git a/src/test/ui/static/auxiliary/static-priv-by-default.rs b/src/test/ui/static/auxiliary/static-priv-by-default.rs new file mode 100644 index 000000000..41f368f46 --- /dev/null +++ b/src/test/ui/static/auxiliary/static-priv-by-default.rs @@ -0,0 +1,27 @@ +// aux-build:static_priv_by_default.rs + +extern crate static_priv_by_default; + +mod child { + pub mod childs_child { + static private: isize = 0; + pub static public: isize = 0; + } +} + +fn foo(_: isize) {} + +fn full_ref() { + foo(static_priv_by_default::private); //~ ERROR: static `private` is private + foo(static_priv_by_default::public); + foo(child::childs_child::private); //~ ERROR: static `private` is private + foo(child::childs_child::public); +} + +fn medium_ref() { + use child::childs_child; + foo(childs_child::private); //~ ERROR: static `private` is private + foo(childs_child::public); +} + +fn main() {} diff --git a/src/test/ui/static/auxiliary/static_priv_by_default.rs b/src/test/ui/static/auxiliary/static_priv_by_default.rs new file mode 100644 index 000000000..39f912066 --- /dev/null +++ b/src/test/ui/static/auxiliary/static_priv_by_default.rs @@ -0,0 +1,51 @@ +#![crate_type = "lib"] + +static private: isize = 0; +pub static public: isize = 0; + +pub struct A(()); + +impl A { + fn foo() {} +} + +mod foo { + pub static a: isize = 0; + pub fn b() {} + pub struct c; + pub enum d {} + pub type e = isize; + + pub struct A(()); + + impl A { + fn foo() {} + } + + // these are public so the parent can re-export them. + pub static reexported_a: isize = 0; + pub fn reexported_b() {} + pub struct reexported_c; + pub enum reexported_d {} + pub type reexported_e = isize; +} + +pub mod bar { + pub use foo::reexported_a as e; + pub use foo::reexported_b as f; + pub use foo::reexported_c as g; + pub use foo::reexported_d as h; + pub use foo::reexported_e as i; +} + +pub static a: isize = 0; +pub fn b() {} +pub struct c; +pub enum d {} +pub type e = isize; + +static j: isize = 0; +fn k() {} +struct l; +enum m {} +type n = isize; |