change.change_file(file_id, Some(Arc::new(text)));
let path = VfsPath::new_virtual_path(meta.path);
- file_set.insert(file_id, path.into());
+ file_set.insert(file_id, path);
files.push(file_id);
file_id.0 += 1;
}
Some(Namespace::Macros) => return None,
None => resolved.iter_items().find_map(|it| it.as_module_def_id())?,
};
- Some(def.into())
+ Some(def)
}
// FIXME: why is this an option? It shouldn't be?
pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
- let body = db.body(self.parent.into());
+ let body = db.body(self.parent);
match &body[self.pat_id] {
Pat::Bind { name, .. } => Some(name.clone()),
_ => None,
}
pub fn is_mut(self, db: &dyn HirDatabase) -> bool {
- let body = db.body(self.parent.into());
+ let body = db.body(self.parent);
matches!(&body[self.pat_id], Pat::Bind { mode: BindingAnnotation::Mutable, .. })
}
}
pub fn ty(self, db: &dyn HirDatabase) -> Type {
- let def = DefWithBodyId::from(self.parent);
+ let def = self.parent;
let infer = db.infer(def);
let ty = infer[self.pat_id].clone();
let krate = def.module(db.upcast()).krate();
}
pub fn source(self, db: &dyn HirDatabase) -> InFile<Either<ast::IdentPat, ast::SelfParam>> {
- let (_body, source_map) = db.body_with_source_map(self.parent.into());
+ let (_body, source_map) = db.body_with_source_map(self.parent);
let src = source_map.pat_syntax(self.pat_id).unwrap(); // Hmm...
let root = src.file_syntax(db.upcast());
src.map(|ast| {
}
pub fn name(self, db: &dyn HirDatabase) -> Name {
- let body = db.body(self.parent.into());
+ let body = db.body(self.parent);
body[self.label_id].name.clone()
}
pub fn source(self, db: &dyn HirDatabase) -> InFile<ast::Label> {
- let (_body, source_map) = db.body_with_source_map(self.parent.into());
+ let (_body, source_map) = db.body_with_source_map(self.parent);
let src = source_map.label_syntax(self.label_id);
let root = src.file_syntax(db.upcast());
src.map(|ast| ast.to_node(&root))
resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()),
resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(id.into()),
resolver::ScopeDef::Local(pat_id) => {
- let parent = resolver.body_owner().unwrap().into();
+ let parent = resolver.body_owner().unwrap();
ScopeDef::Local(Local { parent, pat_id })
}
};
resolver.resolve_path_in_value_ns_fully(db.upcast(), path.mod_path()).and_then(|val| {
let res = match val {
ValueNs::LocalBinding(pat_id) => {
- let var = Local { parent: body_owner?.into(), pat_id };
+ let var = Local { parent: body_owner?, pat_id };
PathResolution::Local(var)
}
ValueNs::FunctionId(it) => PathResolution::Def(Function::from(it).into()),
if docs.is_empty() {
None
} else {
- Some(Documentation(docs.into()))
+ Some(Documentation(docs))
}
}
}
let diagnostic = IncorrectCase {
file: fn_src.file_id,
ident_type: IdentType::Function,
- ident: AstPtr::new(&ast_ptr).into(),
+ ident: AstPtr::new(&ast_ptr),
expected_case: replacement.expected_case,
ident_text: replacement.current_name.to_string(),
suggested_text: replacement.suggested_text,
let diagnostic = IncorrectCase {
file: fn_src.file_id,
ident_type: IdentType::Argument,
- ident: AstPtr::new(&ast_ptr).into(),
+ ident: AstPtr::new(&ast_ptr),
expected_case: param_to_rename.expected_case,
ident_text: param_to_rename.current_name.to_string(),
suggested_text: param_to_rename.suggested_text,
let diagnostic = IncorrectCase {
file: source_ptr.file_id,
ident_type: IdentType::Variable,
- ident: AstPtr::new(&name_ast).into(),
+ ident: AstPtr::new(&name_ast),
expected_case: replacement.expected_case,
ident_text: replacement.current_name.to_string(),
suggested_text: replacement.suggested_text,
let diagnostic = IncorrectCase {
file: struct_src.file_id,
ident_type: IdentType::Structure,
- ident: AstPtr::new(&ast_ptr).into(),
+ ident: AstPtr::new(&ast_ptr),
expected_case: replacement.expected_case,
ident_text: replacement.current_name.to_string(),
suggested_text: replacement.suggested_text,
let diagnostic = IncorrectCase {
file: struct_src.file_id,
ident_type: IdentType::Field,
- ident: AstPtr::new(&ast_ptr).into(),
+ ident: AstPtr::new(&ast_ptr),
expected_case: field_to_rename.expected_case,
ident_text: field_to_rename.current_name.to_string(),
suggested_text: field_to_rename.suggested_text,
let diagnostic = IncorrectCase {
file: enum_src.file_id,
ident_type: IdentType::Enum,
- ident: AstPtr::new(&ast_ptr).into(),
+ ident: AstPtr::new(&ast_ptr),
expected_case: replacement.expected_case,
ident_text: replacement.current_name.to_string(),
suggested_text: replacement.suggested_text,
let diagnostic = IncorrectCase {
file: enum_src.file_id,
ident_type: IdentType::Variant,
- ident: AstPtr::new(&ast_ptr).into(),
+ ident: AstPtr::new(&ast_ptr),
expected_case: variant_to_rename.expected_case,
ident_text: variant_to_rename.current_name.to_string(),
suggested_text: variant_to_rename.suggested_text,
let diagnostic = IncorrectCase {
file: const_src.file_id,
ident_type: IdentType::Constant,
- ident: AstPtr::new(&ast_ptr).into(),
+ ident: AstPtr::new(&ast_ptr),
expected_case: replacement.expected_case,
ident_text: replacement.current_name.to_string(),
suggested_text: replacement.suggested_text,
let diagnostic = IncorrectCase {
file: static_src.file_id,
ident_type: IdentType::StaticVariable,
- ident: AstPtr::new(&ast_ptr).into(),
+ ident: AstPtr::new(&ast_ptr),
expected_case: replacement.expected_case,
ident_text: replacement.current_name.to_string(),
suggested_text: replacement.suggested_text,
pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) {
self.check_for_filter_map_next(db);
- let body = db.body(self.owner.into());
+ let body = db.body(self.owner);
for (id, expr) in body.exprs.iter() {
if let Some((variant_def, missed_fields, true)) =
missed_fields: Vec<LocalFieldId>,
) {
// XXX: only look at source_map if we do have missing fields
- let (_, source_map) = db.body_with_source_map(self.owner.into());
+ let (_, source_map) = db.body_with_source_map(self.owner);
if let Ok(source_ptr) = source_map.expr_syntax(id) {
let root = source_ptr.file_syntax(db.upcast());
missed_fields: Vec<LocalFieldId>,
) {
// XXX: only look at source_map if we do have missing fields
- let (_, source_map) = db.body_with_source_map(self.owner.into());
+ let (_, source_map) = db.body_with_source_map(self.owner);
if let Ok(source_ptr) = source_map.pat_syntax(id) {
if let Some(expr) = source_ptr.value.as_ref().left() {
};
// Search function body for instances of .filter_map(..).next()
- let body = db.body(self.owner.into());
+ let body = db.body(self.owner);
let mut prev = None;
for (id, expr) in body.exprs.iter() {
if let Expr::MethodCall { receiver, .. } = expr {
if function_id == *next_function_id {
if let Some(filter_map_id) = prev {
if *receiver == filter_map_id {
- let (_, source_map) = db.body_with_source_map(self.owner.into());
+ let (_, source_map) = db.body_with_source_map(self.owner);
if let Ok(next_source_ptr) = source_map.expr_syntax(id) {
self.sink.push(ReplaceFilterMapNextWithFindMap {
file: next_source_ptr.file_id,
let mut arg_count = args.len();
if arg_count != param_count {
- let (_, source_map) = db.body_with_source_map(self.owner.into());
+ let (_, source_map) = db.body_with_source_map(self.owner);
if let Ok(source_ptr) = source_map.expr_syntax(call_id) {
if is_method_call {
param_count -= 1;
infer: Arc<InferenceResult>,
) {
let (body, source_map): (Arc<Body>, Arc<BodySourceMap>) =
- db.body_with_source_map(self.owner.into());
+ db.body_with_source_map(self.owner);
let match_expr_ty = if infer.type_of_expr[match_expr].is_unknown() {
return;
};
if params.len() > 0 && params[0] == mismatch.actual {
- let (_, source_map) = db.body_with_source_map(self.owner.into());
+ let (_, source_map) = db.body_with_source_map(self.owner);
if let Ok(source_ptr) = source_map.expr_syntax(id) {
self.sink.push(MissingOkOrSomeInTailExpr {
return;
}
- let (_, source_map) = db.body_with_source_map(self.owner.into());
+ let (_, source_map) = db.body_with_source_map(self.owner);
if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) {
self.sink
}
pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) {
- let def = self.owner.into();
+ let def = self.owner;
let unsafe_expressions = unsafe_expressions(db, self.infer.as_ref(), def);
let is_unsafe = match self.owner {
DefWithBodyId::FunctionId(it) => db.function_data(it).qualifier.is_unsafe,
TyKind::Tuple(cardinality, substs) => {
let substitution = substs.to_chalk(db);
- chalk_ir::TyKind::Tuple(cardinality.into(), substitution).intern(&Interner)
+ chalk_ir::TyKind::Tuple(cardinality, substitution).intern(&Interner)
}
TyKind::Raw(mutability, ty) => {
let ty = ty.to_chalk(db);
let def_id = sema.resolve_variant(record_lit)?;
let module;
let def_file_id;
- let record_fields = match VariantDef::from(def_id) {
+ let record_fields = match def_id {
VariantDef::Struct(s) => {
module = s.module(sema.db);
let source = s.source(sema.db)?;
impl Completions {
pub(crate) fn add(&mut self, item: CompletionItem) {
- self.buf.push(item.into())
+ self.buf.push(item)
}
pub(crate) fn add_all<I>(&mut self, items: I)
impl FormatStrParser {
pub(crate) fn new(input: String) -> Self {
Self {
- input: input.into(),
+ input: input,
output: String::new(),
extracted_expressions: Vec::new(),
state: State::NotExpr,
},
ast::SelfParam(it) => {
let def = sema.to_def(&it)?;
- Some(NameClass::Definition(Definition::Local(def.into())))
+ Some(NameClass::Definition(Definition::Local(def)))
},
ast::RecordField(it) => {
let field: hir::Field = sema.to_def(&it)?;
})
.last()
.map(|last_inner_element| {
- (InsertPosition::After(last_inner_element.into()), AddBlankLine::BeforeTwice)
+ (InsertPosition::After(last_inner_element), AddBlankLine::BeforeTwice)
})
.unwrap_or_else(|| self.first_insert_pos())
}
Some("pat") => parent.token_trees.push(make_ident("foo")),
Some("path") => parent.token_trees.push(make_ident("foo")),
Some("literal") => parent.token_trees.push(make_literal("1")),
- Some("expr") => parent.token_trees.push(make_ident("foo").into()),
+ Some("expr") => parent.token_trees.push(make_ident("foo")),
Some("lifetime") => {
parent.token_trees.push(make_punct('\''));
parent.token_trees.push(make_ident("a"));
if i + 1 != cnt {
if let Some(sep) = separator {
match sep {
- Separator::Literal(it) => parent
- .token_trees
- .push(tt::Leaf::Literal(it.clone().into()).into()),
- Separator::Ident(it) => parent
- .token_trees
- .push(tt::Leaf::Ident(it.clone().into()).into()),
+ Separator::Literal(it) => {
+ parent.token_trees.push(tt::Leaf::Literal(it.clone()).into())
+ }
+ Separator::Ident(it) => {
+ parent.token_trees.push(tt::Leaf::Ident(it.clone()).into())
+ }
Separator::Puncts(puncts) => {
for it in puncts {
- parent
- .token_trees
- .push(tt::Leaf::Punct(it.clone().into()).into())
+ parent.token_trees.push(tt::Leaf::Punct(it.clone()).into())
}
}
};
input
.expect_literal()
.map(|literal| {
- let lit = tt::Leaf::from(literal.clone());
+ let lit = literal.clone();
match neg {
None => Some(lit.into()),
Some(neg) => Some(tt::TokenTree::Subtree(tt::Subtree {
res.push(match expanded.value {
None => break,
Some(tt @ tt::TokenTree::Leaf(_)) => {
- tt::Subtree { delimiter: None, token_trees: vec![tt.into()] }
+ tt::Subtree { delimiter: None, token_trees: vec![tt] }
}
Some(tt::TokenTree::Subtree(tt)) => tt,
});
// Note: We always assume the semi-colon would be the last token in
// other parts of RA such that we don't add whitespace here.
if curr.spacing == tt::Spacing::Alone && curr.char != ';' {
- self.inner.token(WHITESPACE, " ".into());
+ self.inner.token(WHITESPACE, " ");
self.text_pos += TextSize::of(' ');
}
}
fn test_invalid_arms() {
fn check(macro_body: &str, err: ParseError) {
let m = parse_macro_arm(macro_body);
- assert_eq!(m, Err(err.into()));
+ assert_eq!(m, Err(err));
}
check("invalid", ParseError::Expected("expected subtree".into()));
subtree
.token_trees
.push(TokenTree::Leaf(Ident { text: "Foo".into(), id: TokenId(1) }.into()));
- subtree.token_trees.push(TokenTree::Subtree(
- Subtree {
- delimiter: Some(Delimiter { id: TokenId(2), kind: DelimiterKind::Brace }),
- token_trees: vec![],
- }
- .into(),
- ));
+ subtree.token_trees.push(TokenTree::Subtree(Subtree {
+ delimiter: Some(Delimiter { id: TokenId(2), kind: DelimiterKind::Brace }),
+ token_trees: vec![],
+ }));
subtree
}
impl GlobalState {
pub(crate) fn show_message(&mut self, typ: lsp_types::MessageType, message: String) {
- let message = message.into();
+ let message = message;
self.send_notification::<lsp_types::notification::ShowMessage>(
lsp_types::ShowMessageParams { typ, message },
)
let params = call_info
.parameter_ranges()
.iter()
- .map(|it| [u32::from(it.start()).into(), u32::from(it.end()).into()])
+ .map(|it| [u32::from(it.start()), u32::from(it.end())])
.map(|label_offsets| lsp_types::ParameterInformation {
label: lsp_types::ParameterLabel::LabelOffsets(label_offsets),
documentation: None,
Some(t) => t,
None => return self.clone(),
};
- let position = InsertPosition::Before(r_curly.into());
+ let position = InsertPosition::Before(r_curly);
let arm_ws = tokens::WsBuilder::new(" ");
let match_indent = &leading_indent(self.syntax()).unwrap_or_default();
let match_ws = tokens::WsBuilder::new(&format!("\n{}", match_indent));
if right.kind() == T![;] || right.kind() == T![,] {
return None;
}
- Some(make::tokens::single_space().into())
+ Some(make::tokens::single_space())
}