Skip to content

Commit 2cd3630

Browse files
Merge #456
456: Use and generate code for Edition 2018 only r=adamgreig a=therealprof No need to maintain extern crate imports anymore Signed-off-by: Daniel Egger <[email protected]> Co-authored-by: Daniel Egger <[email protected]>
2 parents 8b95499 + 85615cb commit 2cd3630

File tree

8 files changed

+9
-48
lines changed

8 files changed

+9
-48
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2626
use the `msp430_rt::interrupt` attribute macro and `device.x` for interrupt
2727
support. The `INTERRUPT` array has been renamed `__INTERRUPT`.
2828

29+
- Don't generate pre Edition 2018 `extern crate` statements anymore
30+
2931
## [v0.17.0] - 2019-12-31
3032

3133
### Fixed

src/generate/device.rs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::svd::Device;
22
use proc_macro2::{Ident, Span, TokenStream};
3-
use quote::ToTokens;
3+
use quote::{quote, ToTokens};
44
use std::fs::File;
55
use std::io::Write;
66

@@ -75,42 +75,7 @@ pub fn render(
7575
#![no_std]
7676
});
7777

78-
match target {
79-
Target::CortexM => {
80-
out.extend(quote! {
81-
extern crate cortex_m;
82-
#[cfg(feature = "rt")]
83-
extern crate cortex_m_rt;
84-
});
85-
}
86-
Target::Msp430 => {
87-
out.extend(quote! {
88-
extern crate msp430;
89-
#[cfg(feature = "rt")]
90-
extern crate msp430_rt;
91-
});
92-
}
93-
Target::RISCV => {
94-
out.extend(quote! {
95-
extern crate riscv;
96-
#[cfg(feature = "rt")]
97-
extern crate riscv_rt;
98-
});
99-
}
100-
Target::XtensaLX6 => {
101-
out.extend(quote! {
102-
extern crate xtensa_lx6;
103-
#[cfg(feature = "rt")]
104-
extern crate xtensa_lx6_rt;
105-
});
106-
}
107-
Target::None => {}
108-
}
109-
11078
out.extend(quote! {
111-
extern crate bare_metal;
112-
extern crate vcell;
113-
11479
use core::ops::Deref;
11580
use core::marker::PhantomData;
11681
});

src/generate/interrupt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::fmt::Write;
44
use crate::svd::Peripheral;
55
use cast::u64;
66
use proc_macro2::{Ident, Span, TokenStream};
7+
use quote::quote;
78

89
use crate::util::{self, ToSanitizedUpperCase};
910
use crate::Target;

src/generate/peripheral.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::svd::{Cluster, ClusterInfo, Peripheral, Register, RegisterCluster, Re
66
use log::warn;
77
use proc_macro2::TokenStream;
88
use proc_macro2::{Ident, Punct, Spacing, Span};
9-
use quote::ToTokens;
9+
use quote::{quote, ToTokens};
1010
use svd_parser::derive_from::DeriveFrom;
1111
use syn::{parse_str, Token};
1212

src/generate/register.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use crate::quote::ToTokens;
21
use crate::svd::{
32
Access, BitRange, EnumeratedValues, Field, Peripheral, Register, RegisterCluster,
43
RegisterProperties, Usage, WriteConstraint,
54
};
65
use cast::u64;
76
use log::warn;
87
use proc_macro2::{Ident, Punct, Spacing, Span, TokenStream};
8+
use quote::{quote, ToTokens};
99

1010
use crate::util::{self, ToSanitizedSnakeCase, ToSanitizedUpperCase, U32Ext};
1111
use anyhow::{anyhow, Result};

src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,6 @@
451451
//! used with the `cortex-m` crate `NVIC` API.
452452
//!
453453
//! ```ignore
454-
//! extern crate cortex_m;
455-
//! extern crate stm32f30x;
456-
//!
457454
//! use cortex_m::interrupt;
458455
//! use cortex_m::peripheral::Peripherals;
459456
//! use stm32f30x::Interrupt;
@@ -481,8 +478,7 @@
481478
//! compiler. Currently there are no nightly features the flag is only kept for compatibility with prior versions.
482479
#![recursion_limit = "128"]
483480

484-
#[macro_use]
485-
extern crate quote;
481+
use quote::quote;
486482
use svd_parser as svd;
487483

488484
mod generate;

src/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#![recursion_limit = "128"]
22

3-
#[macro_use]
4-
extern crate log;
5-
#[macro_use]
6-
extern crate quote;
3+
use log::error;
74
use svd_parser as svd;
85

96
mod generate;

src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::borrow::Cow;
22

3-
use crate::quote::ToTokens;
43
use crate::svd::{Access, Cluster, Register, RegisterCluster};
54
use inflections::Inflect;
65
use proc_macro2::{Ident, Literal, Span, TokenStream};
6+
use quote::{quote, ToTokens};
77

88
use anyhow::{anyhow, bail, Result};
99

0 commit comments

Comments
 (0)