diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 35bceaa25c36e..549933ceeb645 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -709,6 +709,7 @@ unsafe impl Freeze for &mut T {} /// So this, for example, can only be done on types implementing `Unpin`: /// /// ```rust +/// # #![allow(unused_must_use)] /// use std::mem; /// use std::pin::Pin; /// diff --git a/src/libcore/mem/mod.rs b/src/libcore/mem/mod.rs index 07f7d28bb7546..3fa2b7a2d042c 100644 --- a/src/libcore/mem/mod.rs +++ b/src/libcore/mem/mod.rs @@ -808,6 +808,7 @@ pub fn take(dest: &mut T) -> T { /// [`Clone`]: ../../std/clone/trait.Clone.html #[inline] #[stable(feature = "rust1", since = "1.0.0")] +#[must_use = "if you don't need the old value, you can just assign the new value directly"] pub fn replace(dest: &mut T, mut src: T) -> T { swap(dest, &mut src); src diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index dc7637cfdb934..2c11d5cd25759 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -3010,6 +3010,12 @@ impl str { /// /// Returns `false` if it does not. /// + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html + /// /// # Examples /// /// Basic usage: @@ -3031,6 +3037,12 @@ impl str { /// /// Returns `false` if it does not. /// + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html + /// /// # Examples /// /// Basic usage: @@ -3051,6 +3063,12 @@ impl str { /// /// Returns `false` if it does not. /// + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html + /// /// # Examples /// /// Basic usage: @@ -3074,10 +3092,12 @@ impl str { /// /// Returns [`None`] if the pattern doesn't match. /// - /// The pattern can be a `&str`, [`char`], or a closure that determines if - /// a character matches. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. /// /// [`None`]: option/enum.Option.html#variant.None + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Examples /// @@ -3121,10 +3141,12 @@ impl str { /// /// Returns [`None`] if the pattern doesn't match. /// - /// The pattern can be a `&str`, [`char`], or a closure that determines if - /// a character matches. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. /// /// [`None`]: option/enum.Option.html#variant.None + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Examples /// @@ -3166,8 +3188,11 @@ impl str { /// An iterator over substrings of this string slice, separated by /// characters matched by a pattern. /// - /// The pattern can be any type that implements the Pattern trait. Notable - /// examples are `&str`, [`char`], and closures that determines the split. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Iterator behavior /// @@ -3285,6 +3310,12 @@ impl str { /// `split` in that `split_inclusive` leaves the matched part as the /// terminator of the substring. /// + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html + /// /// # Examples /// /// ``` @@ -3319,8 +3350,11 @@ impl str { /// An iterator over substrings of the given string slice, separated by /// characters matched by a pattern and yielded in reverse order. /// - /// The pattern can be any type that implements the Pattern trait. Notable - /// examples are `&str`, [`char`], and closures that determines the split. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Iterator behavior /// @@ -3370,8 +3404,11 @@ impl str { /// An iterator over substrings of the given string slice, separated by /// characters matched by a pattern. /// - /// The pattern can be any type that implements the Pattern trait. Notable - /// examples are `&str`, [`char`], and closures that determines the split. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// Equivalent to [`split`], except that the trailing substring /// is skipped if empty. @@ -3414,10 +3451,11 @@ impl str { /// An iterator over substrings of `self`, separated by characters /// matched by a pattern and yielded in reverse order. /// - /// The pattern can be any type that implements the Pattern trait. Notable - /// examples are `&str`, [`char`], and closures that determines the split. - /// Additional libraries might provide more complex patterns like - /// regular expressions. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// Equivalent to [`split`], except that the trailing substring is /// skipped if empty. @@ -3462,8 +3500,11 @@ impl str { /// If `n` substrings are returned, the last substring (the `n`th substring) /// will contain the remainder of the string. /// - /// The pattern can be any type that implements the Pattern trait. Notable - /// examples are `&str`, [`char`], and closures that determines the split. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Iterator behavior /// @@ -3512,8 +3553,11 @@ impl str { /// If `n` substrings are returned, the last substring (the `n`th substring) /// will contain the remainder of the string. /// - /// The pattern can be any type that implements the Pattern trait. Notable - /// examples are `&str`, [`char`], and closures that determines the split. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Iterator behavior /// @@ -3557,8 +3601,11 @@ impl str { /// An iterator over the disjoint matches of a pattern within the given string /// slice. /// - /// The pattern can be a `&str`, [`char`], or a closure that determines if - /// a character matches. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Iterator behavior /// @@ -3593,8 +3640,11 @@ impl str { /// An iterator over the disjoint matches of a pattern within this string slice, /// yielded in reverse order. /// - /// The pattern can be a `&str`, [`char`], or a closure that determines if - /// a character matches. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Iterator behavior /// @@ -3634,8 +3684,11 @@ impl str { /// For matches of `pat` within `self` that overlap, only the indices /// corresponding to the first match are returned. /// - /// The pattern can be a `&str`, [`char`], or a closure that determines - /// if a character matches. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Iterator behavior /// @@ -3676,8 +3729,11 @@ impl str { /// For matches of `pat` within `self` that overlap, only the indices /// corresponding to the last match are returned. /// - /// The pattern can be a `&str`, [`char`], or a closure that determines if a - /// character matches. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Iterator behavior /// @@ -3894,8 +3950,11 @@ impl str { /// Returns a string slice with all prefixes and suffixes that match a /// pattern repeatedly removed. /// - /// The pattern can be a [`char`] or a closure that determines if a - /// character matches. + /// The [pattern] can be a [`char`], a slice of [`char`]s, or a function + /// or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Examples /// @@ -3939,8 +3998,11 @@ impl str { /// Returns a string slice with all prefixes that match a pattern /// repeatedly removed. /// - /// The pattern can be a `&str`, [`char`], or a closure that determines if - /// a character matches. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Text directionality /// @@ -3981,6 +4043,12 @@ impl str { /// /// If the string does not start with `prefix`, `None` is returned. /// + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html + /// /// # Examples /// /// ``` @@ -4005,6 +4073,12 @@ impl str { /// /// If the string does not end with `suffix`, `None` is returned. /// + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html + /// /// # Examples /// /// ``` @@ -4027,8 +4101,11 @@ impl str { /// Returns a string slice with all suffixes that match a pattern /// repeatedly removed. /// - /// The pattern can be a `&str`, [`char`], or a closure that - /// determines if a character matches. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. + /// + /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Text directionality /// @@ -4073,10 +4150,11 @@ impl str { /// Returns a string slice with all prefixes that match a pattern /// repeatedly removed. /// - /// The pattern can be a `&str`, [`char`], or a closure that determines if - /// a character matches. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Text directionality /// @@ -4109,10 +4187,11 @@ impl str { /// Returns a string slice with all suffixes that match a pattern /// repeatedly removed. /// - /// The pattern can be a `&str`, [`char`], or a closure that - /// determines if a character matches. + /// The [pattern] can be a `&str`, [`char`], a slice of [`char`]s, or a + /// function or closure that determines if a character matches. /// /// [`char`]: primitive.char.html + /// [pattern]: str/pattern/index.html /// /// # Text directionality /// diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 708e4e5560ecd..2377536c156fa 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -1,7 +1,41 @@ //! The string Pattern API. //! +//! The Pattern API provides a generic mechanism for using different pattern +//! types when searching through a string. +//! //! For more details, see the traits [`Pattern`], [`Searcher`], //! [`ReverseSearcher`], and [`DoubleEndedSearcher`]. +//! +//! Although this API is unstable, it is exposed via stable APIs on the +//! [`str`] type. +//! +//! # Examples +//! +//! [`Pattern`] is [implemented][pattern-impls] in the stable API for +//! [`&str`], [`char`], slices of [`char`], and functions and closures +//! implementing `FnMut(char) -> bool`. +//! +//! ``` +//! let s = "Can you find a needle in a haystack?"; +//! +//! // &str pattern +//! assert_eq!(s.find("you"), Some(4)); +//! // char pattern +//! assert_eq!(s.find('n'), Some(2)); +//! // slice of chars pattern +//! assert_eq!(s.find(&['a', 'e', 'i', 'o', 'u'][..]), Some(1)); +//! // closure pattern +//! assert_eq!(s.find(|c: char| c.is_ascii_punctuation()), Some(35)); +//! ``` +//! +//! [`&str`]: ../../../std/primitive.str.html +//! [`char`]: ../../../std/primitive.char.html +//! [`str`]: ../../../std/primitive.str.html +//! [`DoubleEndedSearcher`]: trait.DoubleEndedSearcher.html +//! [`Pattern`]: trait.Pattern.html +//! [`ReverseSearcher`]: trait.ReverseSearcher.html +//! [`Searcher`]: trait.Searcher.html +//! [pattern-impls]: trait.Pattern.html#implementors #![unstable( feature = "pattern", @@ -702,7 +736,7 @@ unsafe impl<'a, 'b> ReverseSearcher<'a> for CharSliceSearcher<'a, 'b> { impl<'a, 'b> DoubleEndedSearcher<'a> for CharSliceSearcher<'a, 'b> {} -/// Searches for chars that are equal to any of the chars in the array. +/// Searches for chars that are equal to any of the chars in the slice. /// /// # Examples /// diff --git a/src/librustc_parse/parser/expr.rs b/src/librustc_parse/parser/expr.rs index 986f5410e26c0..3f08fb79790fb 100644 --- a/src/librustc_parse/parser/expr.rs +++ b/src/librustc_parse/parser/expr.rs @@ -547,8 +547,7 @@ impl<'a> Parser<'a> { // Rewind to before attempting to parse the type with generics, to recover // from situations like `x as usize < y` in which we first tried to parse // `usize < y` as a type with generic arguments. - let parser_snapshot_after_type = self.clone(); - mem::replace(self, parser_snapshot_before_type); + let parser_snapshot_after_type = mem::replace(self, parser_snapshot_before_type); match self.parse_path(PathStyle::Expr) { Ok(path) => { @@ -560,7 +559,7 @@ impl<'a> Parser<'a> { // example because `parse_ty_no_plus` returns `Err` on keywords, // but `parse_path` returns `Ok` on them due to error recovery. // Return original error and parser state. - mem::replace(self, parser_snapshot_after_type); + *self = parser_snapshot_after_type; return Err(type_err); } }; @@ -601,7 +600,7 @@ impl<'a> Parser<'a> { Err(mut path_err) => { // Couldn't parse as a path, return original error and parser state. path_err.cancel(); - mem::replace(self, parser_snapshot_after_type); + *self = parser_snapshot_after_type; return Err(type_err); } } diff --git a/src/librustc_parse/parser/generics.rs b/src/librustc_parse/parser/generics.rs index f4729e306f806..8e8f864728ce6 100644 --- a/src/librustc_parse/parser/generics.rs +++ b/src/librustc_parse/parser/generics.rs @@ -105,7 +105,7 @@ impl<'a> Parser<'a> { } Err(mut err) => { err.cancel(); - std::mem::replace(self, snapshot); + *self = snapshot; break; } } diff --git a/src/librustc_parse/parser/item.rs b/src/librustc_parse/parser/item.rs index ae8a20f209b99..e9f5f2c0deafc 100644 --- a/src/librustc_parse/parser/item.rs +++ b/src/librustc_parse/parser/item.rs @@ -1650,7 +1650,7 @@ impl<'a> Parser<'a> { // Recover from attempting to parse the argument as a type without pattern. Err(mut err) => { err.cancel(); - mem::replace(self, parser_snapshot_before_ty); + *self = parser_snapshot_before_ty; self.recover_arg_parse()? } } diff --git a/src/librustc_parse/parser/stmt.rs b/src/librustc_parse/parser/stmt.rs index b3764d2d47be1..e5d0ab247aa46 100644 --- a/src/librustc_parse/parser/stmt.rs +++ b/src/librustc_parse/parser/stmt.rs @@ -163,8 +163,8 @@ impl<'a> Parser<'a> { Ok(ty) => (None, Some(ty)), Err(mut err) => { // Rewind to before attempting to parse the type and continue parsing. - let parser_snapshot_after_type = self.clone(); - mem::replace(self, parser_snapshot_before_type); + let parser_snapshot_after_type = + mem::replace(self, parser_snapshot_before_type); if let Ok(snip) = self.span_to_snippet(pat.span) { err.span_label(pat.span, format!("while parsing the type for `{}`", snip)); } @@ -201,7 +201,7 @@ impl<'a> Parser<'a> { // Couldn't parse the type nor the initializer, only raise the type error and // return to the parser state before parsing the type as the initializer. // let x: ; - mem::replace(self, snapshot); + *self = snapshot; return Err(ty_err); } (Err(err), None) => { diff --git a/src/librustc_resolve/late/lifetimes.rs b/src/librustc_resolve/late/lifetimes.rs index defb2c06b32ca..0d12bf08747fa 100644 --- a/src/librustc_resolve/late/lifetimes.rs +++ b/src/librustc_resolve/late/lifetimes.rs @@ -26,7 +26,7 @@ use rustc_span::symbol::{kw, sym}; use rustc_span::Span; use std::borrow::Cow; use std::cell::Cell; -use std::mem::{replace, take}; +use std::mem::take; use log::debug; @@ -371,7 +371,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { self.with(Scope::Body { id: body.id(), s: self.scope }, |_, this| { this.visit_body(body); }); - replace(&mut self.labels_in_fn, saved); + self.labels_in_fn = saved; } fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index da020b85ed499..b91aab44f10a2 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -789,6 +789,37 @@ themePicker.onblur = handleThemeButtonsBlur; Ok((ret, krates)) } + fn collect_json(path: &Path, krate: &str) -> io::Result<(Vec, Vec)> { + let mut ret = Vec::new(); + let mut krates = Vec::new(); + + if path.exists() { + for line in BufReader::new(File::open(path)?).lines() { + let line = line?; + if !line.starts_with("\"") { + continue; + } + if line.starts_with(&format!("\"{}\"", krate)) { + continue; + } + if line.ends_with(",\\") { + ret.push(line[..line.len() - 2].to_string()); + } else { + // Ends with "\\" (it's the case for the last added crate line) + ret.push(line[..line.len() - 1].to_string()); + } + krates.push( + line.split('"') + .filter(|s| !s.is_empty()) + .next() + .map(|s| s.to_owned()) + .unwrap_or_else(String::new), + ); + } + } + Ok((ret, krates)) + } + fn show_item(item: &IndexItem, krate: &str) -> String { format!( "{{'crate':'{}','ty':{},'name':'{}','desc':'{}','p':'{}'{}}}", @@ -909,18 +940,18 @@ themePicker.onblur = handleThemeButtonsBlur; // Update the search index let dst = cx.dst.join(&format!("search-index{}.js", cx.shared.resource_suffix)); - let (mut all_indexes, mut krates) = try_err!(collect(&dst, &krate.name, "searchIndex"), &dst); + let (mut all_indexes, mut krates) = try_err!(collect_json(&dst, &krate.name), &dst); all_indexes.push(search_index); // Sort the indexes by crate so the file will be generated identically even // with rustdoc running in parallel. all_indexes.sort(); { - let mut v = String::from("var searchIndex={};\n"); - v.push_str(&all_indexes.join("\n")); + let mut v = String::from("var searchIndex = JSON.parse('{\\\n"); + v.push_str(&all_indexes.join(",\\\n")); // "addSearchOptions" has to be called first so the crate filtering can be set before the // search might start (if it's set into the URL for example). - v.push_str("\naddSearchOptions(searchIndex);initSearch(searchIndex);"); + v.push_str("\\\n}');\naddSearchOptions(searchIndex);initSearch(searchIndex);"); cx.shared.fs.write(&dst, &v)?; } if options.enable_index_page { diff --git a/src/librustdoc/html/render/cache.rs b/src/librustdoc/html/render/cache.rs index f3c5c12810bf2..5b09029122718 100644 --- a/src/librustdoc/html/render/cache.rs +++ b/src/librustdoc/html/render/cache.rs @@ -634,7 +634,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String { // Collect the index into a string format!( - r#"searchIndex["{}"] = {};"#, + r#""{}":{}"#, krate.name, serde_json::to_string(&CrateData { doc: crate_doc, @@ -642,6 +642,11 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String { paths: crate_paths, }) .expect("failed serde conversion") + // All these `replace` calls are because we have to go through JS string for JSON content. + .replace(r"\", r"\\") + .replace("'", r"\'") + // We need to escape double quotes for the JSON. + .replace("\\\"", "\\\\\"") ) } diff --git a/src/libstd/path.rs b/src/libstd/path.rs index b8361d3e82599..173d6d1cfa7ef 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1116,7 +1116,6 @@ impl PathBuf { /// # Examples /// /// ``` - /// #![feature(path_buf_capacity)] /// use std::path::PathBuf; /// /// let mut path = PathBuf::with_capacity(10); @@ -1130,7 +1129,7 @@ impl PathBuf { /// /// [`with_capacity`]: ../ffi/struct.OsString.html#method.with_capacity /// [`OsString`]: ../ffi/struct.OsString.html - #[unstable(feature = "path_buf_capacity", issue = "58234")] + #[stable(feature = "path_buf_capacity", since = "1.44.0")] pub fn with_capacity(capacity: usize) -> PathBuf { PathBuf { inner: OsString::with_capacity(capacity) } } @@ -1374,7 +1373,7 @@ impl PathBuf { /// /// [`capacity`]: ../ffi/struct.OsString.html#method.capacity /// [`OsString`]: ../ffi/struct.OsString.html - #[unstable(feature = "path_buf_capacity", issue = "58234")] + #[stable(feature = "path_buf_capacity", since = "1.44.0")] pub fn capacity(&self) -> usize { self.inner.capacity() } @@ -1383,7 +1382,7 @@ impl PathBuf { /// /// [`clear`]: ../ffi/struct.OsString.html#method.clear /// [`OsString`]: ../ffi/struct.OsString.html - #[unstable(feature = "path_buf_capacity", issue = "58234")] + #[stable(feature = "path_buf_capacity", since = "1.44.0")] pub fn clear(&mut self) { self.inner.clear() } @@ -1392,7 +1391,7 @@ impl PathBuf { /// /// [`reserve`]: ../ffi/struct.OsString.html#method.reserve /// [`OsString`]: ../ffi/struct.OsString.html - #[unstable(feature = "path_buf_capacity", issue = "58234")] + #[stable(feature = "path_buf_capacity", since = "1.44.0")] pub fn reserve(&mut self, additional: usize) { self.inner.reserve(additional) } @@ -1401,7 +1400,7 @@ impl PathBuf { /// /// [`reserve_exact`]: ../ffi/struct.OsString.html#method.reserve_exact /// [`OsString`]: ../ffi/struct.OsString.html - #[unstable(feature = "path_buf_capacity", issue = "58234")] + #[stable(feature = "path_buf_capacity", since = "1.44.0")] pub fn reserve_exact(&mut self, additional: usize) { self.inner.reserve_exact(additional) } @@ -1410,7 +1409,7 @@ impl PathBuf { /// /// [`shrink_to_fit`]: ../ffi/struct.OsString.html#method.shrink_to_fit /// [`OsString`]: ../ffi/struct.OsString.html - #[unstable(feature = "path_buf_capacity", issue = "58234")] + #[stable(feature = "path_buf_capacity", since = "1.44.0")] pub fn shrink_to_fit(&mut self) { self.inner.shrink_to_fit() } @@ -1419,7 +1418,7 @@ impl PathBuf { /// /// [`shrink_to`]: ../ffi/struct.OsString.html#method.shrink_to /// [`OsString`]: ../ffi/struct.OsString.html - #[unstable(feature = "path_buf_capacity", issue = "58234")] + #[unstable(feature = "shrink_to", issue = "56431")] pub fn shrink_to(&mut self, min_capacity: usize) { self.inner.shrink_to(min_capacity) } diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 29e99c0afd27f..094c468a6770e 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -301,7 +301,7 @@ mod lazy { // value (an aliasing violation). To avoid setting the "I'm running a // destructor" flag we just use `mem::replace` which should sequence the // operations a little differently and make this safe to call. - mem::replace(&mut *ptr, Some(value)); + let _ = mem::replace(&mut *ptr, Some(value)); // After storing `Some` we want to get a reference to the contents of // what we just stored. While we could use `unwrap` here and it should diff --git a/src/test/ui/imports/import-in-block.rs b/src/test/ui/imports/import-in-block.rs index c0ba6220b5443..19703904ece91 100644 --- a/src/test/ui/imports/import-in-block.rs +++ b/src/test/ui/imports/import-in-block.rs @@ -4,7 +4,7 @@ pub fn main() { use std::mem::replace; let mut x = 5; - replace(&mut x, 6); + let _ = replace(&mut x, 6); { use std::mem::*; let mut y = 6; diff --git a/src/test/ui/issues/issue-23611-enum-swap-in-drop.rs b/src/test/ui/issues/issue-23611-enum-swap-in-drop.rs index 6ef7fd42ec6d0..403cf970bcb0a 100644 --- a/src/test/ui/issues/issue-23611-enum-swap-in-drop.rs +++ b/src/test/ui/issues/issue-23611-enum-swap-in-drop.rs @@ -153,6 +153,7 @@ impl<'a> Drop for E<'a> { } }; + #[allow(unused_must_use)] if do_drop { mem::replace(self, E::A(GaspA(f_a, 0xA3A0, log, D::new("drop", 6, log)), true)); }