clippy::useless_conversion
This commit is contained in:
parent
5a2dd7d4f3
commit
6d064295c8
@ -3475,7 +3475,7 @@ impl From<ForeignItemKind> for ItemKind {
|
|||||||
fn from(foreign_item_kind: ForeignItemKind) -> ItemKind {
|
fn from(foreign_item_kind: ForeignItemKind) -> ItemKind {
|
||||||
match foreign_item_kind {
|
match foreign_item_kind {
|
||||||
ForeignItemKind::Static(box static_foreign_item) => {
|
ForeignItemKind::Static(box static_foreign_item) => {
|
||||||
ItemKind::Static(Box::new(static_foreign_item.into()))
|
ItemKind::Static(Box::new(static_foreign_item))
|
||||||
}
|
}
|
||||||
ForeignItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind),
|
ForeignItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind),
|
||||||
ForeignItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
|
ForeignItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
|
||||||
@ -3489,9 +3489,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
|
|||||||
|
|
||||||
fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> {
|
fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> {
|
||||||
Ok(match item_kind {
|
Ok(match item_kind {
|
||||||
ItemKind::Static(box static_item) => {
|
ItemKind::Static(box static_item) => ForeignItemKind::Static(Box::new(static_item)),
|
||||||
ForeignItemKind::Static(Box::new(static_item.into()))
|
|
||||||
}
|
|
||||||
ItemKind::Fn(fn_kind) => ForeignItemKind::Fn(fn_kind),
|
ItemKind::Fn(fn_kind) => ForeignItemKind::Fn(fn_kind),
|
||||||
ItemKind::TyAlias(ty_alias_kind) => ForeignItemKind::TyAlias(ty_alias_kind),
|
ItemKind::TyAlias(ty_alias_kind) => ForeignItemKind::TyAlias(ty_alias_kind),
|
||||||
ItemKind::MacCall(a) => ForeignItemKind::MacCall(a),
|
ItemKind::MacCall(a) => ForeignItemKind::MacCall(a),
|
||||||
|
@ -75,12 +75,7 @@ fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
|
|||||||
|
|
||||||
// This can't use `init_stack_frame` since `body` is not a function,
|
// This can't use `init_stack_frame` since `body` is not a function,
|
||||||
// so computing its ABI would fail. It's also not worth it since there are no arguments to pass.
|
// so computing its ABI would fail. It's also not worth it since there are no arguments to pass.
|
||||||
ecx.push_stack_frame_raw(
|
ecx.push_stack_frame_raw(cid.instance, body, &ret, StackPopCleanup::Root { cleanup: false })?;
|
||||||
cid.instance,
|
|
||||||
body,
|
|
||||||
&ret.clone().into(),
|
|
||||||
StackPopCleanup::Root { cleanup: false },
|
|
||||||
)?;
|
|
||||||
ecx.storage_live_for_always_live_locals()?;
|
ecx.storage_live_for_always_live_locals()?;
|
||||||
|
|
||||||
// The main interpreter loop.
|
// The main interpreter loop.
|
||||||
|
@ -823,7 +823,7 @@ pub(super) fn init_drop_in_place_call(
|
|||||||
(Abi::Rust, fn_abi),
|
(Abi::Rust, fn_abi),
|
||||||
&[FnArg::Copy(arg.into())],
|
&[FnArg::Copy(arg.into())],
|
||||||
false,
|
false,
|
||||||
&ret.into(),
|
&ret,
|
||||||
Some(target),
|
Some(target),
|
||||||
unwind,
|
unwind,
|
||||||
)
|
)
|
||||||
|
@ -681,10 +681,10 @@ pub fn note_expected_found_extra(
|
|||||||
" ".repeat(expected_padding),
|
" ".repeat(expected_padding),
|
||||||
expected_label
|
expected_label
|
||||||
))];
|
))];
|
||||||
msg.extend(expected.0.into_iter());
|
msg.extend(expected.0);
|
||||||
msg.push(StringPart::normal(format!("`{expected_extra}\n")));
|
msg.push(StringPart::normal(format!("`{expected_extra}\n")));
|
||||||
msg.push(StringPart::normal(format!("{}{} `", " ".repeat(found_padding), found_label)));
|
msg.push(StringPart::normal(format!("{}{} `", " ".repeat(found_padding), found_label)));
|
||||||
msg.extend(found.0.into_iter());
|
msg.extend(found.0);
|
||||||
msg.push(StringPart::normal(format!("`{found_extra}")));
|
msg.push(StringPart::normal(format!("`{found_extra}")));
|
||||||
|
|
||||||
// For now, just attach these as notes.
|
// For now, just attach these as notes.
|
||||||
|
@ -1602,7 +1602,7 @@ fn check_fn_or_method<'tcx>(
|
|||||||
function: def_id,
|
function: def_id,
|
||||||
// Note that the `param_idx` of the output type is
|
// Note that the `param_idx` of the output type is
|
||||||
// one greater than the index of the last input type.
|
// one greater than the index of the last input type.
|
||||||
param_idx: idx.try_into().unwrap(),
|
param_idx: idx,
|
||||||
}),
|
}),
|
||||||
ty,
|
ty,
|
||||||
)
|
)
|
||||||
@ -1611,7 +1611,7 @@ fn check_fn_or_method<'tcx>(
|
|||||||
for (idx, ty) in sig.inputs_and_output.iter().enumerate() {
|
for (idx, ty) in sig.inputs_and_output.iter().enumerate() {
|
||||||
wfcx.register_wf_obligation(
|
wfcx.register_wf_obligation(
|
||||||
arg_span(idx),
|
arg_span(idx),
|
||||||
Some(WellFormedLoc::Param { function: def_id, param_idx: idx.try_into().unwrap() }),
|
Some(WellFormedLoc::Param { function: def_id, param_idx: idx }),
|
||||||
ty.into(),
|
ty.into(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2565,7 +2565,7 @@ fn label_generic_mismatches(
|
|||||||
other_generic_param.name.ident() == generic_param.name.ident()
|
other_generic_param.name.ident() == generic_param.name.ident()
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
idxs_matched.push(other_idx.into());
|
idxs_matched.push(other_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if idxs_matched.is_empty() {
|
if idxs_matched.is_empty() {
|
||||||
|
@ -396,7 +396,7 @@ pub fn eval_valtree(
|
|||||||
Ok((tcx.type_of(unevaluated.def).instantiate(tcx, unevaluated.args), c))
|
Ok((tcx.type_of(unevaluated.def).instantiate(tcx, unevaluated.args), c))
|
||||||
}
|
}
|
||||||
Ok(Err(bad_ty)) => Err(Either::Left(bad_ty)),
|
Ok(Err(bad_ty)) => Err(Either::Left(bad_ty)),
|
||||||
Err(err) => Err(Either::Right(err.into())),
|
Err(err) => Err(Either::Right(err)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ConstKind::Value(ty, val) => Ok((ty, val)),
|
ConstKind::Value(ty, val) => Ok((ty, val)),
|
||||||
|
@ -1526,7 +1526,7 @@ fn pretty_print_const_expr(
|
|||||||
|
|
||||||
let precedence = |binop: rustc_middle::mir::BinOp| {
|
let precedence = |binop: rustc_middle::mir::BinOp| {
|
||||||
use rustc_ast::util::parser::AssocOp;
|
use rustc_ast::util::parser::AssocOp;
|
||||||
AssocOp::from_ast_binop(binop.to_hir_binop().into()).precedence()
|
AssocOp::from_ast_binop(binop.to_hir_binop()).precedence()
|
||||||
};
|
};
|
||||||
let op_precedence = precedence(op);
|
let op_precedence = precedence(op);
|
||||||
let formatted_op = op.to_hir_binop().as_str();
|
let formatted_op = op.to_hir_binop().as_str();
|
||||||
|
@ -883,7 +883,6 @@ fn consider_builtin_upcast_to_principal(
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(a_data.principal_def_id().into_iter().flat_map(|principal_def_id| {
|
.chain(a_data.principal_def_id().into_iter().flat_map(|principal_def_id| {
|
||||||
elaborate::supertrait_def_ids(self.cx(), principal_def_id)
|
elaborate::supertrait_def_ids(self.cx(), principal_def_id)
|
||||||
.into_iter()
|
|
||||||
.filter(|def_id| self.cx().trait_is_auto(*def_id))
|
.filter(|def_id| self.cx().trait_is_auto(*def_id))
|
||||||
}))
|
}))
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -383,7 +383,7 @@ pub(super) fn collect_tokens<R: HasAttrs + HasTokens>(
|
|||||||
self.capture_state
|
self.capture_state
|
||||||
.parser_replacements
|
.parser_replacements
|
||||||
.drain(parser_replacements_start..parser_replacements_end)
|
.drain(parser_replacements_start..parser_replacements_end)
|
||||||
.chain(inner_attr_parser_replacements.into_iter())
|
.chain(inner_attr_parser_replacements)
|
||||||
.map(|(parser_range, data)| {
|
.map(|(parser_range, data)| {
|
||||||
(NodeRange::new(parser_range, collect_pos.start_pos), data)
|
(NodeRange::new(parser_range, collect_pos.start_pos), data)
|
||||||
})
|
})
|
||||||
|
@ -1588,7 +1588,7 @@ fn parse_enum_variant(&mut self, span: Span) -> PResult<'a, Option<Variant>> {
|
|||||||
(thin_vec![], Recovered::Yes(guar))
|
(thin_vec![], Recovered::Yes(guar))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
VariantData::Struct { fields, recovered: recovered.into() }
|
VariantData::Struct { fields, recovered }
|
||||||
} else if this.check(&token::OpenDelim(Delimiter::Parenthesis)) {
|
} else if this.check(&token::OpenDelim(Delimiter::Parenthesis)) {
|
||||||
let body = match this.parse_tuple_struct_body() {
|
let body = match this.parse_tuple_struct_body() {
|
||||||
Ok(body) => body,
|
Ok(body) => body,
|
||||||
@ -1672,7 +1672,7 @@ fn parse_item_struct(&mut self) -> PResult<'a, ItemInfo> {
|
|||||||
class_name.span,
|
class_name.span,
|
||||||
generics.where_clause.has_where_token,
|
generics.where_clause.has_where_token,
|
||||||
)?;
|
)?;
|
||||||
VariantData::Struct { fields, recovered: recovered.into() }
|
VariantData::Struct { fields, recovered }
|
||||||
}
|
}
|
||||||
// No `where` so: `struct Foo<T>;`
|
// No `where` so: `struct Foo<T>;`
|
||||||
} else if self.eat(&token::Semi) {
|
} else if self.eat(&token::Semi) {
|
||||||
@ -1684,7 +1684,7 @@ fn parse_item_struct(&mut self) -> PResult<'a, ItemInfo> {
|
|||||||
class_name.span,
|
class_name.span,
|
||||||
generics.where_clause.has_where_token,
|
generics.where_clause.has_where_token,
|
||||||
)?;
|
)?;
|
||||||
VariantData::Struct { fields, recovered: recovered.into() }
|
VariantData::Struct { fields, recovered }
|
||||||
// Tuple-style struct definition with optional where-clause.
|
// Tuple-style struct definition with optional where-clause.
|
||||||
} else if self.token == token::OpenDelim(Delimiter::Parenthesis) {
|
} else if self.token == token::OpenDelim(Delimiter::Parenthesis) {
|
||||||
let body = VariantData::Tuple(self.parse_tuple_struct_body()?, DUMMY_NODE_ID);
|
let body = VariantData::Tuple(self.parse_tuple_struct_body()?, DUMMY_NODE_ID);
|
||||||
@ -1713,14 +1713,14 @@ fn parse_item_union(&mut self) -> PResult<'a, ItemInfo> {
|
|||||||
class_name.span,
|
class_name.span,
|
||||||
generics.where_clause.has_where_token,
|
generics.where_clause.has_where_token,
|
||||||
)?;
|
)?;
|
||||||
VariantData::Struct { fields, recovered: recovered.into() }
|
VariantData::Struct { fields, recovered }
|
||||||
} else if self.token == token::OpenDelim(Delimiter::Brace) {
|
} else if self.token == token::OpenDelim(Delimiter::Brace) {
|
||||||
let (fields, recovered) = self.parse_record_struct_body(
|
let (fields, recovered) = self.parse_record_struct_body(
|
||||||
"union",
|
"union",
|
||||||
class_name.span,
|
class_name.span,
|
||||||
generics.where_clause.has_where_token,
|
generics.where_clause.has_where_token,
|
||||||
)?;
|
)?;
|
||||||
VariantData::Struct { fields, recovered: recovered.into() }
|
VariantData::Struct { fields, recovered }
|
||||||
} else {
|
} else {
|
||||||
let token_str = super::token_descr(&self.token);
|
let token_str = super::token_descr(&self.token);
|
||||||
let msg = format!("expected `where` or `{{` after union name, found {token_str}");
|
let msg = format!("expected `where` or `{{` after union name, found {token_str}");
|
||||||
|
@ -381,7 +381,7 @@ fn print_type(&mut self, ty: Ty<'tcx>) -> Result<(), PrintError> {
|
|||||||
let consts = [
|
let consts = [
|
||||||
start.unwrap_or(self.tcx.consts.unit),
|
start.unwrap_or(self.tcx.consts.unit),
|
||||||
end.unwrap_or(self.tcx.consts.unit),
|
end.unwrap_or(self.tcx.consts.unit),
|
||||||
ty::Const::from_bool(self.tcx, include_end).into(),
|
ty::Const::from_bool(self.tcx, include_end),
|
||||||
];
|
];
|
||||||
// HACK: Represent as tuple until we have something better.
|
// HACK: Represent as tuple until we have something better.
|
||||||
// HACK: constants are used in arrays, even if the types don't match.
|
// HACK: constants are used in arrays, even if the types don't match.
|
||||||
|
@ -408,7 +408,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>(
|
|||||||
debug!("opt_normalize_projection_type: found error");
|
debug!("opt_normalize_projection_type: found error");
|
||||||
let result = normalize_to_error(selcx, param_env, projection_term, cause, depth);
|
let result = normalize_to_error(selcx, param_env, projection_term, cause, depth);
|
||||||
obligations.extend(result.obligations);
|
obligations.extend(result.obligations);
|
||||||
return Ok(Some(result.value.into()));
|
return Ok(Some(result.value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>(
|
|||||||
}
|
}
|
||||||
let result = normalize_to_error(selcx, param_env, projection_term, cause, depth);
|
let result = normalize_to_error(selcx, param_env, projection_term, cause, depth);
|
||||||
obligations.extend(result.obligations);
|
obligations.extend(result.obligations);
|
||||||
Ok(Some(result.value.into()))
|
Ok(Some(result.value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user