-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3206960
commit a642563
Showing
10 changed files
with
349 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#![crate_type = "lib"] | ||
#![feature(staged_api)] | ||
#![stable(feature = "stable_test_feature", since = "1.0")] | ||
|
||
#[unstable(feature = "unstable_test_feature", issue = "none")] | ||
pub struct Unstable { | ||
#[unstable(feature = "unstable_test_feature", issue = "none")] | ||
pub unstable: u8, | ||
} | ||
|
||
#[stable(feature = "stable_test_feature", since = "1.0")] | ||
pub struct Stable { | ||
#[stable(feature = "stable_test_feature", since = "1.0")] | ||
pub stable: u8, | ||
} | ||
|
||
#[stable(feature = "stable_test_feature", since = "1.0")] | ||
pub struct StableWithUnstableField { | ||
#[unstable(feature = "unstable_test_feature", issue = "none")] | ||
pub unstable: u8, | ||
} | ||
|
||
#[stable(feature = "stable_test_feature", since = "1.0")] | ||
pub struct StableWithUnstableFieldType { | ||
#[stable(feature = "stable_test_feature", since = "1.0")] | ||
pub stable: Unstable, | ||
} | ||
|
||
#[unstable(feature = "unstable_test_feature", issue = "none")] | ||
pub struct UnstableWithStableFieldType { | ||
#[unstable(feature = "unstable_test_feature", issue = "none")] | ||
pub unstable: Stable, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,33 @@ | ||
#![feature(offset_of)] | ||
#![feature(offset_of, extern_types)] | ||
|
||
use std::mem::offset_of; | ||
|
||
#[repr(C)] | ||
struct Foo { | ||
struct Alpha { | ||
x: u8, | ||
y: u16, | ||
slice: [u8], | ||
z: [u8], | ||
} | ||
|
||
trait Trait {} | ||
|
||
struct Beta { | ||
x: u8, | ||
y: u16, | ||
z: dyn Trait, | ||
} | ||
|
||
extern { | ||
type Extern; | ||
} | ||
|
||
struct Gamma { | ||
x: u8, | ||
y: u16, | ||
z: Extern, | ||
} | ||
|
||
fn main() { | ||
offset_of!(Foo, slice); //~ ERROR the size for values of type | ||
offset_of!(Alpha, z); //~ ERROR the size for values of type | ||
offset_of!(Beta, z); //~ ERROR the size for values of type | ||
offset_of!(Gamma, z); //~ ERROR the size for values of type | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time | ||
--> $DIR/offset-of-dst-field.rs:13:5 | ||
--> $DIR/offset-of-dst-field.rs:30:5 | ||
| | ||
LL | offset_of!(Foo, slice); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ||
LL | offset_of!(Alpha, z); | ||
| ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `[u8]` | ||
|
||
error: aborting due to previous error | ||
error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time | ||
--> $DIR/offset-of-dst-field.rs:31:5 | ||
| | ||
LL | offset_of!(Beta, z); | ||
| ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `(dyn Trait + 'static)` | ||
|
||
error[E0277]: the size for values of type `Extern` cannot be known at compilation time | ||
--> $DIR/offset-of-dst-field.rs:32:5 | ||
| | ||
LL | offset_of!(Gamma, z); | ||
| ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `Extern` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![feature(offset_of)] | ||
|
||
use std::mem::offset_of; | ||
|
||
enum Alpha { | ||
One(u8), | ||
Two(u8), | ||
} | ||
|
||
fn main() { | ||
offset_of!(Alpha::One, 0); //~ ERROR expected type, found variant `Alpha::One` | ||
offset_of!(Alpha, Two.0); //~ ERROR no field `Two` on type `Alpha` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0573]: expected type, found variant `Alpha::One` | ||
--> $DIR/offset-of-enum.rs:11:16 | ||
| | ||
LL | offset_of!(Alpha::One, 0); | ||
| ^^^^^^^^^^ | ||
| | | ||
| not a type | ||
| help: try using the variant's enum: `Alpha` | ||
|
||
error[E0609]: no field `Two` on type `Alpha` | ||
--> $DIR/offset-of-enum.rs:12:23 | ||
| | ||
LL | offset_of!(Alpha, Two.0); | ||
| ^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0573, E0609. | ||
For more information about an error, try `rustc --explain E0573`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// check-pass | ||
// aux-build:offset-of-staged-api.rs | ||
|
||
#![feature(offset_of, unstable_test_feature)] | ||
|
||
use std::mem::offset_of; | ||
|
||
extern crate offset_of_staged_api; | ||
|
||
use offset_of_staged_api::*; | ||
|
||
fn main() { | ||
offset_of!(Unstable, unstable); | ||
offset_of!(Stable, stable); | ||
offset_of!(StableWithUnstableField, unstable); | ||
offset_of!(StableWithUnstableFieldType, stable); | ||
offset_of!(StableWithUnstableFieldType, stable.unstable); | ||
offset_of!(UnstableWithStableFieldType, unstable); | ||
offset_of!(UnstableWithStableFieldType, unstable.stable); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// aux-build:offset-of-staged-api.rs | ||
|
||
#![feature(offset_of)] | ||
|
||
use std::mem::offset_of; | ||
|
||
extern crate offset_of_staged_api; | ||
|
||
use offset_of_staged_api::*; | ||
|
||
fn main() { | ||
offset_of!( | ||
//~^ ERROR use of unstable library feature | ||
Unstable, //~ ERROR use of unstable library feature | ||
unstable | ||
); | ||
offset_of!(Stable, stable); | ||
offset_of!(StableWithUnstableField, unstable); //~ ERROR use of unstable library feature | ||
offset_of!(StableWithUnstableFieldType, stable); | ||
offset_of!(StableWithUnstableFieldType, stable.unstable); //~ ERROR use of unstable library feature | ||
offset_of!( | ||
//~^ ERROR use of unstable library feature | ||
UnstableWithStableFieldType, //~ ERROR use of unstable library feature | ||
unstable | ||
); | ||
offset_of!( | ||
//~^ ERROR use of unstable library feature | ||
UnstableWithStableFieldType, //~ ERROR use of unstable library feature | ||
unstable.stable | ||
); | ||
} |
Oops, something went wrong.