Skip to content

Commit 4c44226

Browse files
committed
Use Into::into in operator ?
1 parent a9ec99f commit 4c44226

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/libcore/ops/try.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub trait Try {
3434
///
3535
/// If an `Err(e)` result is returned, the value `e` will be "wrapped"
3636
/// in the return type of the enclosing scope (which must itself implement
37-
/// `Try`). Specifically, the value `X::from_error(From::from(e))`
37+
/// `Try`). Specifically, the value `X::from_error(Into::into(e))`
3838
/// is returned, where `X` is the return type of the enclosing function.
3939
#[unstable(feature = "try_trait", issue = "42327")]
4040
fn into_result(self) -> Result<Self::Ok, Self::Error>;

src/librustc/hir/lowering.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -4755,9 +4755,9 @@ impl<'a> LoweringContext<'a> {
47554755
// Ok(val) => #[allow(unreachable_code)] val,
47564756
// Err(err) => #[allow(unreachable_code)]
47574757
// // If there is an enclosing `catch {...}`
4758-
// break 'catch_target Try::from_error(From::from(err)),
4758+
// break 'catch_target Try::from_error(Into::into(err)),
47594759
// // Otherwise
4760-
// return Try::from_error(From::from(err)),
4760+
// return Try::from_error(Into::into(err)),
47614761
// }
47624762

47634763
let unstable_span = self.sess.source_map().mark_span_with_reason(
@@ -4818,17 +4818,17 @@ impl<'a> LoweringContext<'a> {
48184818
};
48194819

48204820
// `Err(err) => #[allow(unreachable_code)]
4821-
// return Try::from_error(From::from(err)),`
4821+
// return Try::from_error(Into::into(err)),`
48224822
let err_arm = {
48234823
let err_ident = self.str_to_ident("err");
48244824
let (err_local, err_local_nid) = self.pat_ident(try_span, err_ident);
4825-
let from_expr = {
4826-
let from_path = &[sym::convert, sym::From, sym::from];
4825+
let into_expr = {
4826+
let into_path = &[sym::convert, sym::Into, sym::into];
48274827
let err_expr = self.expr_ident(try_span, err_ident, err_local_nid);
4828-
self.expr_call_std_path(try_span, from_path, hir_vec![err_expr])
4828+
self.expr_call_std_path(try_span, into_path, hir_vec![err_expr])
48294829
};
48304830
let from_err_expr =
4831-
self.wrap_in_try_constructor(sym::from_error, from_expr, unstable_span);
4831+
self.wrap_in_try_constructor(sym::from_error, into_expr, unstable_span);
48324832
let thin_attrs = ThinVec::from(attrs);
48334833
let catch_scope = self.catch_scopes.last().map(|x| *x);
48344834
let ret_expr = if let Some(catch_node) = catch_scope {

src/libsyntax_pos/symbol.rs

+2
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ symbols! {
287287
infer_static_outlives_requirements,
288288
inline,
289289
intel,
290+
into,
291+
Into,
290292
into_iter,
291293
IntoIterator,
292294
into_result,

0 commit comments

Comments
 (0)