diff --git a/xso-proc/src/compound.rs b/xso-proc/src/compound.rs index afe8369c..97adab2d 100644 --- a/xso-proc/src/compound.rs +++ b/xso-proc/src/compound.rs @@ -161,7 +161,7 @@ impl Compound { }); text_handler = Some(quote! { #collect - ::core::result::Result::Ok(::std::ops::ControlFlow::Break( + ::core::result::Result::Ok(::core::ops::ControlFlow::Break( Self::#default_state_ident { #builder_data_ident } )) }); @@ -196,14 +196,14 @@ impl Compound { &builder, ).with_mut(substate_data).with_impl(quote! { match #feed(&mut #substate_data, ev)? { - ::std::option::Option::Some(#substate_result) => { + ::core::option::Option::Some(#substate_result) => { #collect - ::std::result::Result::Ok(::std::ops::ControlFlow::Break(Self::#default_state_ident { + ::core::result::Result::Ok(::core::ops::ControlFlow::Break(Self::#default_state_ident { #builder_data_ident, })) } - ::std::option::Option::None => { - ::std::result::Result::Ok(::std::ops::ControlFlow::Break(Self::#state_name { + ::core::option::Option::None => { + ::core::result::Result::Ok(::core::ops::ControlFlow::Break(Self::#state_name { #builder_data_ident, #substate_data, })) @@ -221,10 +221,10 @@ impl Compound { child_matchers.extend(quote! { let (name, attrs) = match #matcher { - ::std::result::Result::Err(::xso::error::FromEventsError::Mismatch { name, attrs }) => (name, attrs), - ::std::result::Result::Err(::xso::error::FromEventsError::Invalid(e)) => return ::std::result::Result::Err(e), - ::std::result::Result::Ok(#substate_data) => { - return ::std::result::Result::Ok(::std::ops::ControlFlow::Break(Self::#state_name { + ::core::result::Result::Err(::xso::error::FromEventsError::Mismatch { name, attrs }) => (name, attrs), + ::core::result::Result::Err(::xso::error::FromEventsError::Invalid(e)) => return ::core::result::Result::Err(e), + ::core::result::Result::Ok(#substate_data) => { + return ::core::result::Result::Ok(::core::ops::ControlFlow::Break(Self::#state_name { #builder_data_ident, #substate_data, })) @@ -255,7 +255,7 @@ impl Compound { if #text.as_bytes().iter().any(|b| *b != b' ' && *b != b'\t' && *b != b'\r' && *b != b'\n') { ::core::result::Result::Err(::xso::error::Error::Other("Unexpected text content".into())) } else { - ::core::result::Result::Ok(::std::ops::ControlFlow::Break( + ::core::result::Result::Ok(::core::ops::ControlFlow::Break( Self::#default_state_ident { #builder_data_ident } )) } @@ -286,7 +286,7 @@ impl Compound { match ev { // EndElement in Default state -> done parsing. ::xso::exports::rxml::Event::EndElement(_) => { - ::core::result::Result::Ok(::std::ops::ControlFlow::Continue( + ::core::result::Result::Ok(::core::ops::ControlFlow::Continue( #output_cons )) } @@ -302,7 +302,7 @@ impl Compound { // them at document start, and there we want to indeed // not worry about them being in front of the first // element. - ::xso::exports::rxml::Event::XmlDeclaration(_, ::xso::exports::rxml::XmlVersion::V1_0) => ::core::result::Result::Ok(::std::ops::ControlFlow::Break( + ::xso::exports::rxml::Event::XmlDeclaration(_, ::xso::exports::rxml::XmlVersion::V1_0) => ::core::result::Result::Ok(::core::ops::ControlFlow::Break( Self::#default_state_ident { #builder_data_ident } )) } @@ -513,7 +513,7 @@ impl Compound { states, destructure, init: quote! { - Self::#element_head_start_state_ident { #dummy_ident: ::std::marker::PhantomData, #name_ident: name.1, #ns_ident: name.0, #start_init } + Self::#element_head_start_state_ident { #dummy_ident: ::core::marker::PhantomData, #name_ident: name.1, #ns_ident: name.0, #start_init } }, }) } diff --git a/xso-proc/src/error_message.rs b/xso-proc/src/error_message.rs index 14d0f309..fbf307fb 100644 --- a/xso-proc/src/error_message.rs +++ b/xso-proc/src/error_message.rs @@ -6,14 +6,14 @@ //! Infrastructure for contextual error messages -use std::fmt; +use core::fmt; use syn::*; /// Reference to a compound field's parent /// /// This reference can be converted to a hopefully-useful human-readable -/// string via [`std::fmt::Display`]. +/// string via [`core::fmt::Display`]. #[derive(Clone, Debug)] pub(super) enum ParentRef { /// The parent is addressable by a path, e.g. a struct type or enum @@ -99,7 +99,7 @@ impl ParentRef { /// Ephemeral struct to create a nice human-readable representation of /// [`syn::Member`]. /// -/// It implements [`std::fmt::Display`] for that purpose and is otherwise of +/// It implements [`core::fmt::Display`] for that purpose and is otherwise of /// little use. #[repr(transparent)] struct FieldName<'x>(&'x Member); diff --git a/xso-proc/src/field.rs b/xso-proc/src/field.rs index 06fa5346..e7ea7c19 100644 --- a/xso-proc/src/field.rs +++ b/xso-proc/src/field.rs @@ -622,7 +622,7 @@ impl FieldDef { Ok(FieldBuilderPart::Nested { extra_defs, value: FieldTempInit { - init: quote! { ::std::option::Option::None }, + init: quote! { ::core::option::Option::None }, ty: option_ty(self.ty.clone()), }, matcher: quote! { @@ -637,12 +637,12 @@ impl FieldDef { }, builder, collect: quote! { - #field_access = ::std::option::Option::Some(#fetch); + #field_access = ::core::option::Option::Some(#fetch); }, finalize: quote! { match #field_access { - ::std::option::Option::Some(value) => value, - ::std::option::Option::None => #on_absent, + ::core::option::Option::Some(value) => value, + ::core::option::Option::None => #on_absent, } }, }) diff --git a/xso-proc/src/lib.rs b/xso-proc/src/lib.rs index ce2385b6..6e2deb65 100644 --- a/xso-proc/src/lib.rs +++ b/xso-proc/src/lib.rs @@ -90,7 +90,7 @@ fn from_xml_impl(input: Item) -> Result { #[cfg(feature = "minidom")] result.extend(quote! { - impl ::std::convert::TryFrom<::xso::exports::minidom::Element> for #ident { + impl ::core::convert::TryFrom<::xso::exports::minidom::Element> for #ident { type Error = ::xso::error::FromElementError; fn try_from(other: ::xso::exports::minidom::Element) -> ::core::result::Result { @@ -147,7 +147,7 @@ fn as_xml_impl(input: Item) -> Result { #[cfg(all(feature = "minidom", feature = "panicking-into-impl"))] result.extend(quote! { - impl ::std::convert::From<#ident> for ::xso::exports::minidom::Element { + impl ::core::convert::From<#ident> for ::xso::exports::minidom::Element { fn from(other: #ident) -> Self { ::xso::transform(other).expect("seamless conversion into minidom::Element") } @@ -156,7 +156,7 @@ fn as_xml_impl(input: Item) -> Result { #[cfg(all(feature = "minidom", not(feature = "panicking-into-impl")))] result.extend(quote! { - impl ::std::convert::TryFrom<#ident> for ::xso::exports::minidom::Element { + impl ::core::convert::TryFrom<#ident> for ::xso::exports::minidom::Element { type Error = ::xso::error::Error; fn try_from(other: #ident) -> ::core::result::Result { diff --git a/xso-proc/src/meta.rs b/xso-proc/src/meta.rs index 7b07c2c5..75653233 100644 --- a/xso-proc/src/meta.rs +++ b/xso-proc/src/meta.rs @@ -9,7 +9,7 @@ //! This module is concerned with parsing attributes from the Rust "meta" //! annotations on structs, enums, enum variants and fields. -use std::hash::{Hash, Hasher}; +use core::hash::{Hash, Hasher}; use proc_macro2::{Span, TokenStream}; use quote::{quote, quote_spanned}; diff --git a/xso-proc/src/state.rs b/xso-proc/src/state.rs index 3d865b31..4d005a1c 100644 --- a/xso-proc/src/state.rs +++ b/xso-proc/src/state.rs @@ -280,8 +280,8 @@ impl AsItemsSubmachine { Self::#name { #destructure } => { let mut #uses_mut = #uses_mut; match #advance_body { - ::std::option::Option::Some(item) => { - ::std::result::Result::Ok((::std::option::Option::Some(Self::#name { #destructure }), ::std::option::Option::Some(item))) + ::core::option::Option::Some(item) => { + ::core::result::Result::Ok((::core::option::Option::Some(Self::#name { #destructure }), ::core::option::Option::Some(item))) }, item => { #footer }, } @@ -496,14 +496,14 @@ impl FromEventsStateMachine { } impl #state_ty_ident { - fn advance(mut self, ev: ::xso::exports::rxml::Event) -> ::core::result::Result<::std::ops::ControlFlow, ::xso::error::Error> { + fn advance(mut self, ev: ::xso::exports::rxml::Event) -> ::core::result::Result<::core::ops::ControlFlow, ::xso::error::Error> { match self { #advance_match_arms }.and_then(|__ok| { match __ok { - ::std::ops::ControlFlow::Break(st) => ::core::result::Result::Ok(::std::ops::ControlFlow::Break(st)), - ::std::ops::ControlFlow::Continue(result) => { - ::core::result::Result::Ok(::std::ops::ControlFlow::Continue(result)) + ::core::ops::ControlFlow::Break(st) => ::core::result::Result::Ok(::core::ops::ControlFlow::Break(st)), + ::core::ops::ControlFlow::Continue(result) => { + ::core::result::Result::Ok(::core::ops::ControlFlow::Continue(result)) } } }) @@ -528,8 +528,8 @@ impl FromEventsStateMachine { fn feed(&mut self, ev: ::xso::exports::rxml::Event) -> ::core::result::Result<::core::option::Option, ::xso::error::Error> { let inner = self.0.take().expect("feed called after completion"); match inner.advance(ev)? { - ::std::ops::ControlFlow::Continue(value) => ::core::result::Result::Ok(::core::option::Option::Some(value)), - ::std::ops::ControlFlow::Break(st) => { + ::core::ops::ControlFlow::Continue(value) => ::core::result::Result::Ok(::core::option::Option::Some(value)), + ::core::ops::ControlFlow::Break(st) => { self.0 = ::core::option::Option::Some(st); ::core::result::Result::Ok(::core::option::Option::None) } @@ -651,7 +651,7 @@ impl AsItemsStateMachine { } = self; let input_ty_ref_text = make_ty_ref(input_ty_ref); - let docstr = format!("Convert a {0} into XML events.\n\nThis type is generated using the [`macro@xso::AsXml`] derive macro and implements [`std::iter:Iterator`] for {0}.", input_ty_ref_text); + let docstr = format!("Convert a {0} into XML events.\n\nThis type is generated using the [`macro@xso::AsXml`] derive macro and implements [`core::iter:Iterator`] for {0}.", input_ty_ref_text); let init_body = if variants.len() == 1 { let AsItemsEntryPoint { destructure, init } = variants.remove(0); @@ -700,7 +700,7 @@ impl AsItemsStateMachine { #[doc = #docstr] #vis struct #item_iter_ty(::core::option::Option<#state_ty_ident<#item_iter_ty_lifetime>>); - impl<#item_iter_ty_lifetime> ::std::iter::Iterator for #item_iter_ty { + impl<#item_iter_ty_lifetime> ::core::iter::Iterator for #item_iter_ty { type Item = ::core::result::Result<::xso::Item<#item_iter_ty_lifetime>, ::xso::error::Error>; fn next(&mut self) -> ::core::option::Option { diff --git a/xso-proc/src/types.rs b/xso-proc/src/types.rs index 68ee65c0..1b0f2b70 100644 --- a/xso-proc/src/types.rs +++ b/xso-proc/src/types.rs @@ -193,7 +193,7 @@ pub(crate) fn as_optional_xml_text_fn(ty: Type) -> Expr { } /// Construct a [`syn::Expr`] referring to -/// `<#of_ty as ::std::default::Default>::default`. +/// `<#of_ty as ::core::default::Default>::default`. pub(crate) fn default_fn(of_ty: Type) -> Expr { let span = of_ty.span(); Expr::Path(ExprPath { @@ -211,7 +211,7 @@ pub(crate) fn default_fn(of_ty: Type) -> Expr { }), segments: [ PathSegment { - ident: Ident::new("std", span), + ident: Ident::new("core", span), arguments: PathArguments::None, }, PathSegment { @@ -373,7 +373,7 @@ pub(crate) fn ref_ty(ty: Type, lifetime: Lifetime) -> Type { } /// Construct a [`syn::Type`] referring to -/// `::std::marker::PhantomData<&#lifetime ()>`. +/// `::core::marker::PhantomData<&#lifetime ()>`. pub(crate) fn phantom_lifetime_ty(lifetime: Lifetime) -> Type { let span = lifetime.span(); let dummy = Type::Tuple(TypeTuple { @@ -388,7 +388,7 @@ pub(crate) fn phantom_lifetime_ty(lifetime: Lifetime) -> Type { }), segments: [ PathSegment { - ident: Ident::new("std", span), + ident: Ident::new("core", span), arguments: PathArguments::None, }, PathSegment { @@ -475,7 +475,7 @@ pub(crate) fn from_events_fn(of_ty: Type) -> Expr { } /// Construct a [`syn::Type`] which wraps the given `ty` in -/// `::std::option::Option<_>`. +/// `::core::option::Option<_>`. pub(crate) fn option_ty(ty: Type) -> Type { let span = ty.span(); Type::Path(TypePath { @@ -486,7 +486,7 @@ pub(crate) fn option_ty(ty: Type) -> Type { }), segments: [ PathSegment { - ident: Ident::new("std", span), + ident: Ident::new("core", span), arguments: PathArguments::None, }, PathSegment { @@ -642,7 +642,7 @@ fn into_iterator_of(of_ty: Type) -> (Span, TypePath) { }), segments: [ PathSegment { - ident: Ident::new("std", span), + ident: Ident::new("core", span), arguments: PathArguments::None, }, PathSegment { @@ -699,7 +699,7 @@ pub(crate) fn into_iterator_into_iter_fn(of_ty: Type) -> Expr { } /// Construct a [`syn::Expr`] referring to -/// `<#of_ty as ::std::iter::Extend>::extend`. +/// `<#of_ty as ::core::iter::Extend>::extend`. pub(crate) fn extend_fn(of_ty: Type, item_ty: Type) -> Expr { let span = of_ty.span(); Expr::Path(ExprPath { @@ -717,7 +717,7 @@ pub(crate) fn extend_fn(of_ty: Type, item_ty: Type) -> Expr { }), segments: [ PathSegment { - ident: Ident::new("std", span), + ident: Ident::new("core", span), arguments: PathArguments::None, }, PathSegment {