Utilize fewer reexports
In regards to: https://github.com/rust-lang/rust/issues/19253#issuecomment-64836729 This commit: * Changes the #deriving code so that it generates code that utilizes fewer reexports (in particur Option::* and Result::*), which is necessary to remove those reexports in the future * Changes other areas of the codebase so that fewer reexports are utilized
This commit is contained in:
parent
6f4c11be3b
commit
4ef16741e3
85 changed files with 277 additions and 195 deletions
|
|
@ -680,6 +680,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
let some = vec!(
|
||||
self.ident_of("std"),
|
||||
self.ident_of("option"),
|
||||
self.ident_of("Option"),
|
||||
self.ident_of("Some"));
|
||||
self.expr_call_global(sp, some, vec!(expr))
|
||||
}
|
||||
|
|
@ -688,6 +689,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
let none = self.path_global(sp, vec!(
|
||||
self.ident_of("std"),
|
||||
self.ident_of("option"),
|
||||
self.ident_of("Option"),
|
||||
self.ident_of("None")));
|
||||
self.expr_path(none)
|
||||
}
|
||||
|
|
@ -732,6 +734,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
let ok = vec!(
|
||||
self.ident_of("std"),
|
||||
self.ident_of("result"),
|
||||
self.ident_of("Result"),
|
||||
self.ident_of("Ok"));
|
||||
self.expr_call_global(sp, ok, vec!(expr))
|
||||
}
|
||||
|
|
@ -740,6 +743,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
let err = vec!(
|
||||
self.ident_of("std"),
|
||||
self.ident_of("result"),
|
||||
self.ident_of("Result"),
|
||||
self.ident_of("Err"));
|
||||
self.expr_call_global(sp, err, vec!(expr))
|
||||
}
|
||||
|
|
@ -810,6 +814,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
let some = vec!(
|
||||
self.ident_of("std"),
|
||||
self.ident_of("option"),
|
||||
self.ident_of("Option"),
|
||||
self.ident_of("Some"));
|
||||
let path = self.path_global(span, some);
|
||||
self.pat_enum(span, path, vec!(pat))
|
||||
|
|
@ -819,6 +824,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
let some = vec!(
|
||||
self.ident_of("std"),
|
||||
self.ident_of("option"),
|
||||
self.ident_of("Option"),
|
||||
self.ident_of("None"));
|
||||
let path = self.path_global(span, some);
|
||||
self.pat_enum(span, path, vec!())
|
||||
|
|
@ -828,6 +834,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
let some = vec!(
|
||||
self.ident_of("std"),
|
||||
self.ident_of("result"),
|
||||
self.ident_of("Result"),
|
||||
self.ident_of("Ok"));
|
||||
let path = self.path_global(span, some);
|
||||
self.pat_enum(span, path, vec!(pat))
|
||||
|
|
@ -837,6 +844,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
let some = vec!(
|
||||
self.ident_of("std"),
|
||||
self.ident_of("result"),
|
||||
self.ident_of("Result"),
|
||||
self.ident_of("Err"));
|
||||
let path = self.path_global(span, some);
|
||||
self.pat_enum(span, path, vec!(pat))
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span,
|
|||
let ordering = cx.path_global(span,
|
||||
vec!(cx.ident_of("std"),
|
||||
cx.ident_of("cmp"),
|
||||
cx.ident_of("Ordering"),
|
||||
cx.ident_of("Equal")));
|
||||
let ordering = cx.expr_path(ordering);
|
||||
let equals_expr = cx.expr_some(span, ordering);
|
||||
|
|
@ -120,9 +121,9 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span,
|
|||
Builds:
|
||||
|
||||
let __test = ::std::cmp::PartialOrd::partial_cmp(&self_field1, &other_field1);
|
||||
if __test == ::std::option::Some(::std::cmp::Equal) {
|
||||
if __test == ::std::option::Option::Some(::std::cmp::Ordering::Equal) {
|
||||
let __test = ::std::cmp::PartialOrd::partial_cmp(&self_field2, &other_field2);
|
||||
if __test == ::std::option::Some(::std::cmp::Equal) {
|
||||
if __test == ::std::option::Option::Some(::std::cmp::Ordering::Equal) {
|
||||
...
|
||||
} else {
|
||||
__test
|
||||
|
|
@ -139,7 +140,7 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span,
|
|||
false,
|
||||
|cx, span, old, self_f, other_fs| {
|
||||
// let __test = new;
|
||||
// if __test == Some(::std::cmp::Equal) {
|
||||
// if __test == Some(::std::cmp::Ordering::Equal) {
|
||||
// old
|
||||
// } else {
|
||||
// __test
|
||||
|
|
|
|||
|
|
@ -70,9 +70,9 @@ pub fn cs_cmp(cx: &mut ExtCtxt, span: Span,
|
|||
Builds:
|
||||
|
||||
let __test = self_field1.cmp(&other_field2);
|
||||
if other == ::std::cmp::Equal {
|
||||
if other == ::std::cmp::Ordering::Equal {
|
||||
let __test = self_field2.cmp(&other_field2);
|
||||
if __test == ::std::cmp::Equal {
|
||||
if __test == ::std::cmp::Ordering::Equal {
|
||||
...
|
||||
} else {
|
||||
__test
|
||||
|
|
@ -89,7 +89,7 @@ pub fn cs_cmp(cx: &mut ExtCtxt, span: Span,
|
|||
false,
|
||||
|cx, span, old, new| {
|
||||
// let __test = new;
|
||||
// if __test == ::std::cmp::Equal {
|
||||
// if __test == ::std::cmp::Ordering::Equal {
|
||||
// old
|
||||
// } else {
|
||||
// __test
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenT
|
|||
true,
|
||||
vec!(cx.ident_of("std"),
|
||||
cx.ident_of("option"),
|
||||
cx.ident_of("Option"),
|
||||
cx.ident_of("None")),
|
||||
Vec::new(),
|
||||
vec!(cx.ty_rptr(sp,
|
||||
|
|
@ -50,6 +51,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenT
|
|||
cx.expr_call_global(sp,
|
||||
vec!(cx.ident_of("std"),
|
||||
cx.ident_of("option"),
|
||||
cx.ident_of("Option"),
|
||||
cx.ident_of("Some")),
|
||||
vec!(cx.expr_str(sp,
|
||||
token::intern_and_get_ident(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue