Skip to content

Use and generate code for Edition 2018 only #456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
use the `msp430_rt::interrupt` attribute macro and `device.x` for interrupt
support. The `INTERRUPT` array has been renamed `__INTERRUPT`.

- Don't generate pre Edition 2018 `extern crate` statements anymore

## [v0.17.0] - 2019-12-31

### Fixed
Expand Down
37 changes: 1 addition & 36 deletions src/generate/device.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::svd::Device;
use proc_macro2::{Ident, Span, TokenStream};
use quote::ToTokens;
use quote::{quote, ToTokens};
use std::fs::File;
use std::io::Write;

Expand Down Expand Up @@ -75,42 +75,7 @@ pub fn render(
#![no_std]
});

match target {
Target::CortexM => {
out.extend(quote! {
extern crate cortex_m;
#[cfg(feature = "rt")]
extern crate cortex_m_rt;
});
}
Target::Msp430 => {
out.extend(quote! {
extern crate msp430;
#[cfg(feature = "rt")]
extern crate msp430_rt;
});
}
Target::RISCV => {
out.extend(quote! {
extern crate riscv;
#[cfg(feature = "rt")]
extern crate riscv_rt;
});
}
Target::XtensaLX6 => {
out.extend(quote! {
extern crate xtensa_lx6;
#[cfg(feature = "rt")]
extern crate xtensa_lx6_rt;
});
}
Target::None => {}
}

out.extend(quote! {
extern crate bare_metal;
extern crate vcell;

use core::ops::Deref;
use core::marker::PhantomData;
});
Expand Down
1 change: 1 addition & 0 deletions src/generate/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::fmt::Write;
use crate::svd::Peripheral;
use cast::u64;
use proc_macro2::{Ident, Span, TokenStream};
use quote::quote;

use crate::util::{self, ToSanitizedUpperCase};
use crate::Target;
Expand Down
2 changes: 1 addition & 1 deletion src/generate/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::svd::{Cluster, ClusterInfo, Peripheral, Register, RegisterCluster, Re
use log::warn;
use proc_macro2::TokenStream;
use proc_macro2::{Ident, Punct, Spacing, Span};
use quote::ToTokens;
use quote::{quote, ToTokens};
use svd_parser::derive_from::DeriveFrom;
use syn::{parse_str, Token};

Expand Down
2 changes: 1 addition & 1 deletion src/generate/register.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::quote::ToTokens;
use crate::svd::{
Access, BitRange, EnumeratedValues, Field, Peripheral, Register, RegisterCluster,
RegisterProperties, Usage, WriteConstraint,
};
use cast::u64;
use log::warn;
use proc_macro2::{Ident, Punct, Spacing, Span, TokenStream};
use quote::{quote, ToTokens};

use crate::util::{self, ToSanitizedSnakeCase, ToSanitizedUpperCase, U32Ext};
use anyhow::{anyhow, Result};
Expand Down
6 changes: 1 addition & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,6 @@
//! used with the `cortex-m` crate `NVIC` API.
//!
//! ```ignore
//! extern crate cortex_m;
//! extern crate stm32f30x;
//!
//! use cortex_m::interrupt;
//! use cortex_m::peripheral::Peripherals;
//! use stm32f30x::Interrupt;
Expand Down Expand Up @@ -481,8 +478,7 @@
//! compiler. Currently there are no nightly features the flag is only kept for compatibility with prior versions.
#![recursion_limit = "128"]

#[macro_use]
extern crate quote;
use quote::quote;
use svd_parser as svd;

mod generate;
Expand Down
5 changes: 1 addition & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#![recursion_limit = "128"]

#[macro_use]
extern crate log;
#[macro_use]
extern crate quote;
use log::error;
use svd_parser as svd;

mod generate;
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::borrow::Cow;

use crate::quote::ToTokens;
use crate::svd::{Access, Cluster, Register, RegisterCluster};
use inflections::Inflect;
use proc_macro2::{Ident, Literal, Span, TokenStream};
use quote::{quote, ToTokens};

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

Expand Down