diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-06-17 22:18:56 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-06-18 10:48:56 +0300 |
| commit | 8ec502eecdccec643ae6631a323dc6f38b490269 (patch) | |
| tree | efc3e263154b0a4f74a9abd57df443cdd8d4ed37 /src/libsyntax_pos | |
| parent | 68e1141c45c71c56cc4904b72f2212701b5912d4 (diff) | |
| download | rust-8ec502eecdccec643ae6631a323dc6f38b490269.tar.gz rust-8ec502eecdccec643ae6631a323dc6f38b490269.zip | |
syntax: Introduce `default`/`with_unstable` constructors for `ExpnInfo`
Diffstat (limited to 'src/libsyntax_pos')
| -rw-r--r-- | src/libsyntax_pos/hygiene.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index b827416ab53..e9a912ddbc2 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -682,6 +682,29 @@ pub struct ExpnInfo { pub edition: Edition, } +impl ExpnInfo { + /// Constructs an expansion info with default properties. + pub fn default(format: ExpnFormat, call_site: Span, edition: Edition) -> ExpnInfo { + ExpnInfo { + call_site, + def_site: None, + format, + allow_internal_unstable: None, + allow_internal_unsafe: false, + local_inner_macros: false, + edition, + } + } + + pub fn with_unstable(format: ExpnFormat, call_site: Span, edition: Edition, + allow_internal_unstable: &[Symbol]) -> ExpnInfo { + ExpnInfo { + allow_internal_unstable: Some(allow_internal_unstable.into()), + ..ExpnInfo::default(format, call_site, edition) + } + } +} + /// The source of expansion. #[derive(Clone, Hash, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] pub enum ExpnFormat { |
