From 1b09dc2596c88dcf3fb840046f05db5e8595e9ca Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 16 Jan 2021 11:34:22 +0100 Subject: [PATCH 01/17] PlaceRef::ty: use method call syntax --- compiler/rustc_codegen_ssa/src/mir/analyze.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/place.rs | 2 +- .../src/borrow_check/diagnostics/conflict_errors.rs | 4 +++- compiler/rustc_mir/src/borrow_check/mod.rs | 8 ++++---- compiler/rustc_mir/src/borrow_check/prefixes.rs | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/mir/analyze.rs b/compiler/rustc_codegen_ssa/src/mir/analyze.rs index b1e372afc6501..fd0ff5b66e607 100644 --- a/compiler/rustc_codegen_ssa/src/mir/analyze.rs +++ b/compiler/rustc_codegen_ssa/src/mir/analyze.rs @@ -119,7 +119,7 @@ impl> LocalAnalyzer<'mir, 'a, 'tcx, Bx> { ) ); if is_consume { - let base_ty = mir::PlaceRef::ty(&place_base, self.fx.mir, cx.tcx()); + let base_ty = place_base.ty(self.fx.mir, cx.tcx()); let base_ty = self.fx.monomorphize(base_ty); // ZSTs don't require any actual memory access. diff --git a/compiler/rustc_codegen_ssa/src/mir/place.rs b/compiler/rustc_codegen_ssa/src/mir/place.rs index 958e4ebd078b6..66d9d1a1e0c49 100644 --- a/compiler/rustc_codegen_ssa/src/mir/place.rs +++ b/compiler/rustc_codegen_ssa/src/mir/place.rs @@ -506,7 +506,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'tcx>) -> Ty<'tcx> { let tcx = self.cx.tcx(); - let place_ty = mir::PlaceRef::ty(&place_ref, self.mir, tcx); + let place_ty = place_ref.ty(self.mir, tcx); self.monomorphize(place_ty.ty) } } diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs index db02ee67910b2..727514b500755 100644 --- a/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs +++ b/compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs @@ -287,7 +287,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ); } - let ty = PlaceRef::ty(&used_place, self.body, self.infcx.tcx).ty; + let ty = used_place.ty(self.body, self.infcx.tcx).ty; let needs_note = match ty.kind() { ty::Closure(id, _) => { let tables = self.infcx.tcx.typeck(id.expect_local()); @@ -725,6 +725,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Define a small closure that we can use to check if the type of a place // is a union. let union_ty = |place_base| { + // Need to use fn call syntax `PlaceRef::ty` to determine the type of `place_base`; + // using a type annotation in the closure argument instead leads to a lifetime error. let ty = PlaceRef::ty(&place_base, self.body, self.infcx.tcx).ty; ty.ty_adt_def().filter(|adt| adt.is_union()).map(|_| ty) }; diff --git a/compiler/rustc_mir/src/borrow_check/mod.rs b/compiler/rustc_mir/src/borrow_check/mod.rs index 006e05072a7a9..7c7edfdb5fbaf 100644 --- a/compiler/rustc_mir/src/borrow_check/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/mod.rs @@ -1743,7 +1743,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { if let Some((place_base, ProjectionElem::Subslice { from, to, from_end: false })) = place_span.0.last_projection() { - let place_ty = PlaceRef::ty(&place_base, self.body(), self.infcx.tcx); + let place_ty = place_base.ty(self.body(), self.infcx.tcx); if let ty::Array(..) = place_ty.ty.kind() { self.check_if_subslice_element_is_moved( location, @@ -1854,7 +1854,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // assigning to `P.f` requires `P` itself // be already initialized let tcx = self.infcx.tcx; - let base_ty = PlaceRef::ty(&place_base, self.body(), tcx).ty; + let base_ty = place_base.ty(self.body(), tcx).ty; match base_ty.kind() { ty::Adt(def, _) if def.has_dtor(tcx) => { self.check_if_path_or_subpath_is_moved( @@ -1951,7 +1951,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // no move out from an earlier location) then this is an attempt at initialization // of the union - we should error in that case. let tcx = this.infcx.tcx; - if let ty::Adt(def, _) = PlaceRef::ty(&base, this.body(), tcx).ty.kind() { + if let ty::Adt(def, _) = base.ty(this.body(), tcx).ty.kind() { if def.is_union() { if this.move_data.path_map[mpi].iter().any(|moi| { this.move_data.moves[*moi].source.is_predecessor_of(location, this.body) @@ -2173,7 +2173,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { Some((place_base, elem)) => { match elem { ProjectionElem::Deref => { - let base_ty = PlaceRef::ty(&place_base, self.body(), self.infcx.tcx).ty; + let base_ty = place_base.ty(self.body(), self.infcx.tcx).ty; // Check the kind of deref to decide match base_ty.kind() { diff --git a/compiler/rustc_mir/src/borrow_check/prefixes.rs b/compiler/rustc_mir/src/borrow_check/prefixes.rs index cf04c55eb68c5..bdf2becb71126 100644 --- a/compiler/rustc_mir/src/borrow_check/prefixes.rs +++ b/compiler/rustc_mir/src/borrow_check/prefixes.rs @@ -117,7 +117,7 @@ impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> { // derefs, except we stop at the deref of a shared // reference. - let ty = PlaceRef::ty(&cursor_base, self.body, self.tcx).ty; + let ty = cursor_base.ty(self.body, self.tcx).ty; match ty.kind() { ty::RawPtr(_) | ty::Ref(_ /*rgn*/, _ /*ty*/, hir::Mutability::Not) => { // don't continue traversing over derefs of raw pointers or shared From ae3a5153377f2271ba7dfe686a9b5bca1632c32b Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Mon, 18 Jan 2021 17:56:06 +0100 Subject: [PATCH 02/17] Avoid hash_slice in VecDeque's Hash implementation Fixes #80303. --- .../alloc/src/collections/vec_deque/mod.rs | 10 +++-- .../alloc/src/collections/vec_deque/tests.rs | 40 +++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 5b61e8911a59a..6f9133e2811bf 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -2646,9 +2646,13 @@ impl Ord for VecDeque { impl Hash for VecDeque { fn hash(&self, state: &mut H) { self.len().hash(state); - let (a, b) = self.as_slices(); - Hash::hash_slice(a, state); - Hash::hash_slice(b, state); + // It's not possible to use Hash::hash_slice on slices + // returned by as_slices method as their length can vary + // in otherwise identical deques. + // + // Hasher only guarantees equivalence for the exact same + // set of calls to its methods. + self.iter().for_each(|elem| elem.hash(state)); } } diff --git a/library/alloc/src/collections/vec_deque/tests.rs b/library/alloc/src/collections/vec_deque/tests.rs index 27dc59ae64411..87e06fa394d38 100644 --- a/library/alloc/src/collections/vec_deque/tests.rs +++ b/library/alloc/src/collections/vec_deque/tests.rs @@ -599,3 +599,43 @@ fn issue_53529() { assert_eq!(*a, 2); } } + +#[test] +fn issue_80303() { + use core::iter; + use core::num::Wrapping; + + // This is a valid, albeit rather bad hash function implementation. + struct SimpleHasher(Wrapping); + + impl Hasher for SimpleHasher { + fn finish(&self) -> u64 { + self.0.0 + } + + fn write(&mut self, bytes: &[u8]) { + // This particular implementation hashes value 24 in addition to bytes. + // Such an implementation is valid as Hasher only guarantees equivalence + // for the exact same set of calls to its methods. + for &v in iter::once(&24).chain(bytes) { + self.0 = Wrapping(31) * self.0 + Wrapping(u64::from(v)); + } + } + } + + fn hash_code(value: impl Hash) -> u64 { + let mut hasher = SimpleHasher(Wrapping(1)); + value.hash(&mut hasher); + hasher.finish() + } + + // This creates two deques for which values returned by as_slices + // method differ. + let vda: VecDeque = (0..10).collect(); + let mut vdb = VecDeque::with_capacity(10); + vdb.extend(5..10); + (0..5).rev().for_each(|elem| vdb.push_front(elem)); + assert_ne!(vda.as_slices(), vdb.as_slices()); + assert_eq!(vda, vdb); + assert_eq!(hash_code(vda), hash_code(vdb)); +} From 453ebbdb8b62660a50acf24aa70334df71c0ab5b Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 21 Jan 2021 10:16:42 -0800 Subject: [PATCH 03/17] Update cargo --- Cargo.lock | 1 + src/tools/cargo | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index b2ae22b6abd9b..afcff1bfb0607 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -427,6 +427,7 @@ dependencies = [ "remove_dir_all", "serde_json", "tar", + "toml", "url 2.1.1", ] diff --git a/src/tools/cargo b/src/tools/cargo index a73e5b7d567c3..783bc43c660bf 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit a73e5b7d567c3036b296fc6b33ed52c5edcd882e +Subproject commit 783bc43c660bf39c1e562c8c429b32078ad3099b From e3faeb486a962d19e1f533a206511b669aced988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Thu, 21 Jan 2021 20:10:40 +0300 Subject: [PATCH 04/17] mir: Improve size_of handling when arg is unsized --- .../rustc_middle/src/mir/interpret/error.rs | 3 ++ compiler/rustc_mir/src/interpret/step.rs | 1 + src/test/ui/mir/issue-80742.stderr | 34 +++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index 397d2ffd565b1..cf931ece712b0 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -127,6 +127,8 @@ pub enum InvalidProgramInfo<'tcx> { Layout(layout::LayoutError<'tcx>), /// An invalid transmute happened. TransmuteSizeDiff(Ty<'tcx>, Ty<'tcx>), + /// SizeOf of unsized type was requested. + SizeOfUnsizedType(Ty<'tcx>), } impl fmt::Display for InvalidProgramInfo<'_> { @@ -144,6 +146,7 @@ impl fmt::Display for InvalidProgramInfo<'_> { "transmuting `{}` to `{}` is not possible, because these types do not have the same size", from_ty, to_ty ), + SizeOfUnsizedType(ty) => write!(f, "size_of called on unsized type `{}`", ty), } } } diff --git a/compiler/rustc_mir/src/interpret/step.rs b/compiler/rustc_mir/src/interpret/step.rs index 6d447acbecf34..fbc72ad8adc96 100644 --- a/compiler/rustc_mir/src/interpret/step.rs +++ b/compiler/rustc_mir/src/interpret/step.rs @@ -270,6 +270,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { self.frame().current_span(), &format!("SizeOf nullary MIR operator called for unsized type {}", ty), ); + throw_inval!(SizeOfUnsizedType(ty)); } self.write_scalar(Scalar::from_machine_usize(layout.size.bytes(), self), dest)?; } diff --git a/src/test/ui/mir/issue-80742.stderr b/src/test/ui/mir/issue-80742.stderr index 2ec0e9505288b..26f9c786ba13b 100644 --- a/src/test/ui/mir/issue-80742.stderr +++ b/src/test/ui/mir/issue-80742.stderr @@ -1,3 +1,17 @@ +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + | +LL | intrinsics::size_of::() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | size_of called on unsized type `dyn Debug` + | inside `std::mem::size_of::` at $SRC_DIR/core/src/mem/mod.rs:LL:COL + | + ::: $DIR/issue-80742.rs:23:10 + | +LL | [u8; size_of::() + 1]: , + | -------------- inside `Inline::::{constant#0}` at $DIR/issue-80742.rs:23:10 + error[E0599]: no function or associated item named `new` found for struct `Inline` in the current scope --> $DIR/issue-80742.rs:31:36 | @@ -21,6 +35,20 @@ LL | pub trait Debug { = note: the method `new` exists but the following trait bounds were not satisfied: `dyn Debug: Sized` +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + | +LL | intrinsics::size_of::() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | size_of called on unsized type `dyn Debug` + | inside `std::mem::size_of::` at $SRC_DIR/core/src/mem/mod.rs:LL:COL + | + ::: $DIR/issue-80742.rs:15:10 + | +LL | [u8; size_of::() + 1]: , + | -------------- inside `Inline::::{constant#0}` at $DIR/issue-80742.rs:15:10 + error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time --> $DIR/issue-80742.rs:31:15 | @@ -36,7 +64,7 @@ help: consider relaxing the implicit `Sized` restriction LL | struct Inline | ^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0277, E0599. -For more information about an error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0080, E0277, E0599. +For more information about an error, try `rustc --explain E0080`. From 3f42abec58ab05d37689f33efdfa6382eb4b1e1a Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Thu, 21 Jan 2021 22:09:15 +0100 Subject: [PATCH 05/17] Lower closure prototype after its body. --- compiler/rustc_ast_lowering/src/expr.rs | 31 +++++++------ src/test/ui/closures/local-type-mix.rs | 17 ++++++++ src/test/ui/closures/local-type-mix.stderr | 51 ++++++++++++++++++++++ 3 files changed, 86 insertions(+), 13 deletions(-) create mode 100644 src/test/ui/closures/local-type-mix.rs create mode 100644 src/test/ui/closures/local-type-mix.stderr diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 1b9ccbd850bee..2470a8791e16e 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -770,10 +770,7 @@ impl<'hir> LoweringContext<'_, 'hir> { body: &Expr, fn_decl_span: Span, ) -> hir::ExprKind<'hir> { - // Lower outside new scope to preserve `is_in_loop_condition`. - let fn_decl = self.lower_fn_decl(decl, None, false, None); - - self.with_new_scopes(move |this| { + let (body_id, generator_option) = self.with_new_scopes(move |this| { let prev = this.current_item; this.current_item = Some(fn_decl_span); let mut generator_kind = None; @@ -785,8 +782,13 @@ impl<'hir> LoweringContext<'_, 'hir> { let generator_option = this.generator_movability_for_fn(&decl, fn_decl_span, generator_kind, movability); this.current_item = prev; - hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, generator_option) - }) + (body_id, generator_option) + }); + + // Lower outside new scope to preserve `is_in_loop_condition`. + let fn_decl = self.lower_fn_decl(decl, None, false, None); + + hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, generator_option) } fn generator_movability_for_fn( @@ -832,12 +834,8 @@ impl<'hir> LoweringContext<'_, 'hir> { ) -> hir::ExprKind<'hir> { let outer_decl = FnDecl { inputs: decl.inputs.clone(), output: FnRetTy::Default(fn_decl_span) }; - // We need to lower the declaration outside the new scope, because we - // have to conserve the state of being inside a loop condition for the - // closure argument types. - let fn_decl = self.lower_fn_decl(&outer_decl, None, false, None); - self.with_new_scopes(move |this| { + let body_id = self.with_new_scopes(|this| { // FIXME(cramertj): allow `async` non-`move` closures with arguments. if capture_clause == CaptureBy::Ref && !decl.inputs.is_empty() { struct_span_err!( @@ -868,8 +866,15 @@ impl<'hir> LoweringContext<'_, 'hir> { ); this.expr(fn_decl_span, async_body, ThinVec::new()) }); - hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, None) - }) + body_id + }); + + // We need to lower the declaration outside the new scope, because we + // have to conserve the state of being inside a loop condition for the + // closure argument types. + let fn_decl = self.lower_fn_decl(&outer_decl, None, false, None); + + hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, None) } /// Destructure the LHS of complex assignments. diff --git a/src/test/ui/closures/local-type-mix.rs b/src/test/ui/closures/local-type-mix.rs new file mode 100644 index 0000000000000..006e6f490f06b --- /dev/null +++ b/src/test/ui/closures/local-type-mix.rs @@ -0,0 +1,17 @@ +// Check that using the parameter name in its type does not ICE. +// edition:2018 + +#![feature(async_closure)] + +fn main() { + let _ = |x: x| x; //~ ERROR expected type + let _ = |x: bool| -> x { x }; //~ ERROR expected type + let _ = async move |x: x| x; //~ ERROR expected type + let _ = async move |x: bool| -> x { x }; //~ ERROR expected type +} + +fn foo(x: x) {} //~ ERROR expected type +fn foo_ret(x: bool) -> x {} //~ ERROR expected type + +async fn async_foo(x: x) {} //~ ERROR expected type +async fn async_foo_ret(x: bool) -> x {} //~ ERROR expected type diff --git a/src/test/ui/closures/local-type-mix.stderr b/src/test/ui/closures/local-type-mix.stderr new file mode 100644 index 0000000000000..68c320a065d57 --- /dev/null +++ b/src/test/ui/closures/local-type-mix.stderr @@ -0,0 +1,51 @@ +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:7:17 + | +LL | let _ = |x: x| x; + | ^ not a type + +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:8:26 + | +LL | let _ = |x: bool| -> x { x }; + | ^ not a type + +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:9:28 + | +LL | let _ = async move |x: x| x; + | ^ not a type + +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:10:37 + | +LL | let _ = async move |x: bool| -> x { x }; + | ^ not a type + +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:13:11 + | +LL | fn foo(x: x) {} + | ^ not a type + +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:14:24 + | +LL | fn foo_ret(x: bool) -> x {} + | ^ not a type + +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:16:23 + | +LL | async fn async_foo(x: x) {} + | ^ not a type + +error[E0573]: expected type, found local variable `x` + --> $DIR/local-type-mix.rs:17:36 + | +LL | async fn async_foo_ret(x: bool) -> x {} + | ^ not a type + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0573`. From 5f74ab49694a8622afd44c24021b44239573402d Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 21 Jan 2021 17:57:46 -0500 Subject: [PATCH 06/17] Add more self-profile info to rustc_resolve --- compiler/rustc_resolve/src/lib.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index d293899dc0c6f..2b4a1d9e3fa0a 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1465,16 +1465,14 @@ impl<'a> Resolver<'a> { /// Entry point to crate resolution. pub fn resolve_crate(&mut self, krate: &Crate) { - let _prof_timer = self.session.prof.generic_activity("resolve_crate"); - - ImportResolver { r: self }.finalize_imports(); - self.finalize_macro_resolutions(); - - self.late_resolve_crate(krate); - - self.check_unused(krate); - self.report_errors(krate); - self.crate_loader.postprocess(krate); + self.session.time("resolve_crate", || { + self.session.time("finalize_imports", || ImportResolver { r: self }.finalize_imports()); + self.session.time("finalize_macro_resolutions", || self.finalize_macro_resolutions()); + self.session.time("late_resolve_crate", || self.late_resolve_crate(krate)); + self.session.time("resolve_check_unused", || self.check_unused(krate)); + self.session.time("resolve_report_errors", || self.report_errors(krate)); + self.session.time("resolve_postprocess", || self.crate_loader.postprocess(krate)); + }); } pub fn traits_in_scope( From 9880560a1cb64ec099886eb11ce3d34de8070bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20du=20Garreau?= Date: Fri, 22 Jan 2021 18:46:00 +0100 Subject: [PATCH 07/17] Inline methods of Path and OsString --- library/std/src/ffi/os_str.rs | 34 +++++++++++++++++ library/std/src/path.rs | 69 +++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 2eef4d58507c0..32f0f8a52f820 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -111,6 +111,7 @@ impl OsString { /// let os_string = OsString::new(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn new() -> OsString { OsString { inner: Buf::from_string(String::new()) } } @@ -127,6 +128,7 @@ impl OsString { /// assert_eq!(os_string.as_os_str(), os_str); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn as_os_str(&self) -> &OsStr { self } @@ -145,6 +147,7 @@ impl OsString { /// assert_eq!(string, Ok(String::from("foo"))); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn into_string(self) -> Result { self.inner.into_string().map_err(|buf| OsString { inner: buf }) } @@ -163,6 +166,7 @@ impl OsString { /// assert_eq!(&os_string, "foobar"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn push>(&mut self, s: T) { self.inner.push_slice(&s.as_ref().inner) } @@ -189,6 +193,7 @@ impl OsString { /// assert_eq!(capacity, os_string.capacity()); /// ``` #[stable(feature = "osstring_simple_functions", since = "1.9.0")] + #[inline] pub fn with_capacity(capacity: usize) -> OsString { OsString { inner: Buf::with_capacity(capacity) } } @@ -207,6 +212,7 @@ impl OsString { /// assert_eq!(&os_string, ""); /// ``` #[stable(feature = "osstring_simple_functions", since = "1.9.0")] + #[inline] pub fn clear(&mut self) { self.inner.clear() } @@ -224,6 +230,7 @@ impl OsString { /// assert!(os_string.capacity() >= 10); /// ``` #[stable(feature = "osstring_simple_functions", since = "1.9.0")] + #[inline] pub fn capacity(&self) -> usize { self.inner.capacity() } @@ -243,6 +250,7 @@ impl OsString { /// assert!(s.capacity() >= 10); /// ``` #[stable(feature = "osstring_simple_functions", since = "1.9.0")] + #[inline] pub fn reserve(&mut self, additional: usize) { self.inner.reserve(additional) } @@ -265,6 +273,7 @@ impl OsString { /// assert!(s.capacity() >= 10); /// ``` #[stable(feature = "osstring_simple_functions", since = "1.9.0")] + #[inline] pub fn reserve_exact(&mut self, additional: usize) { self.inner.reserve_exact(additional) } @@ -285,6 +294,7 @@ impl OsString { /// assert_eq!(3, s.capacity()); /// ``` #[stable(feature = "osstring_shrink_to_fit", since = "1.19.0")] + #[inline] pub fn shrink_to_fit(&mut self) { self.inner.shrink_to_fit() } @@ -342,6 +352,7 @@ impl From for OsString { /// Converts a [`String`] into a [`OsString`]. /// /// The conversion copies the data, and includes an allocation on the heap. + #[inline] fn from(s: String) -> OsString { OsString { inner: Buf::from_string(s) } } @@ -408,6 +419,7 @@ impl fmt::Debug for OsString { #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq for OsString { + #[inline] fn eq(&self, other: &OsString) -> bool { &**self == &**other } @@ -415,6 +427,7 @@ impl PartialEq for OsString { #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq for OsString { + #[inline] fn eq(&self, other: &str) -> bool { &**self == other } @@ -422,6 +435,7 @@ impl PartialEq for OsString { #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq for str { + #[inline] fn eq(&self, other: &OsString) -> bool { &**other == self } @@ -429,6 +443,7 @@ impl PartialEq for str { #[stable(feature = "os_str_str_ref_eq", since = "1.29.0")] impl PartialEq<&str> for OsString { + #[inline] fn eq(&self, other: &&str) -> bool { **self == **other } @@ -436,6 +451,7 @@ impl PartialEq<&str> for OsString { #[stable(feature = "os_str_str_ref_eq", since = "1.29.0")] impl<'a> PartialEq for &'a str { + #[inline] fn eq(&self, other: &OsString) -> bool { **other == **self } @@ -539,6 +555,7 @@ impl OsStr { /// assert_eq!(os_str.to_str(), Some("foo")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn to_str(&self) -> Option<&str> { self.inner.to_str() } @@ -589,6 +606,7 @@ impl OsStr { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn to_string_lossy(&self) -> Cow<'_, str> { self.inner.to_string_lossy() } @@ -605,6 +623,7 @@ impl OsStr { /// assert_eq!(os_string, OsString::from("foo")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn to_os_string(&self) -> OsString { OsString { inner: self.inner.to_owned() } } @@ -655,6 +674,7 @@ impl OsStr { /// ``` #[doc(alias = "length")] #[stable(feature = "osstring_simple_functions", since = "1.9.0")] + #[inline] pub fn len(&self) -> usize { self.inner.inner.len() } @@ -696,6 +716,7 @@ impl OsStr { /// assert_eq!("grÜße, jÜrgen ❤", s); /// ``` #[unstable(feature = "osstring_ascii", issue = "70516")] + #[inline] pub fn make_ascii_lowercase(&mut self) { self.inner.make_ascii_lowercase() } @@ -721,6 +742,7 @@ impl OsStr { /// assert_eq!("GRüßE, JüRGEN ❤", s); /// ``` #[unstable(feature = "osstring_ascii", issue = "70516")] + #[inline] pub fn make_ascii_uppercase(&mut self) { self.inner.make_ascii_uppercase() } @@ -784,6 +806,7 @@ impl OsStr { /// assert!(!non_ascii.is_ascii()); /// ``` #[unstable(feature = "osstring_ascii", issue = "70516")] + #[inline] pub fn is_ascii(&self) -> bool { self.inner.is_ascii() } @@ -811,6 +834,7 @@ impl OsStr { #[stable(feature = "box_from_os_str", since = "1.17.0")] impl From<&OsStr> for Box { + #[inline] fn from(s: &OsStr) -> Box { let rw = Box::into_raw(s.inner.into_box()) as *mut OsStr; unsafe { Box::from_raw(rw) } @@ -832,6 +856,7 @@ impl From> for Box { impl From> for OsString { /// Converts a [`Box`]`<`[`OsStr`]`>` into a `OsString` without copying or /// allocating. + #[inline] fn from(boxed: Box) -> OsString { boxed.into_os_string() } @@ -840,6 +865,7 @@ impl From> for OsString { #[stable(feature = "box_from_os_string", since = "1.20.0")] impl From for Box { /// Converts a [`OsString`] into a [`Box`]`` without copying or allocating. + #[inline] fn from(s: OsString) -> Box { s.into_boxed_os_str() } @@ -925,6 +951,7 @@ impl<'a> From> for OsString { #[stable(feature = "box_default_extra", since = "1.17.0")] impl Default for Box { + #[inline] fn default() -> Box { let rw = Box::into_raw(Slice::empty_box()) as *mut OsStr; unsafe { Box::from_raw(rw) } @@ -1075,6 +1102,7 @@ impl OsStr { #[stable(feature = "rust1", since = "1.0.0")] impl Borrow for OsString { + #[inline] fn borrow(&self) -> &OsStr { &self[..] } @@ -1083,9 +1111,11 @@ impl Borrow for OsString { #[stable(feature = "rust1", since = "1.0.0")] impl ToOwned for OsStr { type Owned = OsString; + #[inline] fn to_owned(&self) -> OsString { self.to_os_string() } + #[inline] fn clone_into(&self, target: &mut OsString) { self.inner.clone_into(&mut target.inner) } @@ -1093,6 +1123,7 @@ impl ToOwned for OsStr { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for OsStr { + #[inline] fn as_ref(&self) -> &OsStr { self } @@ -1123,12 +1154,14 @@ impl AsRef for String { } impl FromInner for OsString { + #[inline] fn from_inner(buf: Buf) -> OsString { OsString { inner: buf } } } impl IntoInner for OsString { + #[inline] fn into_inner(self) -> Buf { self.inner } @@ -1145,6 +1178,7 @@ impl AsInner for OsStr { impl FromStr for OsString { type Err = core::convert::Infallible; + #[inline] fn from_str(s: &str) -> Result { Ok(OsString::from(s)) } diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 243761e389784..1889e54933867 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -401,12 +401,14 @@ impl<'a> PrefixComponent<'a> { /// See [`Prefix`]'s documentation for more information on the different /// kinds of prefixes. #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn kind(&self) -> Prefix<'a> { self.parsed } /// Returns the raw [`OsStr`] slice for this prefix. #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn as_os_str(&self) -> &'a OsStr { self.raw } @@ -414,6 +416,7 @@ impl<'a> PrefixComponent<'a> { #[stable(feature = "rust1", since = "1.0.0")] impl<'a> cmp::PartialEq for PrefixComponent<'a> { + #[inline] fn eq(&self, other: &PrefixComponent<'a>) -> bool { cmp::PartialEq::eq(&self.parsed, &other.parsed) } @@ -421,6 +424,7 @@ impl<'a> cmp::PartialEq for PrefixComponent<'a> { #[stable(feature = "rust1", since = "1.0.0")] impl<'a> cmp::PartialOrd for PrefixComponent<'a> { + #[inline] fn partial_cmp(&self, other: &PrefixComponent<'a>) -> Option { cmp::PartialOrd::partial_cmp(&self.parsed, &other.parsed) } @@ -428,6 +432,7 @@ impl<'a> cmp::PartialOrd for PrefixComponent<'a> { #[stable(feature = "rust1", since = "1.0.0")] impl cmp::Ord for PrefixComponent<'_> { + #[inline] fn cmp(&self, other: &Self) -> cmp::Ordering { cmp::Ord::cmp(&self.parsed, &other.parsed) } @@ -522,6 +527,7 @@ impl<'a> Component<'a> { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for Component<'_> { + #[inline] fn as_ref(&self) -> &OsStr { self.as_os_str() } @@ -529,6 +535,7 @@ impl AsRef for Component<'_> { #[stable(feature = "path_component_asref", since = "1.25.0")] impl AsRef for Component<'_> { + #[inline] fn as_ref(&self) -> &Path { self.as_os_str().as_ref() } @@ -750,6 +757,7 @@ impl<'a> Components<'a> { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for Components<'_> { + #[inline] fn as_ref(&self) -> &Path { self.as_path() } @@ -757,6 +765,7 @@ impl AsRef for Components<'_> { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for Components<'_> { + #[inline] fn as_ref(&self) -> &OsStr { self.as_path().as_os_str() } @@ -792,6 +801,7 @@ impl<'a> Iter<'a> { /// assert_eq!(Path::new("foo/bar.txt"), iter.as_path()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn as_path(&self) -> &'a Path { self.inner.as_path() } @@ -799,6 +809,7 @@ impl<'a> Iter<'a> { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for Iter<'_> { + #[inline] fn as_ref(&self) -> &Path { self.as_path() } @@ -806,6 +817,7 @@ impl AsRef for Iter<'_> { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for Iter<'_> { + #[inline] fn as_ref(&self) -> &OsStr { self.as_path().as_os_str() } @@ -815,6 +827,7 @@ impl AsRef for Iter<'_> { impl<'a> Iterator for Iter<'a> { type Item = &'a OsStr; + #[inline] fn next(&mut self) -> Option<&'a OsStr> { self.inner.next().map(Component::as_os_str) } @@ -822,6 +835,7 @@ impl<'a> Iterator for Iter<'a> { #[stable(feature = "rust1", since = "1.0.0")] impl<'a> DoubleEndedIterator for Iter<'a> { + #[inline] fn next_back(&mut self) -> Option<&'a OsStr> { self.inner.next_back().map(Component::as_os_str) } @@ -935,6 +949,7 @@ impl FusedIterator for Components<'_> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a> cmp::PartialEq for Components<'a> { + #[inline] fn eq(&self, other: &Components<'a>) -> bool { Iterator::eq(self.clone(), other.clone()) } @@ -945,6 +960,7 @@ impl cmp::Eq for Components<'_> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a> cmp::PartialOrd for Components<'a> { + #[inline] fn partial_cmp(&self, other: &Components<'a>) -> Option { Iterator::partial_cmp(self.clone(), other.clone()) } @@ -952,6 +968,7 @@ impl<'a> cmp::PartialOrd for Components<'a> { #[stable(feature = "rust1", since = "1.0.0")] impl cmp::Ord for Components<'_> { + #[inline] fn cmp(&self, other: &Self) -> cmp::Ordering { Iterator::cmp(self.clone(), other.clone()) } @@ -985,6 +1002,7 @@ pub struct Ancestors<'a> { impl<'a> Iterator for Ancestors<'a> { type Item = &'a Path; + #[inline] fn next(&mut self) -> Option { let next = self.next; self.next = next.and_then(Path::parent); @@ -1060,6 +1078,7 @@ pub struct PathBuf { } impl PathBuf { + #[inline] fn as_mut_vec(&mut self) -> &mut Vec { unsafe { &mut *(self as *mut PathBuf as *mut Vec) } } @@ -1074,6 +1093,7 @@ impl PathBuf { /// let path = PathBuf::new(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn new() -> PathBuf { PathBuf { inner: OsString::new() } } @@ -1097,6 +1117,7 @@ impl PathBuf { /// /// [`with_capacity`]: OsString::with_capacity #[stable(feature = "path_buf_capacity", since = "1.44.0")] + #[inline] pub fn with_capacity(capacity: usize) -> PathBuf { PathBuf { inner: OsString::with_capacity(capacity) } } @@ -1112,6 +1133,7 @@ impl PathBuf { /// assert_eq!(Path::new("/test"), p.as_path()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn as_path(&self) -> &Path { self } @@ -1315,12 +1337,14 @@ impl PathBuf { /// let os_str = p.into_os_string(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn into_os_string(self) -> OsString { self.inner } /// Converts this `PathBuf` into a [boxed](Box) [`Path`]. #[stable(feature = "into_boxed_path", since = "1.20.0")] + #[inline] pub fn into_boxed_path(self) -> Box { let rw = Box::into_raw(self.inner.into_boxed_os_str()) as *mut Path; unsafe { Box::from_raw(rw) } @@ -1330,6 +1354,7 @@ impl PathBuf { /// /// [`capacity`]: OsString::capacity #[stable(feature = "path_buf_capacity", since = "1.44.0")] + #[inline] pub fn capacity(&self) -> usize { self.inner.capacity() } @@ -1338,6 +1363,7 @@ impl PathBuf { /// /// [`clear`]: OsString::clear #[stable(feature = "path_buf_capacity", since = "1.44.0")] + #[inline] pub fn clear(&mut self) { self.inner.clear() } @@ -1346,6 +1372,7 @@ impl PathBuf { /// /// [`reserve`]: OsString::reserve #[stable(feature = "path_buf_capacity", since = "1.44.0")] + #[inline] pub fn reserve(&mut self, additional: usize) { self.inner.reserve(additional) } @@ -1354,6 +1381,7 @@ impl PathBuf { /// /// [`reserve_exact`]: OsString::reserve_exact #[stable(feature = "path_buf_capacity", since = "1.44.0")] + #[inline] pub fn reserve_exact(&mut self, additional: usize) { self.inner.reserve_exact(additional) } @@ -1362,6 +1390,7 @@ impl PathBuf { /// /// [`shrink_to_fit`]: OsString::shrink_to_fit #[stable(feature = "path_buf_capacity", since = "1.44.0")] + #[inline] pub fn shrink_to_fit(&mut self) { self.inner.shrink_to_fit() } @@ -1370,6 +1399,7 @@ impl PathBuf { /// /// [`shrink_to`]: OsString::shrink_to #[unstable(feature = "shrink_to", issue = "56431")] + #[inline] pub fn shrink_to(&mut self, min_capacity: usize) { self.inner.shrink_to(min_capacity) } @@ -1400,6 +1430,7 @@ impl From> for PathBuf { /// Converts a `Box` into a `PathBuf` /// /// This conversion does not allocate or copy memory. + #[inline] fn from(boxed: Box) -> PathBuf { boxed.into_path_buf() } @@ -1411,6 +1442,7 @@ impl From for Box { /// /// This conversion currently should not allocate memory, /// but this behavior is not guaranteed on all platforms or in all future versions. + #[inline] fn from(p: PathBuf) -> Box { p.into_boxed_path() } @@ -1426,6 +1458,7 @@ impl Clone for Box { #[stable(feature = "rust1", since = "1.0.0")] impl> From<&T> for PathBuf { + #[inline] fn from(s: &T) -> PathBuf { PathBuf::from(s.as_ref().to_os_string()) } @@ -1447,6 +1480,7 @@ impl From for OsString { /// Converts a `PathBuf` into a `OsString` /// /// This conversion does not allocate or copy memory. + #[inline] fn from(path_buf: PathBuf) -> OsString { path_buf.inner } @@ -1457,6 +1491,7 @@ impl From for PathBuf { /// Converts a `String` into a `PathBuf` /// /// This conversion does not allocate or copy memory. + #[inline] fn from(s: String) -> PathBuf { PathBuf::from(OsString::from(s)) } @@ -1466,6 +1501,7 @@ impl From for PathBuf { impl FromStr for PathBuf { type Err = core::convert::Infallible; + #[inline] fn from_str(s: &str) -> Result { Ok(PathBuf::from(s)) } @@ -1510,6 +1546,7 @@ impl ops::Deref for PathBuf { #[stable(feature = "rust1", since = "1.0.0")] impl Borrow for PathBuf { + #[inline] fn borrow(&self) -> &Path { self.deref() } @@ -1517,6 +1554,7 @@ impl Borrow for PathBuf { #[stable(feature = "default_for_pathbuf", since = "1.17.0")] impl Default for PathBuf { + #[inline] fn default() -> Self { PathBuf::new() } @@ -1597,9 +1635,11 @@ impl From<&Path> for Rc { #[stable(feature = "rust1", since = "1.0.0")] impl ToOwned for Path { type Owned = PathBuf; + #[inline] fn to_owned(&self) -> PathBuf { self.to_path_buf() } + #[inline] fn clone_into(&self, target: &mut PathBuf) { self.inner.clone_into(&mut target.inner); } @@ -1607,6 +1647,7 @@ impl ToOwned for Path { #[stable(feature = "rust1", since = "1.0.0")] impl cmp::PartialEq for PathBuf { + #[inline] fn eq(&self, other: &PathBuf) -> bool { self.components() == other.components() } @@ -1624,6 +1665,7 @@ impl cmp::Eq for PathBuf {} #[stable(feature = "rust1", since = "1.0.0")] impl cmp::PartialOrd for PathBuf { + #[inline] fn partial_cmp(&self, other: &PathBuf) -> Option { self.components().partial_cmp(other.components()) } @@ -1631,6 +1673,7 @@ impl cmp::PartialOrd for PathBuf { #[stable(feature = "rust1", since = "1.0.0")] impl cmp::Ord for PathBuf { + #[inline] fn cmp(&self, other: &PathBuf) -> cmp::Ordering { self.components().cmp(other.components()) } @@ -1638,6 +1681,7 @@ impl cmp::Ord for PathBuf { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for PathBuf { + #[inline] fn as_ref(&self) -> &OsStr { &self.inner[..] } @@ -1745,6 +1789,7 @@ impl Path { /// assert_eq!(os_str, std::ffi::OsStr::new("foo.txt")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn as_os_str(&self) -> &OsStr { &self.inner } @@ -1766,6 +1811,7 @@ impl Path { /// assert_eq!(path.to_str(), Some("foo.txt")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn to_str(&self) -> Option<&str> { self.inner.to_str() } @@ -1791,6 +1837,7 @@ impl Path { /// Had `path` contained invalid unicode, the `to_string_lossy` call might /// have returned `"fo�.txt"`. #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn to_string_lossy(&self) -> Cow<'_, str> { self.inner.to_string_lossy() } @@ -1854,6 +1901,7 @@ impl Path { /// /// [`is_absolute`]: Path::is_absolute #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn is_relative(&self) -> bool { !self.is_absolute() } @@ -1879,6 +1927,7 @@ impl Path { /// assert!(Path::new("/etc/passwd").has_root()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn has_root(&self) -> bool { self.components().has_root() } @@ -1941,6 +1990,7 @@ impl Path { /// /// [`parent`]: Path::parent #[stable(feature = "path_ancestors", since = "1.28.0")] + #[inline] pub fn ancestors(&self) -> Ancestors<'_> { Ancestors { next: Some(&self) } } @@ -2265,6 +2315,7 @@ impl Path { /// assert_eq!(it.next(), None) /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn iter(&self) -> Iter<'_> { Iter { inner: self.components() } } @@ -2284,6 +2335,7 @@ impl Path { /// println!("{}", path.display()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn display(&self) -> Display<'_> { Display { path: self } } @@ -2305,6 +2357,7 @@ impl Path { /// println!("{:?}", metadata.file_type()); /// ``` #[stable(feature = "path_ext", since = "1.5.0")] + #[inline] pub fn metadata(&self) -> io::Result { fs::metadata(self) } @@ -2323,6 +2376,7 @@ impl Path { /// println!("{:?}", metadata.file_type()); /// ``` #[stable(feature = "path_ext", since = "1.5.0")] + #[inline] pub fn symlink_metadata(&self) -> io::Result { fs::symlink_metadata(self) } @@ -2341,6 +2395,7 @@ impl Path { /// assert_eq!(path.canonicalize().unwrap(), PathBuf::from("/foo/test/bar.rs")); /// ``` #[stable(feature = "path_ext", since = "1.5.0")] + #[inline] pub fn canonicalize(&self) -> io::Result { fs::canonicalize(self) } @@ -2358,6 +2413,7 @@ impl Path { /// let path_link = path.read_link().expect("read_link call failed"); /// ``` #[stable(feature = "path_ext", since = "1.5.0")] + #[inline] pub fn read_link(&self) -> io::Result { fs::read_link(self) } @@ -2382,6 +2438,7 @@ impl Path { /// } /// ``` #[stable(feature = "path_ext", since = "1.5.0")] + #[inline] pub fn read_dir(&self) -> io::Result { fs::read_dir(self) } @@ -2406,6 +2463,7 @@ impl Path { /// This is a convenience function that coerces errors to false. If you want to /// check errors, call [`fs::metadata`]. #[stable(feature = "path_ext", since = "1.5.0")] + #[inline] pub fn exists(&self) -> bool { fs::metadata(self).is_ok() } @@ -2480,6 +2538,7 @@ impl Path { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for Path { + #[inline] fn as_ref(&self) -> &OsStr { &self.inner } @@ -2531,6 +2590,7 @@ impl fmt::Display for Display<'_> { #[stable(feature = "rust1", since = "1.0.0")] impl cmp::PartialEq for Path { + #[inline] fn eq(&self, other: &Path) -> bool { self.components().eq(other.components()) } @@ -2550,6 +2610,7 @@ impl cmp::Eq for Path {} #[stable(feature = "rust1", since = "1.0.0")] impl cmp::PartialOrd for Path { + #[inline] fn partial_cmp(&self, other: &Path) -> Option { self.components().partial_cmp(other.components()) } @@ -2557,6 +2618,7 @@ impl cmp::PartialOrd for Path { #[stable(feature = "rust1", since = "1.0.0")] impl cmp::Ord for Path { + #[inline] fn cmp(&self, other: &Path) -> cmp::Ordering { self.components().cmp(other.components()) } @@ -2564,6 +2626,7 @@ impl cmp::Ord for Path { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for Path { + #[inline] fn as_ref(&self) -> &Path { self } @@ -2571,6 +2634,7 @@ impl AsRef for Path { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for OsStr { + #[inline] fn as_ref(&self) -> &Path { Path::new(self) } @@ -2578,6 +2642,7 @@ impl AsRef for OsStr { #[stable(feature = "cow_os_str_as_ref_path", since = "1.8.0")] impl AsRef for Cow<'_, OsStr> { + #[inline] fn as_ref(&self) -> &Path { Path::new(self) } @@ -2585,6 +2650,7 @@ impl AsRef for Cow<'_, OsStr> { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for OsString { + #[inline] fn as_ref(&self) -> &Path { Path::new(self) } @@ -2600,6 +2666,7 @@ impl AsRef for str { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for String { + #[inline] fn as_ref(&self) -> &Path { Path::new(self) } @@ -2617,6 +2684,7 @@ impl AsRef for PathBuf { impl<'a> IntoIterator for &'a PathBuf { type Item = &'a OsStr; type IntoIter = Iter<'a>; + #[inline] fn into_iter(self) -> Iter<'a> { self.iter() } @@ -2626,6 +2694,7 @@ impl<'a> IntoIterator for &'a PathBuf { impl<'a> IntoIterator for &'a Path { type Item = &'a OsStr; type IntoIter = Iter<'a>; + #[inline] fn into_iter(self) -> Iter<'a> { self.iter() } From 4d7e48970aff055e415e3074115453dc76fe8fe9 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Fri, 22 Jan 2021 19:41:20 +0100 Subject: [PATCH 08/17] Note library tracking issue template in tracking issue template. --- .github/ISSUE_TEMPLATE/tracking_issue.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/tracking_issue.md b/.github/ISSUE_TEMPLATE/tracking_issue.md index 24f4321389713..0065960507179 100644 --- a/.github/ISSUE_TEMPLATE/tracking_issue.md +++ b/.github/ISSUE_TEMPLATE/tracking_issue.md @@ -5,6 +5,8 @@ title: Tracking Issue for XXX labels: C-tracking-issue ---