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 #52344

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
de2ecea
Provide llvm-strip in llvm-tools component
crlf0710 Jul 1, 2018
6035534
Implement `Option::replace` in the core library
Kerollmops Jul 4, 2018
2c2add6
Update std::ascii::ASCIIExt deprecation notes
zajlerke Jul 8, 2018
af87a35
Add a basic test to `Option::replace`
Jul 9, 2018
c8f0e6f
Fix the documentation of `Option::replace`
Jul 9, 2018
5336df7
Add UI tests for diagnostics comparing types
glandium Jul 11, 2018
b5c2b79
Don't display default generic parameters in diagnostics that compare …
glandium Jul 11, 2018
0d7b2e6
Deny bare trait objects in src/librustc_save_analysis
ljedrz Jul 12, 2018
f29ac5a
Deny bare trait objects in librustc_typeck
ljedrz Jul 12, 2018
0878453
Deny bare trait objects in src/libserialize
ljedrz Jul 12, 2018
21d9ac1
Deny bare trait objects in librustc_target and libtest
ljedrz Jul 12, 2018
5058af7
Deny bare trait objects in the rest of rust
ljedrz Jul 12, 2018
e93de95
Fix ICE when using a pointer cast as array size
varkor Jul 12, 2018
4c340a2
Backport 1.27.1 release notes to master
Mark-Simulacrum Jul 12, 2018
72f096b
Resolve FIXME(#27942)
ljedrz Jul 12, 2018
9ead0d8
Update llvm-rebuild-trigger in light of LLVM 7 upgrade
varkor Jul 12, 2018
4f4e91a
task: remove wrong comments about non-existent LocalWake trait
seanmonstar Jul 12, 2018
8cc4fd6
dead-code lint: say "constructed", "called" for structs, functions
zackmdavis Jul 13, 2018
f8eb9a6
Add `ref mut` suggestion test
ashtneoi Jul 11, 2018
52d6ae8
Reimplement some "add `mut`" suggestions under NLL
ashtneoi Jul 11, 2018
6fd1a9f
Don't try to suggest `ref mut` for implicit `ref`
ashtneoi Jul 11, 2018
b8b04f6
Put the two halves of suggest_ampmut back together
ashtneoi Jul 11, 2018
73a979a
Simplify match expression
ashtneoi Jul 11, 2018
77d5f39
Also test `&mut self` suggestion
ashtneoi Jul 11, 2018
246caea
fix wrong replacing
csmoe May 31, 2018
4e5d228
update test
csmoe May 31, 2018
1662daa
lint with ref_span
csmoe Jun 1, 2018
af5edc3
replace ref
csmoe Jun 1, 2018
212da12
update test
csmoe Jun 1, 2018
8932684
add nll stderr
csmoe Jun 3, 2018
7a70140
span_suggestion
csmoe Jun 14, 2018
323df7b
Bless tests and update ERROR
ashtneoi Jul 12, 2018
531a68c
Factor out suggest_ref_mut; use it in rustc_borrowck
ashtneoi Jul 12, 2018
1ed8619
Bless one more test
ashtneoi Jul 13, 2018
030d60c
Rollup merge of #51962 - crlf0710:patch-2, r=alexcrichton
Mark-Simulacrum Jul 13, 2018
20176fe
Rollup merge of #52003 - Kerollmops:option-replace, r=Kimundi
Mark-Simulacrum Jul 13, 2018
b16bad6
Rollup merge of #52156 - zajlerke:update-deprecation-notice, r=Kimundi
Mark-Simulacrum Jul 13, 2018
7b75c00
Rollup merge of #52242 - ashtneoi:suggest-ref-mut, r=pnkfelix
Mark-Simulacrum Jul 13, 2018
24738ba
Rollup merge of #52244 - glandium:issue52097, r=estebank
Mark-Simulacrum Jul 13, 2018
464ed4d
Rollup merge of #52290 - ljedrz:dyn_librustc_save_analysis, r=cramertj
Mark-Simulacrum Jul 13, 2018
76eed24
Rollup merge of #52293 - ljedrz:dyn_librustc_typeck, r=estebank
Mark-Simulacrum Jul 13, 2018
90a21a1
Rollup merge of #52299 - ljedrz:dyn_libserialize, r=cramertj
Mark-Simulacrum Jul 13, 2018
6167181
Rollup merge of #52300 - ljedrz:dyn_target_test, r=Mark-Simulacrum
Mark-Simulacrum Jul 13, 2018
cf5eebf
Rollup merge of #52302 - ljedrz:dyn_futureproofing, r=cramertj
Mark-Simulacrum Jul 13, 2018
fed8105
Rollup merge of #52310 - Mark-Simulacrum:release-notes-backport-from-…
Mark-Simulacrum Jul 13, 2018
102ed77
Rollup merge of #52314 - varkor:issue-52023, r=oli-obk
Mark-Simulacrum Jul 13, 2018
82da5ce
Rollup merge of #52315 - ljedrz:FIXME_#27942, r=petrochenkov
Mark-Simulacrum Jul 13, 2018
0bba879
Rollup merge of #52316 - seanmonstar:waker-unsafety, r=cramertj
Mark-Simulacrum Jul 13, 2018
a1b9b6a
Rollup merge of #52322 - varkor:llvm-7-rebuild-trigger, r=alexcrichton
Mark-Simulacrum Jul 13, 2018
9dff778
Rollup merge of #52332 - zackmdavis:dead_code_lint_should_say_2_elect…
Mark-Simulacrum Jul 13, 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
23 changes: 23 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,29 @@ Compatibility Notes
[`{Any + Send + Sync}::downcast_ref`]: https://doc.rust-lang.org/std/any/trait.Any.html#method.downcast_ref-2
[`{Any + Send + Sync}::is`]: https://doc.rust-lang.org/std/any/trait.Any.html#method.is-2

Version 1.27.1 (2018-07-10)
===========================

Security Notes
--------------

- rustdoc would execute plugins in the /tmp/rustdoc/plugins directory
when running, which enabled executing code as some other user on a
given machine. This release fixes that vulnerability; you can read
more about this on the [blog][rustdoc-sec]. The associated CVE is [CVE-2018-1000622].

Thank you to Red Hat for responsibily disclosing this vulnerability to us.

Compatibility Notes
-------------------

- The borrow checker was fixed to avoid an additional potential unsoundness when using
match ergonomics: [#51415][51415], [#49534][49534].

[51415]: https://github.com/rust-lang/rust/issues/51415
[49534]: https://github.com/rust-lang/rust/issues/49534
[rustdoc-sec]: https://blog.rust-lang.org/2018/07/06/security-advisory-for-rustdoc.html
[CVE-2018-1000622]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=%20CVE-2018-1000622

Version 1.27.0 (2018-06-21)
==========================
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ const LLVM_TOOLS: &[&str] = &[
"llvm-objcopy", // used to transform ELFs into binary format which flashing tools consume
"llvm-objdump", // used to disassemble programs
"llvm-profdata", // used to inspect and merge files generated by profiles
"llvm-size", // prints the size of the linker sections of a program
"llvm-size", // used to prints the size of the linker sections of a program
"llvm-strip", // used to discard symbols from binary files to reduce their size
];

/// A structure representing a Rust compiler.
Expand Down
2 changes: 2 additions & 0 deletions src/build_helper/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(bare_trait_objects)]

use std::fs::File;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
Expand Down
1 change: 1 addition & 0 deletions src/liballoc_jemalloc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#![no_std]
#![allow(unused_attributes)]
#![deny(bare_trait_objects)]
#![unstable(feature = "alloc_jemalloc",
reason = "implementation detail of std, does not provide any public API",
issue = "0")]
Expand Down
1 change: 1 addition & 0 deletions src/liballoc_system/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#![no_std]
#![allow(unused_attributes)]
#![deny(bare_trait_objects)]
#![unstable(feature = "alloc_system",
reason = "this library is unlikely to be stabilized in its current \
form or name",
Expand Down
1 change: 1 addition & 0 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#![cfg_attr(test, feature(test))]

#![allow(deprecated)]
#![deny(bare_trait_objects)]

extern crate alloc;
extern crate rustc_data_structures;
Expand Down
27 changes: 27 additions & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,33 @@ impl<T> Option<T> {
pub fn take(&mut self) -> Option<T> {
mem::replace(self, None)
}

/// Replaces the actual value in the option by the value given in parameter,
/// returning the old value if present,
/// leaving a [`Some`] in its place without deinitializing either one.
///
/// [`Some`]: #variant.Some
///
/// # Examples
///
/// ```
/// #![feature(option_replace)]
///
/// let mut x = Some(2);
/// let old = x.replace(5);
/// assert_eq!(x, Some(5));
/// assert_eq!(old, Some(2));
///
/// let mut x = None;
/// let old = x.replace(3);
/// assert_eq!(x, Some(3));
/// assert_eq!(old, None);
/// ```
#[inline]
#[unstable(feature = "option_replace", issue = "51998")]
pub fn replace(&mut self, value: T) -> Option<T> {
mem::replace(self, Some(value))
}
}

impl<'a, T: Clone> Option<&'a T> {
Expand Down
8 changes: 3 additions & 5 deletions src/libcore/task/wake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ impl LocalWaker {
/// but you otherwise shouldn't call it directly.
///
/// If you're working with the standard library then it's recommended to
/// use the `LocalWaker::from` function instead which works with the safe
/// `Rc` type and the safe `LocalWake` trait.
/// use the `local_waker_from_nonlocal` or `local_waker` to convert a `Waker`
/// into a `LocalWaker`.
///
/// For this function to be used safely, it must be sound to call `inner.wake_local()`
/// on the current thread.
Expand Down Expand Up @@ -197,9 +197,7 @@ impl Drop for LocalWaker {
/// customization.
///
/// When using `std`, a default implementation of the `UnsafeWake` trait is provided for
/// `Arc<T>` where `T: Wake` and `Rc<T>` where `T: LocalWake`.
///
/// Although the methods on `UnsafeWake` take pointers rather than references,
/// `Arc<T>` where `T: Wake`.
pub unsafe trait UnsafeWake: Send + Sync {
/// Creates a clone of this `UnsafeWake` and stores it behind a `Waker`.
///
Expand Down
1 change: 1 addition & 0 deletions src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#![feature(reverse_bits)]
#![feature(iterator_find_map)]
#![feature(slice_internals)]
#![feature(option_replace)]

extern crate core;
extern crate test;
Expand Down
15 changes: 15 additions & 0 deletions src/libcore/tests/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,18 @@ fn test_try() {
}
assert_eq!(try_option_err(), Err(NoneError));
}

#[test]
fn test_replace() {
let mut x = Some(2);
let old = x.replace(5);

assert_eq!(x, Some(5));
assert_eq!(old, Some(2));

let mut x = None;
let old = x.replace(3);

assert_eq!(x, Some(3));
assert_eq!(old, None);
}
2 changes: 2 additions & 0 deletions src/libfmt_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
//! Parsing does not happen at runtime: structures of `std::fmt::rt` are
//! generated instead.

#![deny(bare_trait_objects)]

#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
Expand Down
2 changes: 2 additions & 0 deletions src/libgraphviz/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@
//!
//! * [DOT language](http://www.graphviz.org/doc/info/lang.html)

#![deny(bare_trait_objects)]

#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
Expand Down
1 change: 1 addition & 0 deletions src/libpanic_abort/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
#![panic_runtime]
#![allow(unused_features)]
#![deny(bare_trait_objects)]

#![feature(core_intrinsics)]
#![feature(libc)]
Expand Down
1 change: 1 addition & 0 deletions src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
//! See [the book](../book/first-edition/procedural-macros.html) for more.

#![stable(feature = "proc_macro_lib", since = "1.15.0")]
#![deny(bare_trait_objects)]
#![deny(missing_docs)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
Expand Down
1 change: 1 addition & 0 deletions src/libprofiler_builtins/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
reason = "internal implementation detail of rustc right now",
issue = "0")]
#![allow(unused_features)]
#![deny(bare_trait_objects)]
#![feature(staged_api)]
92 changes: 64 additions & 28 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ use super::{InferCtxt, RegionVariableOrigin, SubregionOrigin, TypeTrace, ValuePa
use super::region_constraints::GenericKind;
use super::lexical_region_resolve::RegionResolutionError;

use std::fmt;
use std::{cmp, fmt};
use hir;
use hir::map as hir_map;
use hir::def_id::DefId;
use middle::region;
use traits::{ObligationCause, ObligationCauseCode};
use ty::{self, Region, Ty, TyCtxt, TypeFoldable, TypeVariants};
use ty::{self, subst::Subst, Region, Ty, TyCtxt, TypeFoldable, TypeVariants};
use ty::error::TypeError;
use syntax::ast::DUMMY_NODE_ID;
use syntax_pos::{Pos, Span};
Expand Down Expand Up @@ -193,32 +193,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

let scope = region.free_region_binding_scope(self);
let node = self.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID);
let unknown;
let tag = match self.hir.find(node) {
Some(hir_map::NodeBlock(_)) | Some(hir_map::NodeExpr(_)) => "body",
Some(hir_map::NodeItem(it)) => Self::item_scope_tag(&it),
Some(hir_map::NodeTraitItem(it)) => Self::trait_item_scope_tag(&it),
Some(hir_map::NodeImplItem(it)) => Self::impl_item_scope_tag(&it),

// this really should not happen, but it does:
// FIXME(#27942)
Some(_) => {
unknown = format!(
"unexpected node ({}) for scope {:?}. \
Please report a bug.",
self.hir.node_to_string(node),
scope
);
&unknown
}
None => {
unknown = format!(
"unknown node for scope {:?}. \
Please report a bug.",
scope
);
&unknown
}
_ => unreachable!()
};
let (prefix, span) = match *region {
ty::ReEarlyBound(ref br) => {
Expand Down Expand Up @@ -672,6 +652,43 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
}
}

/// For generic types with parameters with defaults, remove the parameters corresponding to
/// the defaults. This repeats a lot of the logic found in `PrintContext::parameterized`.
fn strip_generic_default_params(
&self,
def_id: DefId,
substs: &ty::subst::Substs<'tcx>
) -> &'tcx ty::subst::Substs<'tcx> {
let generics = self.tcx.generics_of(def_id);
let mut num_supplied_defaults = 0;
let mut type_params = generics.params.iter().rev().filter_map(|param| match param.kind {
ty::GenericParamDefKind::Lifetime => None,
ty::GenericParamDefKind::Type { has_default, .. } => {
Some((param.def_id, has_default))
}
}).peekable();
let has_default = {
let has_default = type_params.peek().map(|(_, has_default)| has_default);
*has_default.unwrap_or(&false)
};
if has_default {
let types = substs.types().rev();
for ((def_id, has_default), actual) in type_params.zip(types) {
if !has_default {
break;
}
if self.tcx.type_of(def_id).subst(self.tcx, substs) != actual {
break;
}
num_supplied_defaults += 1;
}
}
let len = generics.params.len();
let mut generics = generics.clone();
generics.params.truncate(len - num_supplied_defaults);
substs.truncate_to(self.tcx, &generics)
}

/// Compare two given types, eliding parts that are the same between them and highlighting
/// relevant differences, and return two representation of those types for highlighted printing.
fn cmp(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) -> (DiagnosticStyledString, DiagnosticStyledString) {
Expand Down Expand Up @@ -713,6 +730,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {

match (&t1.sty, &t2.sty) {
(&ty::TyAdt(def1, sub1), &ty::TyAdt(def2, sub2)) => {
let sub_no_defaults_1 = self.strip_generic_default_params(def1.did, sub1);
let sub_no_defaults_2 = self.strip_generic_default_params(def2.did, sub2);
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
let path1 = self.tcx.item_path_str(def1.did.clone());
let path2 = self.tcx.item_path_str(def2.did.clone());
Expand All @@ -728,8 +747,19 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
values.0.push_normal(path1);
values.1.push_normal(path2);

// Avoid printing out default generic parameters that are common to both
// types.
let len1 = sub_no_defaults_1.len();
let len2 = sub_no_defaults_2.len();
let common_len = cmp::min(len1, len2);
let remainder1: Vec<_> = sub1.types().skip(common_len).collect();
let remainder2: Vec<_> = sub2.types().skip(common_len).collect();
let common_default_params =
remainder1.iter().rev().zip(remainder2.iter().rev())
.filter(|(a, b)| a == b).count();
let len = sub1.len() - common_default_params;

// Only draw `<...>` if there're lifetime/type arguments.
let len = sub1.len();
if len > 0 {
values.0.push_normal("<");
values.1.push_normal("<");
Expand Down Expand Up @@ -774,7 +804,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// ^ elided type as this type argument was the same in both sides
let type_arguments = sub1.types().zip(sub2.types());
let regions_len = sub1.regions().collect::<Vec<_>>().len();
for (i, (ta1, ta2)) in type_arguments.enumerate() {
for (i, (ta1, ta2)) in type_arguments.take(len).enumerate() {
let i = i + regions_len;
if ta1 == ta2 {
values.0.push_normal("_");
Expand Down Expand Up @@ -804,7 +834,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
&mut values.0,
&mut values.1,
path1.clone(),
sub1,
sub_no_defaults_1,
path2.clone(),
&t2,
).is_some()
Expand All @@ -816,8 +846,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// Bar<Qux>
// Foo<Bar<Qux>>
// ------- this type argument is exactly the same as the other type
if self.cmp_type_arg(&mut values.1, &mut values.0, path2, sub2, path1, &t1)
.is_some()
if self.cmp_type_arg(
&mut values.1,
&mut values.0,
path2,
sub_no_defaults_2,
path1,
&t1,
).is_some()
{
return values;
}
Expand Down
10 changes: 8 additions & 2 deletions src/librustc/middle/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,17 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
hir::ItemImpl(..) => self.tcx.sess.codemap().def_span(item.span),
_ => item.span,
};
let participle = match item.node {
hir::ItemFn(..) => "called",
hir::ItemStruct(..) => "constructed",
_ => "used"
};
self.warn_dead_code(
item.id,
span,
item.name,
item.node.descriptive_variant(),
"used",
participle,
);
} else {
// Only continue if we didn't warn
Expand Down Expand Up @@ -622,7 +627,8 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
hir::ImplItemKind::Method(_, body_id) => {
if !self.symbol_is_live(impl_item.id, None) {
let span = self.tcx.sess.codemap().def_span(impl_item.span);
self.warn_dead_code(impl_item.id, span, impl_item.ident.name, "method", "used");
self.warn_dead_code(impl_item.id, span, impl_item.ident.name,
"method", "called");
}
self.visit_nested_body(body_id)
}
Expand Down
Loading