Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 16 pull requests #53662

Merged
merged 43 commits into from
Aug 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
0603a73
Add test case for #50865 regression.
FelixMcFelix Jul 20, 2018
f285876
Logging for rustc_privacy.
FelixMcFelix Aug 10, 2018
8a72954
Window Mutex: make sure we properly initialize the SRWLock
RalfJung Aug 13, 2018
b7a49e7
fixed wording
RalfJung Aug 14, 2018
00b2606
Mark impl Trait Functions as reachable. (Fixes #50865)
FelixMcFelix Aug 20, 2018
81684bf
New AccessLevel and accompanying propagation.
FelixMcFelix Aug 20, 2018
54b096a
Fixes for code review.
FelixMcFelix Aug 21, 2018
3536359
Further fixes.
FelixMcFelix Aug 21, 2018
17eb64a
add macro check for lint
Dylan-DPC Aug 21, 2018
a6201f9
add testcase to existing macro testcase
Dylan-DPC Aug 21, 2018
11f3918
docs: std::string::String.repeat(): slightly rephrase to be more in-l…
matthiaskrgr Aug 22, 2018
f07245c
Update RELEASES.md
Aaronepower Aug 22, 2018
c9c4f5e
Fix a grammatical mistake in "expected generic arguments" errors
varkor Aug 22, 2018
276253e
update nomicon and book
RalfJung Aug 22, 2018
200c6d9
Update RELEASES.md
Aaronepower Aug 22, 2018
8fbcb9c
add warning for missing docs
Dylan-DPC Aug 22, 2018
a15b617
tidy: Stop requiring a license header
joshtriplett Aug 22, 2018
b188c2a
Lament the invincibility of the Turbofish
varkor Aug 21, 2018
ede1f7d
use String::new() instead of String::from(""), "".to_string(), "".to_…
matthiaskrgr Aug 23, 2018
85a05d1
Light restructuring.
FelixMcFelix Aug 23, 2018
9e0ff24
Prefer `.nth(n)` over `.skip(n).next()`.
frewsxcv Aug 23, 2018
e7709b3
Discourage overuse of mem::forget
kornelski Aug 19, 2018
747722e
fix testcase
Dylan-DPC Aug 23, 2018
2cc2e01
Add missing fmt examples
GuillaumeGomez Aug 22, 2018
25a83e3
Use SmallVec for SmallCStr
llogiq Aug 23, 2018
ab5a71b
Rollup merge of #53311 - RalfJung:windows-mutex, r=retep998
kennytm Aug 24, 2018
973428d
Rollup merge of #53503 - kornelski:master, r=dtolnay
kennytm Aug 24, 2018
7f396ba
Rollup merge of #53559 - Dylan-DPC:fix/missing-doc-lint, r=kennytm
kennytm Aug 24, 2018
714e5b3
Rollup merge of #53562 - varkor:bastion-of-the-turbofish, r=nagisa
kennytm Aug 24, 2018
d13c612
Rollup merge of #53563 - matthiaskrgr:String, r=varkor
kennytm Aug 24, 2018
b24a30e
Remove unnecessary closure in rustc_mir/build/mod.rs
IsaacWoods Aug 24, 2018
c802be6
Added rustc_codegen_llvm to compiler documentation.
davidtwco Aug 24, 2018
c51903c
Rollup merge of #53592 - matthiaskrgr:str_doc, r=alexcrichton
kennytm Aug 24, 2018
3fbd72e
Rollup merge of #53594 - rust-lang:Aaronepower-patch-1, r=Mark-Simula…
kennytm Aug 24, 2018
7d990fa
Rollup merge of #53600 - varkor:expected-generic-arg-s, r=eddyb
kennytm Aug 24, 2018
ff4500c
Rollup merge of #53614 - RalfJung:nomicon, r=kennytm
kennytm Aug 24, 2018
cf90fd0
Rollup merge of #53617 - joshtriplett:tidy-no-license-header, r=Mark-…
kennytm Aug 24, 2018
a37b69d
Rollup merge of #53618 - GuillaumeGomez:fmt-examples, r=QuietMisdreavus
kennytm Aug 24, 2018
9dfb95b
Rollup merge of #53636 - frewsxcv:frewsxcv-nth, r=rkruppe
kennytm Aug 24, 2018
0009fad
Rollup merge of #53644 - llogiq:smallvec-for-small-c-str, r=estebank
kennytm Aug 24, 2018
62f29c4
Rollup merge of #53664 - IsaacWoods:fix_53608, r=oli-obk
kennytm Aug 24, 2018
a1ec2f7
Rollup merge of #53545 - FelixMcFelix:fix-50865-beta, r=petrochenkov
kennytm Aug 24, 2018
c6039de
Rollup merge of #53666 - davidtwco:issue-51737, r=Mark-Simulacrum
kennytm Aug 24, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Misc
will demote `deny` and `forbid` lints to `warn`.
- [`rustc` and `rustdoc` will now have the exit code of `1` if compilation
fails, and `101` if there is a panic.][52197]
- [A preview of clippy has been made available through rustup.][51122]
You can install the preview with `rustup component add clippy-preview`

Compatibility Notes
-------------------
Expand All @@ -64,6 +66,7 @@ Compatibility Notes
[51619]: https://github.com/rust-lang/rust/pull/51619/
[51656]: https://github.com/rust-lang/rust/pull/51656/
[51178]: https://github.com/rust-lang/rust/pull/51178/
[51122]: https://github.com/rust-lang/rust/pull/51122
[50494]: https://github.com/rust-lang/rust/pull/50494/
[cargo/5614]: https://github.com/rust-lang/cargo/pull/5614/
[cargo/5723]: https://github.com/rust-lang/cargo/pull/5723/
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ impl Step for Rustc {

// Find dependencies for top level crates.
let mut compiler_crates = HashSet::new();
for root_crate in &["rustc", "rustc_driver"] {
for root_crate in &["rustc", "rustc_driver", "rustc_codegen_llvm"] {
let interned_root_crate = INTERNER.intern_str(root_crate);
find_compiler_crates(builder, &interned_root_crate, &mut compiler_crates);
}
Expand Down
2 changes: 1 addition & 1 deletion src/doc/nomicon
2 changes: 1 addition & 1 deletion src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ impl str {
unsafe { String::from_utf8_unchecked(slice.into_vec()) }
}

/// Create a [`String`] by repeating a string `n` times.
/// Creates a new [`String`] by repeating a string `n` times.
///
/// [`String`]: string/struct.String.html
///
Expand Down
6 changes: 3 additions & 3 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ impl String {
self.vec
}

/// Extracts a string slice containing the entire string.
/// Extracts a string slice containing the entire `String`.
///
/// # Examples
///
Expand Down Expand Up @@ -1454,8 +1454,8 @@ impl String {
self.vec.clear()
}

/// Creates a draining iterator that removes the specified range in the string
/// and yields the removed chars.
/// Creates a draining iterator that removes the specified range in the `String`
/// and yields the removed `chars`.
///
/// Note: The element range is removed even if the iterator is not
/// consumed until the end.
Expand Down
68 changes: 67 additions & 1 deletion src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,36 @@ impl<'a> Formatter<'a> {
///
/// This function will correctly account for the flags provided as well as
/// the minimum width. It will not take precision into account.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Foo { nb: i32 };
///
/// impl Foo {
/// fn new(nb: i32) -> Foo {
/// Foo {
/// nb,
/// }
/// }
/// }
///
/// impl fmt::Display for Foo {
/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
/// // We need to remove "-" from the number output.
/// let tmp = self.nb.abs().to_string();
///
/// formatter.pad_integral(self.nb > 0, "Foo ", &tmp)
/// }
/// }
///
/// assert_eq!(&format!("{}", Foo::new(2)), "2");
/// assert_eq!(&format!("{}", Foo::new(-1)), "-1");
/// assert_eq!(&format!("{:#}", Foo::new(-1)), "-Foo 1");
/// assert_eq!(&format!("{:0>#8}", Foo::new(-1)), "00-Foo 1");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn pad_integral(&mut self,
is_nonnegative: bool,
Expand Down Expand Up @@ -1232,7 +1262,7 @@ impl<'a> Formatter<'a> {
// If our string is longer that the precision, then we must have
// truncation. However other flags like `fill`, `width` and `align`
// must act as always.
if let Some((i, _)) = s.char_indices().skip(max).next() {
if let Some((i, _)) = s.char_indices().nth(max) {
// LLVM here can't prove that `..i` won't panic `&s[..i]`, but
// we know that it can't panic. Use `get` + `unwrap_or` to avoid
// `unsafe` and otherwise don't emit any panic-related code
Expand Down Expand Up @@ -1381,12 +1411,48 @@ impl<'a> Formatter<'a> {

/// Writes some data to the underlying buffer contained within this
/// formatter.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Foo;
///
/// impl fmt::Display for Foo {
/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
/// formatter.write_str("Foo")
/// // This is equivalent to:
/// // write!(formatter, "Foo")
/// }
/// }
///
/// assert_eq!(&format!("{}", Foo), "Foo");
/// assert_eq!(&format!("{:0>8}", Foo), "Foo");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn write_str(&mut self, data: &str) -> Result {
self.buf.write_str(data)
}

/// Writes some formatted information into this instance.
///
/// # Examples
///
/// ```
/// use std::fmt;
///
/// struct Foo(i32);
///
/// impl fmt::Display for Foo {
/// fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
/// formatter.write_fmt(format_args!("Foo {}", self.0))
/// }
/// }
///
/// assert_eq!(&format!("{}", Foo(-1)), "Foo -1");
/// assert_eq!(&format!("{:0>8}", Foo(2)), "Foo 2");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn write_fmt(&mut self, fmt: Arguments) -> Result {
write(self.buf, fmt)
Expand Down
46 changes: 7 additions & 39 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ use ops::{Deref, DerefMut, CoerceUnsized};
#[stable(feature = "rust1", since = "1.0.0")]
pub use intrinsics::transmute;

/// Leaks a value: takes ownership and "forgets" about the value **without running
/// its destructor**.
/// Takes ownership and "forgets" about the value **without running its destructor**.
///
/// Any resources the value manages, such as heap memory or a file handle, will linger
/// forever in an unreachable state.
/// forever in an unreachable state. However, it does not guarantee that pointers
/// to this memory will remain valid.
///
/// If you want to dispose of a value properly, running its destructor, see
/// * If you want to leak memory, see [`Box::leak`][leak].
/// * If you want to obtain a raw pointer to the memory, see [`Box::into_raw`][into_raw].
/// * If you want to dispose of a value properly, running its destructor, see
/// [`mem::drop`][drop].
///
/// # Safety
Expand All @@ -59,15 +61,6 @@ pub use intrinsics::transmute;
///
/// # Examples
///
/// Leak some heap memory by never deallocating it:
///
/// ```
/// use std::mem;
///
/// let heap_memory = Box::new(3);
/// mem::forget(heap_memory);
/// ```
///
/// Leak an I/O object, never closing the file:
///
/// ```no_run
Expand Down Expand Up @@ -137,38 +130,13 @@ pub use intrinsics::transmute;
/// }
/// ```
///
/// ## Use case 3
///
/// You are transferring ownership across a [FFI] boundary to code written in
/// another language. You need to `forget` the value on the Rust side because Rust
/// code is no longer responsible for it.
///
/// ```no_run
/// use std::mem;
///
/// extern "C" {
/// fn my_c_function(x: *const u32);
/// }
///
/// let x: Box<u32> = Box::new(3);
///
/// // Transfer ownership into C code.
/// unsafe {
/// my_c_function(&*x);
/// }
/// mem::forget(x);
/// ```
///
/// In this case, C code must call back into Rust to free the object. Calling C's `free`
/// function on a [`Box`][box] is *not* safe! Also, `Box` provides an [`into_raw`][into_raw]
/// method which is the preferred way to do this in practice.
///
/// [drop]: fn.drop.html
/// [uninit]: fn.uninitialized.html
/// [clone]: ../clone/trait.Clone.html
/// [swap]: fn.swap.html
/// [FFI]: ../../book/first-edition/ffi.html
/// [box]: ../../std/boxed/struct.Box.html
/// [leak]: ../../std/boxed/struct.Box.html#method.leak
/// [into_raw]: ../../std/boxed/struct.Box.html#method.into_raw
/// [ub]: ../../reference/behavior-considered-undefined.html
#[inline]
Expand Down
1 change: 1 addition & 0 deletions src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,7 @@ impl_stable_hash_for!(enum traits::Reveal {
});

impl_stable_hash_for!(enum ::middle::privacy::AccessLevel {
ReachableFromImplTrait,
Reachable,
Exported,
Public
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
s
};
let var_description = match var_origin {
infer::MiscVariable(_) => "".to_string(),
infer::MiscVariable(_) => String::new(),
infer::PatternRegion(_) => " for pattern".to_string(),
infer::AddrOfRegion(_) => " for borrow expression".to_string(),
infer::Autoref(_) => " for autoref".to_string(),
Expand Down
4 changes: 3 additions & 1 deletion src/librustc/middle/privacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use syntax::ast::NodeId;
// Accessibility levels, sorted in ascending order
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum AccessLevel {
// Superset of Reachable used to mark impl Trait items.
ReachableFromImplTrait,
// Exported items + items participating in various kinds of public interfaces,
// but not directly nameable. For example, if function `fn f() -> T {...}` is
// public, then type `T` is reachable. Its values can be obtained by other crates
Expand All @@ -40,7 +42,7 @@ pub struct AccessLevels<Id = NodeId> {

impl<Id: Hash + Eq> AccessLevels<Id> {
pub fn is_reachable(&self, id: Id) -> bool {
self.map.contains_key(&id)
self.map.get(&id) >= Some(&AccessLevel::Reachable)
}
pub fn is_exported(&self, id: Id) -> bool {
self.map.get(&id) >= Some(&AccessLevel::Exported)
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/middle/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) ->
// Step 2: Mark all symbols that the symbols on the worklist touch.
reachable_context.propagate();

debug!("Inline reachability shows: {:?}", reachable_context.reachable_symbols);

// Return the set of reachable symbols.
ReachableSet(Lrc::new(reachable_context.reachable_symbols))
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2105,7 +2105,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
region
} else {
// Do not even print 'static
"".to_owned()
String::new()
};
write!(fmt, "&{}{}{:?}", region, kind_str, place)
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
"perform LLVM link-time optimizations"),
target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
"select target processor (rustc --print target-cpus for details)"),
target_feature: String = ("".to_string(), parse_string, [TRACKED],
target_feature: String = (String::new(), parse_string, [TRACKED],
"target specific attributes (rustc --print target-features for details)"),
passes: Vec<String> = (Vec::new(), parse_list, [TRACKED],
"a list of extra LLVM passes to run (space separated)"),
Expand Down Expand Up @@ -1085,7 +1085,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
"choose the code model to use (rustc --print code-models for details)"),
metadata: Vec<String> = (Vec::new(), parse_list, [TRACKED],
"metadata to mangle symbol names with"),
extra_filename: String = ("".to_string(), parse_string, [UNTRACKED],
extra_filename: String = (String::new(), parse_string, [UNTRACKED],
"extra data to put in each output filename"),
codegen_units: Option<usize> = (None, parse_opt_uint, [UNTRACKED],
"divide crate into N units to optimize in parallel"),
Expand Down Expand Up @@ -1992,7 +1992,7 @@ pub fn build_session_options_and_crate_config(
};
if cg.target_feature == "help" {
prints.push(PrintRequest::TargetFeatures);
cg.target_feature = "".to_string();
cg.target_feature = String::new();
}
if cg.relocation_model.as_ref().map_or(false, |s| s == "help") {
prints.push(PrintRequest::RelocationModels);
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
if len > 5 {
format!("\nand {} others", len - 4)
} else {
"".to_owned()
String::new()
}
));
}
Expand Down Expand Up @@ -917,7 +917,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
remove_refs);

err.span_suggestion_short_with_applicability(
sp, &format_str, String::from(""), Applicability::MachineApplicable
sp, &format_str, String::new(), Applicability::MachineApplicable
);
break;
}
Expand Down Expand Up @@ -1116,7 +1116,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
.collect::<Vec<String>>()
.join(", "))
} else {
"".to_owned()
String::new()
},
);
err.span_suggestion_with_applicability(
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ impl IntercrateAmbiguityCause {
&IntercrateAmbiguityCause::DownstreamCrate { ref trait_desc, ref self_desc } => {
let self_desc = if let &Some(ref ty) = self_desc {
format!(" for type `{}`", ty)
} else { "".to_string() };
} else { String::new() };
format!("downstream crates may implement trait `{}`{}", trait_desc, self_desc)
}
&IntercrateAmbiguityCause::UpstreamCrateUpdate { ref trait_desc, ref self_desc } => {
let self_desc = if let &Some(ref ty) = self_desc {
format!(" for type `{}`", ty)
} else { "".to_string() };
} else { String::new() };
format!("upstream crates may add new impl of trait `{}`{} \
in future versions",
trait_desc, self_desc)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/util/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ fn print_time_passes_entry_internal(what: &str, dur: Duration) {
let mb = n as f64 / 1_000_000.0;
format!("; rss: {}MB", mb.round() as usize)
}
None => "".to_owned(),
None => String::new(),
};
println!("{}time: {}{}\t{}",
" ".repeat(indentation),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/util/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ macro_rules! define_categories {
(format!("{:.2}",
(((hits as f32) / (total as f32)) * 100.0)), total.to_string())
} else {
("".into(), "".into())
(String::new(), String::new())
};

writeln!(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_borrowck/borrowck/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> {
.span_suggestion_short_with_applicability(
mut_span,
"remove this `mut`",
"".to_owned(),
String::new(),
Applicability::MachineApplicable)
.emit();
}
Expand Down
Loading