This shaves off another ~4 mb or so
crate::type_ref::TraitRef,
crate::type_ref::TypeBound,
crate::path::ModPath,
crate::type_ref::TraitRef,
crate::type_ref::TypeBound,
crate::path::ModPath,
+ crate::path::GenericArgs,
let binding =
AssociatedTypeBinding { name: name![Output], type_ref: Some(orig), bounds: Vec::new() };
last.bindings.push(binding);
let binding =
AssociatedTypeBinding { name: name![Output], type_ref: Some(orig), bounds: Vec::new() };
last.bindings.push(binding);
- generic_args.push(Some(Arc::new(last)));
+ generic_args.push(Some(Interned::new(last)));
Path::from_known_path(path, generic_args)
}
Path::from_known_path(path, generic_args)
}
use std::{
fmt::{self, Display},
iter,
use std::{
fmt::{self, Display},
iter,
};
use crate::{body::LowerCtx, db::DefDatabase, intern::Interned, type_ref::LifetimeRef};
};
use crate::{body::LowerCtx, db::DefDatabase, intern::Interned, type_ref::LifetimeRef};
type_anchor: Option<Interned<TypeRef>>,
mod_path: Interned<ModPath>,
/// Invariant: the same len as `self.mod_path.segments`
type_anchor: Option<Interned<TypeRef>>,
mod_path: Interned<ModPath>,
/// Invariant: the same len as `self.mod_path.segments`
- generic_args: Vec<Option<Arc<GenericArgs>>>,
+ generic_args: Vec<Option<Interned<GenericArgs>>>,
}
/// Generic arguments to a path segment (e.g. the `i32` in `Option<i32>`). This
}
/// Generic arguments to a path segment (e.g. the `i32` in `Option<i32>`). This
/// Converts a known mod path to `Path`.
pub(crate) fn from_known_path(
path: ModPath,
/// Converts a known mod path to `Path`.
pub(crate) fn from_known_path(
path: ModPath,
- generic_args: Vec<Option<Arc<GenericArgs>>>,
+ generic_args: Vec<Option<Interned<GenericArgs>>>,
) -> Path {
Path { type_anchor: None, mod_path: Interned::new(path), generic_args }
}
) -> Path {
Path { type_anchor: None, mod_path: Interned::new(path), generic_args }
}
pub struct PathSegments<'a> {
segments: &'a [Name],
pub struct PathSegments<'a> {
segments: &'a [Name],
- generic_args: &'a [Option<Arc<GenericArgs>>],
+ generic_args: &'a [Option<Interned<GenericArgs>>],
}
impl<'a> PathSegments<'a> {
}
impl<'a> PathSegments<'a> {
mod lower_use;
use crate::intern::Interned;
mod lower_use;
use crate::intern::Interned;
use either::Either;
use hir_expand::name::{name, AsName};
use either::Either;
use hir_expand::name::{name, AsName};
segments.push(name);
generic_args.push(args)
}
segments.push(name);
generic_args.push(args)
}
// Insert the type reference (T in the above example) as Self parameter for the trait
let last_segment =
generic_args.iter_mut().rev().nth(num_segments.saturating_sub(1))?;
// Insert the type reference (T in the above example) as Self parameter for the trait
let last_segment =
generic_args.iter_mut().rev().nth(num_segments.saturating_sub(1))?;
- if last_segment.is_none() {
- *last_segment = Some(Arc::new(GenericArgs::empty()));
+ let mut args_inner = match last_segment {
+ Some(it) => it.as_ref().clone(),
+ None => GenericArgs::empty(),
- let args = last_segment.as_mut().unwrap();
- let mut args_inner = Arc::make_mut(args);
args_inner.has_self_type = true;
args_inner.args.insert(0, GenericArg::Type(self_type));
args_inner.has_self_type = true;
args_inner.args.insert(0, GenericArg::Type(self_type));
+ *last_segment = Some(Interned::new(args_inner));