From 00307a5b6f1d81fb5d19f1ef7235ff235ce75d50 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 30 Jun 2022 10:20:19 +1000 Subject: [PATCH] Rename `Ty::Literal` as `Ty::Path`. Because a `Literal` is a type of expression, and is simply the wrong name for this. --- compiler/rustc_builtin_macros/src/deriving/clone.rs | 2 +- compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs | 2 +- .../src/deriving/cmp/partial_eq.rs | 2 +- .../src/deriving/cmp/partial_ord.rs | 9 +++------ compiler/rustc_builtin_macros/src/deriving/debug.rs | 4 ++-- .../rustc_builtin_macros/src/deriving/decodable.rs | 10 +++------- .../rustc_builtin_macros/src/deriving/encodable.rs | 10 +++------- .../rustc_builtin_macros/src/deriving/generic/ty.rs | 6 +++--- compiler/rustc_builtin_macros/src/deriving/hash.rs | 2 +- 9 files changed, 18 insertions(+), 29 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/deriving/clone.rs b/compiler/rustc_builtin_macros/src/deriving/clone.rs index 05d1fdbd513..1c507678489 100644 --- a/compiler/rustc_builtin_macros/src/deriving/clone.rs +++ b/compiler/rustc_builtin_macros/src/deriving/clone.rs @@ -55,7 +55,7 @@ pub fn expand_deriving_clone( } } ItemKind::Union(..) => { - bounds = vec![Literal(path_std!(marker::Copy))]; + bounds = vec![Path(path_std!(marker::Copy))]; is_simple = true; substructure = combine_substructure(Box::new(|c, s, sub| { cs_clone_simple("Clone", c, s, sub, true) diff --git a/compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs b/compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs index ae1bfea20d8..c7850cd4b4c 100644 --- a/compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs +++ b/compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs @@ -29,7 +29,7 @@ pub fn expand_deriving_ord( generics: Bounds::empty(), explicit_self: true, args: vec![(self_ref(), sym::other)], - ret_ty: Literal(path_std!(cmp::Ordering)), + ret_ty: Path(path_std!(cmp::Ordering)), attributes: attrs, unify_fieldless_variants: true, combine_substructure: combine_substructure(Box::new(|a, b, c| cs_cmp(a, b, c))), diff --git a/compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs b/compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs index f086e7c16fd..ca5ca29eb82 100644 --- a/compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs +++ b/compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs @@ -71,7 +71,7 @@ pub fn expand_deriving_partial_eq( generics: Bounds::empty(), explicit_self: true, args: vec![(self_ref(), sym::other)], - ret_ty: Literal(path_local!(bool)), + ret_ty: Path(path_local!(bool)), attributes: attrs, unify_fieldless_variants: true, combine_substructure: combine_substructure(Box::new(|a, b, c| $f(a, b, c))), diff --git a/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs b/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs index dfc3e8c6ef2..07db82fee93 100644 --- a/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs +++ b/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs @@ -15,12 +15,9 @@ pub fn expand_deriving_partial_ord( item: &Annotatable, push: &mut dyn FnMut(Annotatable), ) { - let ordering_ty = Literal(path_std!(cmp::Ordering)); - let ret_ty = Literal(Path::new_( - pathvec_std!(option::Option), - vec![Box::new(ordering_ty)], - PathKind::Std, - )); + let ordering_ty = Path(path_std!(cmp::Ordering)); + let ret_ty = + Path(Path::new_(pathvec_std!(option::Option), vec![Box::new(ordering_ty)], PathKind::Std)); let inline = cx.meta_word(span, sym::inline); let attrs = vec![cx.attribute(inline)]; diff --git a/compiler/rustc_builtin_macros/src/deriving/debug.rs b/compiler/rustc_builtin_macros/src/deriving/debug.rs index 8da624c4b82..1411c60c0bf 100644 --- a/compiler/rustc_builtin_macros/src/deriving/debug.rs +++ b/compiler/rustc_builtin_macros/src/deriving/debug.rs @@ -16,7 +16,7 @@ pub fn expand_deriving_debug( push: &mut dyn FnMut(Annotatable), ) { // &mut ::std::fmt::Formatter - let fmtr = Ref(Box::new(Literal(path_std!(fmt::Formatter))), ast::Mutability::Mut); + let fmtr = Ref(Box::new(Path(path_std!(fmt::Formatter))), ast::Mutability::Mut); let trait_def = TraitDef { span, @@ -30,7 +30,7 @@ pub fn expand_deriving_debug( generics: Bounds::empty(), explicit_self: true, args: vec![(fmtr, sym::f)], - ret_ty: Literal(path_std!(fmt::Result)), + ret_ty: Path(path_std!(fmt::Result)), attributes: Vec::new(), unify_fieldless_variants: false, combine_substructure: combine_substructure(Box::new(|a, b, c| { diff --git a/compiler/rustc_builtin_macros/src/deriving/decodable.rs b/compiler/rustc_builtin_macros/src/deriving/decodable.rs index 4bd8340e099..16154fb4d03 100644 --- a/compiler/rustc_builtin_macros/src/deriving/decodable.rs +++ b/compiler/rustc_builtin_macros/src/deriving/decodable.rs @@ -36,16 +36,12 @@ pub fn expand_deriving_rustc_decodable( )], }, explicit_self: false, - args: vec![(Ref(Box::new(Literal(Path::new_local(typaram))), Mutability::Mut), sym::d)], - ret_ty: Literal(Path::new_( + args: vec![(Ref(Box::new(Path(Path::new_local(typaram))), Mutability::Mut), sym::d)], + ret_ty: Path(Path::new_( pathvec_std!(result::Result), vec![ Box::new(Self_), - Box::new(Literal(Path::new_( - vec![typaram, sym::Error], - vec![], - PathKind::Local, - ))), + Box::new(Path(Path::new_(vec![typaram, sym::Error], vec![], PathKind::Local))), ], PathKind::Std, )), diff --git a/compiler/rustc_builtin_macros/src/deriving/encodable.rs b/compiler/rustc_builtin_macros/src/deriving/encodable.rs index 829e258c36b..7cce1a0c2a2 100644 --- a/compiler/rustc_builtin_macros/src/deriving/encodable.rs +++ b/compiler/rustc_builtin_macros/src/deriving/encodable.rs @@ -121,16 +121,12 @@ pub fn expand_deriving_rustc_encodable( )], }, explicit_self: true, - args: vec![(Ref(Box::new(Literal(Path::new_local(typaram))), Mutability::Mut), sym::s)], - ret_ty: Literal(Path::new_( + args: vec![(Ref(Box::new(Path(Path::new_local(typaram))), Mutability::Mut), sym::s)], + ret_ty: Path(Path::new_( pathvec_std!(result::Result), vec![ Box::new(Tuple(Vec::new())), - Box::new(Literal(Path::new_( - vec![typaram, sym::Error], - vec![], - PathKind::Local, - ))), + Box::new(Path(Path::new_(vec![typaram, sym::Error], vec![], PathKind::Local))), ], PathKind::Std, )), diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs b/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs index 6b2f31c64e1..c2dcff36c39 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs @@ -77,7 +77,7 @@ pub enum Ty { Ref(Box, ast::Mutability), /// `mod::mod::Type<[lifetime], [Params...]>`, including a plain type /// parameter, and things like `i32` - Literal(Path), + Path(Path), /// includes unit Tuple(Vec), } @@ -103,7 +103,7 @@ impl Ty { let raw_ty = ty.to_ty(cx, span, self_ty, self_generics); cx.ty_rptr(span, raw_ty, None, *mutbl) } - Literal(p) => p.to_ty(cx, span, self_ty, self_generics), + Path(p) => p.to_ty(cx, span, self_ty, self_generics), Self_ => cx.ty_path(self.to_path(cx, span, self_ty, self_generics)), Tuple(fields) => { let ty = ast::TyKind::Tup( @@ -141,7 +141,7 @@ impl Ty { cx.path_all(span, false, vec![self_ty], params) } - Literal(ref p) => p.to_path(cx, span, self_ty, generics), + Path(ref p) => p.to_path(cx, span, self_ty, generics), Ref(..) => cx.span_bug(span, "ref in a path in generic `derive`"), Tuple(..) => cx.span_bug(span, "tuple in a path in generic `derive`"), } diff --git a/compiler/rustc_builtin_macros/src/deriving/hash.rs b/compiler/rustc_builtin_macros/src/deriving/hash.rs index 906eef32f79..641744c47ce 100644 --- a/compiler/rustc_builtin_macros/src/deriving/hash.rs +++ b/compiler/rustc_builtin_macros/src/deriving/hash.rs @@ -31,7 +31,7 @@ pub fn expand_deriving_hash( name: sym::hash, generics: Bounds { bounds: vec![(typaram, vec![path_std!(hash::Hasher)])] }, explicit_self: true, - args: vec![(Ref(Box::new(Literal(arg)), Mutability::Mut), sym::state)], + args: vec![(Ref(Box::new(Path(arg)), Mutability::Mut), sym::state)], ret_ty: nil_ty(), attributes: vec![], unify_fieldless_variants: true,