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 14 pull requests #66009

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cae8987
Don't print newline inside a node label
ecstatic-morse Oct 16, 2019
cbf6929
Use `DefId` to create globally unique basic block labels
ecstatic-morse Oct 16, 2019
3fa99f9
Use subgraphs to render multiple MIR bodies
ecstatic-morse Oct 16, 2019
cd3e9c4
Bless graphviz test with unique identifiers
ecstatic-morse Oct 16, 2019
58b67c8
Use structured suggestion for unnecessary bounds in type aliases
estebank Oct 28, 2019
afbb89e
Optimize long-linker-command-line test
tmiasko Oct 28, 2019
08ca236
Add lint for unnecessary parens around types
jack-t Oct 4, 2019
9bb9833
Add method to `Candidate` that determines its promotability rules
ecstatic-morse Oct 29, 2019
46b68b0
Emit errors in `promote_consts` when required promotion fails
ecstatic-morse Oct 29, 2019
122c6fe
Stop emitting error in `qualify_consts` if promotion fails
ecstatic-morse Oct 29, 2019
8995974
vxWorks: remove all code related to UNIX socket as it is not supporte…
BaoshanPang Oct 29, 2019
732842f
update submodules to rust-lang
steveklabnik Oct 30, 2019
627e3ef
Remove references to now unused `E0526`
ecstatic-morse Oct 30, 2019
bb1f4c4
doc: reword iter module example and mention other methods
tesuji Oct 30, 2019
e9e4836
Fix libunwind build: Define __LITTLE_ENDIAN__ for LE targets
Oct 30, 2019
c24a099
rustdoc: Resolve module-level doc references more locally
kinnison Oct 31, 2019
8bb5450
Fix incorrect diagnostics for expected type in E0271 with an associat…
ohadravid Oct 30, 2019
5dfb167
Create new error E0743
GuillaumeGomez Oct 31, 2019
fcbf77e
Update ui tests
GuillaumeGomez Oct 31, 2019
18391b6
Fix outdated rustdoc of Once::init_locking function
spastorino Oct 31, 2019
9c2f1dd
Add long error explanation for E0578
GuillaumeGomez Oct 16, 2019
bfe9c9e
update ui tests
GuillaumeGomez Oct 16, 2019
be0e381
Merge pull request #42 from Wind-River/master_003
n-salim Oct 31, 2019
255a713
Rollup merge of #65112 - jack-t:type-parens-lint, r=varkor
tmandry Oct 31, 2019
9f6420b
Rollup merge of #65459 - ecstatic-morse:graphviz-subgraph, r=estebank
tmandry Oct 31, 2019
19550e4
Rollup merge of #65471 - GuillaumeGomez:long-err-explanation-E0578, r…
tmandry Oct 31, 2019
ee58559
Rollup merge of #65857 - kinnison:kinnison/issue-55364, r=Manisheart,…
tmandry Oct 31, 2019
ab9e46d
Rollup merge of #65914 - estebank:type-alias-bounds-sugg, r=davidtwco
tmandry Oct 31, 2019
a6e1a73
Rollup merge of #65945 - tmiasko:long-linker-command-line, r=alexcric…
tmandry Oct 31, 2019
93ce064
Rollup merge of #65946 - ecstatic-morse:refactor-promotion2, r=eddyb
tmandry Oct 31, 2019
f82b14d
Rollup merge of #65960 - lzutao:doc-iter-example, r=Centril
tmandry Oct 31, 2019
71bba23
Rollup merge of #65963 - steveklabnik:update-submodules, r=Centril
tmandry Oct 31, 2019
9df994c
Rollup merge of #65972 - braiins:vkr-arm-panicking, r=alexcrichton
tmandry Oct 31, 2019
07b6b70
Rollup merge of #65977 - ohadravid:fix-incorrect-diagnostics-with-an-…
tmandry Oct 31, 2019
0682fc0
Rollup merge of #65995 - GuillaumeGomez:add-err-code-E0743, r=estebank
tmandry Oct 31, 2019
88ceb95
Rollup merge of #65997 - spastorino:fix-init_locking-rustdoc, r=Mark-…
tmandry Oct 31, 2019
1c5156a
Rollup merge of #66005 - Wind-River:master_base, r=alexcrichton
tmandry Oct 31, 2019
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
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
url = https://github.com/rust-lang/rust-installer.git
[submodule "src/doc/nomicon"]
path = src/doc/nomicon
url = https://github.com/rust-lang-nursery/nomicon.git
url = https://github.com/rust-lang/nomicon.git
[submodule "src/tools/cargo"]
path = src/tools/cargo
url = https://github.com/rust-lang/cargo.git
[submodule "src/doc/reference"]
path = src/doc/reference
url = https://github.com/rust-lang-nursery/reference.git
url = https://github.com/rust-lang/reference.git
[submodule "src/doc/book"]
path = src/doc/book
url = https://github.com/rust-lang/book.git
Expand All @@ -36,7 +36,7 @@
url = https://github.com/rust-lang/rustc-guide.git
[submodule "src/doc/edition-guide"]
path = src/doc/edition-guide
url = https://github.com/rust-lang-nursery/edition-guide.git
url = https://github.com/rust-lang/edition-guide.git
[submodule "src/llvm-project"]
path = src/llvm-project
url = https://github.com/rust-lang/llvm-project.git
Expand Down
35 changes: 14 additions & 21 deletions src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,26 +118,16 @@
//!
//! let mut counter = Counter::new();
//!
//! let x = counter.next().unwrap();
//! println!("{}", x);
//!
//! let x = counter.next().unwrap();
//! println!("{}", x);
//!
//! let x = counter.next().unwrap();
//! println!("{}", x);
//!
//! let x = counter.next().unwrap();
//! println!("{}", x);
//!
//! let x = counter.next().unwrap();
//! println!("{}", x);
//! assert_eq!(counter.next(), Some(1));
//! assert_eq!(counter.next(), Some(2));
//! assert_eq!(counter.next(), Some(3));
//! assert_eq!(counter.next(), Some(4));
//! assert_eq!(counter.next(), Some(5));
//! assert_eq!(counter.next(), None);
//! ```
//!
//! This will print `1` through `5`, each on their own line.
//!
//! Calling `next()` this way gets repetitive. Rust has a construct which can
//! call `next()` on your iterator, until it reaches `None`. Let's go over that
//! Calling [`next`] this way gets repetitive. Rust has a construct which can
//! call [`next`] on your iterator, until it reaches `None`. Let's go over that
//! next.
//!
//! Also note that `Iterator` provides a default implementation of methods such as `nth` and `fold`
Expand Down Expand Up @@ -253,20 +243,23 @@
//! ```
//!
//! The idiomatic way to write a [`map`] for its side effects is to use a
//! `for` loop instead:
//! `for` loop or call the [`for_each`] method:
//!
//! ```
//! let v = vec![1, 2, 3, 4, 5];
//!
//! v.iter().for_each(|x| println!("{}", x));
//! // or
//! for x in &v {
//! println!("{}", x);
//! }
//! ```
//!
//! [`map`]: trait.Iterator.html#method.map
//! [`for_each`]: trait.Iterator.html#method.for_each
//!
//! The two most common ways to evaluate an iterator are to use a `for` loop
//! like this, or using the [`collect`] method to produce a new collection.
//! Another common way to evaluate an iterator is to use the [`collect`]
//! method to produce a new collection.
//!
//! [`collect`]: trait.Iterator.html#method.collect
//!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
&self,
arg: &'tcx hir::Ty,
br: &ty::BoundRegion,
) -> Option<(&'tcx hir::Ty)> {
) -> Option<&'tcx hir::Ty> {
let mut nested_visitor = FindNestedTypeVisitor {
tcx: self.tcx(),
bound_region: *br,
Expand Down
23 changes: 18 additions & 5 deletions src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,26 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
0,
&mut obligations
);

debug!("report_projection_error obligation.cause={:?} obligation.param_env={:?}",
obligation.cause, obligation.param_env);

debug!("report_projection_error normalized_ty={:?} data.ty={:?}",
normalized_ty, data.ty);

let is_normalized_ty_expected = match &obligation.cause.code {
ObligationCauseCode::ItemObligation(_) |
ObligationCauseCode::BindingObligation(_, _) |
ObligationCauseCode::ObjectCastObligation(_) => false,
_ => true,
};

if let Err(error) = self.at(&obligation.cause, obligation.param_env)
.eq(normalized_ty, data.ty)
.eq_exp(is_normalized_ty_expected, normalized_ty, data.ty)
{
values = Some(infer::ValuePairs::Types(ExpectedFound {
expected: normalized_ty,
found: data.ty,
}));
values = Some(infer::ValuePairs::Types(
ExpectedFound::new(is_normalized_ty_expected, normalized_ty, data.ty)));

err_buf = error;
err = &err_buf;
}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_data_structures/owning_ref/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,14 +1046,14 @@ unsafe impl<O, T: ?Sized> CloneStableAddress for OwningRef<O, T>
where O: CloneStableAddress {}

unsafe impl<O, T: ?Sized> Send for OwningRef<O, T>
where O: Send, for<'a> (&'a T): Send {}
where O: Send, for<'a> &'a T: Send {}
unsafe impl<O, T: ?Sized> Sync for OwningRef<O, T>
where O: Sync, for<'a> (&'a T): Sync {}
where O: Sync, for<'a> &'a T: Sync {}

unsafe impl<O, T: ?Sized> Send for OwningRefMut<O, T>
where O: Send, for<'a> (&'a mut T): Send {}
where O: Send, for<'a> &'a mut T: Send {}
unsafe impl<O, T: ?Sized> Sync for OwningRefMut<O, T>
where O: Sync, for<'a> (&'a mut T): Sync {}
where O: Sync, for<'a> &'a mut T: Sync {}

impl Debug for dyn Erased {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_data_structures/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,10 @@ impl<T> Once<T> {
assert!(self.try_set(value).is_none());
}

/// Tries to initialize the inner value by calling the closure while ensuring that no-one else
/// can access the value in the mean time by holding a lock for the duration of the closure.
/// If the value was already initialized the closure is not called and `false` is returned,
/// otherwise if the value from the closure initializes the inner value, `true` is returned
/// Initializes the inner value if it wasn't already done by calling the provided closure. It
/// ensures that no-one else can access the value in the mean time by holding a lock for the
/// duration of the closure.
/// A reference to the inner value is returned.
#[inline]
pub fn init_locking<F: FnOnce() -> T>(&self, f: F) -> &T {
{
Expand Down
17 changes: 13 additions & 4 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds {
.map(|pred| pred.span()).collect();
let mut err = cx.struct_span_lint(TYPE_ALIAS_BOUNDS, spans,
"where clauses are not enforced in type aliases");
err.help("the clause will not be checked when the type alias is used, \
and should be removed");
err.span_suggestion(
type_alias_generics.where_clause.span_for_predicates_or_empty_place(),
"the clause will not be checked when the type alias is used, and should be removed",
String::new(),
Applicability::MachineApplicable,
);
if !suggested_changing_assoc_types {
TypeAliasBounds::suggest_changing_assoc_types(ty, &mut err);
suggested_changing_assoc_types = true;
Expand All @@ -1136,14 +1140,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds {
// The parameters must not have bounds
for param in type_alias_generics.params.iter() {
let spans: Vec<_> = param.bounds.iter().map(|b| b.span()).collect();
let suggestion = spans.iter().map(|sp| {
let start = param.span.between(*sp); // Include the `:` in `T: Bound`.
(start.to(*sp), String::new())
}).collect();
if !spans.is_empty() {
let mut err = cx.struct_span_lint(
TYPE_ALIAS_BOUNDS,
spans,
"bounds on generic parameters are not enforced in type aliases",
);
err.help("the bound will not be checked when the type alias is used, \
and should be removed");
let msg = "the bound will not be checked when the type alias is used, \
and should be removed";
err.multipart_suggestion(&msg, suggestion, Applicability::MachineApplicable);
if !suggested_changing_assoc_types {
TypeAliasBounds::suggest_changing_assoc_types(ty, &mut err);
suggested_changing_assoc_types = true;
Expand Down
19 changes: 19 additions & 0 deletions src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,25 @@ impl EarlyLintPass for UnusedParens {
fn check_arm(&mut self, cx: &EarlyContext<'_>, arm: &ast::Arm) {
self.check_unused_parens_pat(cx, &arm.pat, false, false);
}

fn check_ty(&mut self, cx: &EarlyContext<'_>, ty: &ast::Ty) {
if let &ast::TyKind::Paren(ref r) = &ty.kind {
match &r.kind {
&ast::TyKind::TraitObject(..) => {}
&ast::TyKind::ImplTrait(_, ref bounds) if bounds.len() > 1 => {}
_ => {
let pattern_text = if let Ok(snippet) = cx.sess().source_map()
.span_to_snippet(ty.span) {
snippet
} else {
pprust::ty_to_string(ty)
};

Self::remove_outer_parens(cx, ty.span, &pattern_text, "type", (false, false));
}
}
}
}
}

declare_lint! {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/prefixes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(super) struct Prefixes<'cx, 'tcx> {
body: &'cx Body<'tcx>,
tcx: TyCtxt<'tcx>,
kind: PrefixSet,
next: Option<(PlaceRef<'cx, 'tcx>)>,
next: Option<PlaceRef<'cx, 'tcx>>,
}

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2545,7 +2545,7 @@ There are some known bugs that trigger this message.
// E0471, // constant evaluation error (in pattern)
// E0385, // {} in an aliasable location
E0521, // borrowed data escapes outside of closure
E0526, // shuffle indices are not constant
// E0526, // shuffle indices are not constant
E0594, // cannot assign to {}
// E0598, // lifetime of {} is too short to guarantee its contents can be...
E0625, // thread-local statics cannot be accessed at compile-time
Expand Down
29 changes: 23 additions & 6 deletions src/librustc_mir/transform/promote_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ pub enum Candidate {
Argument { bb: BasicBlock, index: usize },
}

impl Candidate {
/// Returns `true` if we should use the "explicit" rules for promotability for this `Candidate`.
fn forces_explicit_promotion(&self) -> bool {
match self {
Candidate::Ref(_) |
Candidate::Repeat(_) => false,
Candidate::Argument { .. } => true,
}
}
}

fn args_required_const(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Vec<usize>> {
let attrs = tcx.get_attrs(def_id);
let attr = attrs.iter().find(|a| a.check_name(sym::rustc_args_required_const))?;
Expand Down Expand Up @@ -727,16 +738,22 @@ pub fn validate_candidates(
};

candidates.iter().copied().filter(|&candidate| {
validator.explicit = match candidate {
Candidate::Ref(_) |
Candidate::Repeat(_) => false,
Candidate::Argument { .. } => true,
};
validator.explicit = candidate.forces_explicit_promotion();

// FIXME(eddyb) also emit the errors for shuffle indices
// and `#[rustc_args_required_const]` arguments here.

validator.validate_candidate(candidate).is_ok()
let is_promotable = validator.validate_candidate(candidate).is_ok();
match candidate {
Candidate::Argument { bb, index } if !is_promotable => {
let span = body[bb].terminator().source_info.span;
let msg = format!("argument {} is required to be a constant", index + 1);
tcx.sess.span_err(span, &msg);
}
_ => ()
}

is_promotable
}).collect()
}

Expand Down
14 changes: 3 additions & 11 deletions src/librustc_mir/transform/qualify_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1606,20 +1606,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
// This is not a problem, because the argument explicitly
// requests constness, in contrast to regular promotion
// which happens even without the user requesting it.
// We can error out with a hard error if the argument is not
// constant here.
//
// `promote_consts` is responsible for emitting the error if
// the argument is not promotable.
if !IsNotPromotable::in_operand(self, arg) {
debug!("visit_terminator_kind: candidate={:?}", candidate);
self.promotion_candidates.push(candidate);
} else {
if is_shuffle {
span_err!(self.tcx.sess, self.span, E0526,
"shuffle indices are not constant");
} else {
self.tcx.sess.span_err(self.span,
&format!("argument {} is required to be a constant",
i + 1));
}
}
}
}
Expand Down
Loading