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

[beta] Rollup backports #59235

Merged
merged 25 commits into from Mar 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
877c5e9
[BETA] Update cargo
ehuss Mar 15, 2019
b72af83
Include bounds from promoted constants in NLL
matthewjasper Jan 17, 2019
1824067
Remove unnecessary parameter
matthewjasper Jan 17, 2019
e2a0a83
Handle type annotations in promoted MIR correctly
matthewjasper Feb 27, 2019
11bd998
Temporarily emulate the (accidentally) omitted recursion during impl …
pnkfelix Feb 20, 2019
a35c8e8
Unit (and regression) tests for warning cycle code.
pnkfelix Feb 22, 2019
1d6d40b
Revised warning-downgrade strategy for nested impl trait.
pnkfelix Mar 11, 2019
7f31bab
Test illustrating that the nested_impl_trait lint should only catch s…
pnkfelix Mar 11, 2019
8df3fb6
Addressed review feedback regarding comment phrasing.
pnkfelix Mar 12, 2019
4e1c03b
Don't promote function calls to nonpromotable things
oli-obk Feb 27, 2019
eedebbc
Schedule the demolition of `IsNotPromotable`
oli-obk Mar 1, 2019
ad293f1
Make migrate mode work at item level granularity
matthewjasper Feb 27, 2019
363024d
Expand where negative supertrait specific error is shown
estebank Mar 1, 2019
d954246
Do not panic on missing close paren
estebank Mar 2, 2019
8470916
Bail when encountering a second unexpected token in the same span
estebank Mar 2, 2019
d60f22c
Emit unclosed delimiters during recovery
estebank Mar 2, 2019
a5c464a
Reduce test case
estebank Mar 2, 2019
d5b3606
Panic when unmatched delimiters aren't emitted
estebank Mar 3, 2019
d21b852
Emit missing unclosed delimiter errors
estebank Mar 3, 2019
a460b4b
Collect unclosed delimiters in parent parser
estebank Mar 3, 2019
51c47f3
Always emit mismatched delim errors, never panic
estebank Mar 3, 2019
e808e1e
Add regression test for #58886
estebank Mar 4, 2019
78554ed
Simplify code
estebank Mar 4, 2019
159cc95
Rely on drop to emit unclosed delims
estebank Mar 7, 2019
0e9e6ec
Rollup merge of #59217 - ehuss:update-beta-cargo, r=alexcrichton
pietroalbini Mar 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/librustc/lint/builtin.rs
Expand Up @@ -386,6 +386,12 @@ declare_lint! {
"ambiguous associated items"
}

declare_lint! {
pub NESTED_IMPL_TRAIT,
Warn,
"nested occurrence of `impl Trait` type"
}

/// Does nothing as a lint pass, but registers some `Lint`s
/// that are used by other parts of the compiler.
#[derive(Copy, Clone)]
Expand Down Expand Up @@ -457,6 +463,7 @@ impl LintPass for HardwiredLints {
parser::ILL_FORMED_ATTRIBUTE_INPUT,
DEPRECATED_IN_FUTURE,
AMBIGUOUS_ASSOCIATED_ITEMS,
NESTED_IMPL_TRAIT,
)
}
}
Expand All @@ -474,6 +481,7 @@ pub enum BuiltinLintDiagnostics {
ElidedLifetimesInPaths(usize, Span, bool, Span, String),
UnknownCrateTypes(Span, String, String),
UnusedImports(String, Vec<(Span, String)>),
NestedImplTrait { outer_impl_trait_span: Span, inner_impl_trait_span: Span },
}

impl BuiltinLintDiagnostics {
Expand Down Expand Up @@ -564,6 +572,12 @@ impl BuiltinLintDiagnostics {
);
}
}
BuiltinLintDiagnostics::NestedImplTrait {
outer_impl_trait_span, inner_impl_trait_span
} => {
db.span_label(outer_impl_trait_span, "outer `impl Trait`");
db.span_label(inner_impl_trait_span, "nested `impl Trait` here");
}
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/librustc/middle/expr_use_visitor.rs
Expand Up @@ -83,6 +83,9 @@ pub trait Delegate<'tcx> {
assignment_span: Span,
assignee_cmt: &mc::cmt_<'tcx>,
mode: MutateMode);

// A nested closure or generator - only one layer deep.
fn nested_body(&mut self, _body_id: hir::BodyId) {}
}

#[derive(Copy, Clone, PartialEq, Debug)]
Expand Down Expand Up @@ -532,8 +535,9 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
self.consume_expr(&base);
}

hir::ExprKind::Closure(.., fn_decl_span, _) => {
self.walk_captures(expr, fn_decl_span)
hir::ExprKind::Closure(_, _, body_id, fn_decl_span, _) => {
self.delegate.nested_body(body_id);
self.walk_captures(expr, fn_decl_span);
}

hir::ExprKind::Box(ref base) => {
Expand Down
18 changes: 18 additions & 0 deletions src/librustc_borrowck/borrowck/gather_loans/mod.rs
Expand Up @@ -152,6 +152,24 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> {
.node_type(self.bccx.tcx.hir().node_to_hir_id(id));
gather_moves::gather_decl(self.bccx, &self.move_data, id, ty);
}

fn nested_body(&mut self, body_id: hir::BodyId) {
debug!("nested_body(body_id={:?})", body_id);
// rust-lang/rust#58776: MIR and AST borrow check disagree on where
// certain closure errors are reported. As such migrate borrowck has to
// operate at the level of items, rather than bodies. Check if the
// contained closure had any errors and set `signalled_any_error` if it
// has.
let bccx = self.bccx;
if bccx.tcx.migrate_borrowck() {
if let SignalledError::NoErrorsSeen = bccx.signalled_any_error.get() {
let closure_def_id = bccx.tcx.hir().body_owner_def_id(body_id);
debug!("checking closure: {:?}", closure_def_id);

bccx.signalled_any_error.set(bccx.tcx.borrowck(closure_def_id).signalled_any_error);
}
}
}
}

/// Implements the A-* rules in README.md.
Expand Down
5 changes: 5 additions & 0 deletions src/librustc_lint/lib.rs
Expand Up @@ -353,6 +353,11 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
reference: "issue #57593 <https://github.com/rust-lang/rust/issues/57593>",
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(NESTED_IMPL_TRAIT),
reference: "issue #59014 <https://github.com/rust-lang/rust/issues/59014>",
edition: None,
},
]);

// Register renamed and removed lints.
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_metadata/cstore_impl.rs
Expand Up @@ -439,8 +439,8 @@ impl cstore::CStore {

let source_file = sess.parse_sess.source_map().new_source_file(source_name, def.body);
let local_span = Span::new(source_file.start_pos, source_file.end_pos, NO_EXPANSION);
let (body, errors) = source_file_to_stream(&sess.parse_sess, source_file, None);
emit_unclosed_delims(&errors, &sess.diagnostic());
let (body, mut errors) = source_file_to_stream(&sess.parse_sess, source_file, None);
emit_unclosed_delims(&mut errors, &sess.diagnostic());

// Mark the attrs as used
let attrs = data.get_item_attrs(id.index, sess);
Expand Down
28 changes: 5 additions & 23 deletions src/librustc_mir/borrow_check/mod.rs
Expand Up @@ -329,30 +329,12 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
// When borrowck=migrate, check if AST-borrowck would
// error on the given code.

// rust-lang/rust#55492: loop over parents to ensure that
// errors that AST-borrowck only detects in some parent of
// a closure still allows NLL to signal an error.
let mut curr_def_id = def_id;
let signalled_any_error = loop {
match tcx.borrowck(curr_def_id).signalled_any_error {
SignalledError::NoErrorsSeen => {
// keep traversing (and borrow-checking) parents
}
SignalledError::SawSomeError => {
// stop search here
break SignalledError::SawSomeError;
}
}

if tcx.is_closure(curr_def_id) {
curr_def_id = tcx.parent_def_id(curr_def_id)
.expect("a closure must have a parent_def_id");
} else {
break SignalledError::NoErrorsSeen;
}
};
// rust-lang/rust#55492, rust-lang/rust#58776 check the base def id
// for errors. AST borrowck is responsible for aggregating
// `signalled_any_error` from all of the nested closures here.
let base_def_id = tcx.closure_base_def_id(def_id);

match signalled_any_error {
match tcx.borrowck(base_def_id).signalled_any_error {
SignalledError::NoErrorsSeen => {
// if AST-borrowck signalled no errors, then
// downgrade all the buffered MIR-borrowck errors
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_mir/borrow_check/nll/region_infer/mod.rs
Expand Up @@ -1357,7 +1357,6 @@ pub trait ClosureRegionRequirementsExt<'gcx, 'tcx> {
fn apply_requirements(
&self,
tcx: TyCtxt<'_, 'gcx, 'tcx>,
location: Location,
closure_def_id: DefId,
closure_substs: &'tcx ty::subst::Substs<'tcx>,
) -> Vec<QueryRegionConstraint<'tcx>>;
Expand Down Expand Up @@ -1388,13 +1387,12 @@ impl<'gcx, 'tcx> ClosureRegionRequirementsExt<'gcx, 'tcx> for ClosureRegionRequi
fn apply_requirements(
&self,
tcx: TyCtxt<'_, 'gcx, 'tcx>,
location: Location,
closure_def_id: DefId,
closure_substs: &'tcx ty::subst::Substs<'tcx>,
) -> Vec<QueryRegionConstraint<'tcx>> {
debug!(
"apply_requirements(location={:?}, closure_def_id={:?}, closure_substs={:?})",
location, closure_def_id, closure_substs
"apply_requirements(closure_def_id={:?}, closure_substs={:?})",
closure_def_id, closure_substs
);

// Extract the values of the free regions in `closure_substs`
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/borrow_check/nll/region_infer/values.rs
Expand Up @@ -154,10 +154,10 @@ impl<N: Idx> LivenessValues<N> {
/// Creates a new set of "region values" that tracks causal information.
/// Each of the regions in num_region_variables will be initialized with an
/// empty set of points and no causal information.
crate fn new(elements: &Rc<RegionValueElements>) -> Self {
crate fn new(elements: Rc<RegionValueElements>) -> Self {
Self {
elements: elements.clone(),
points: SparseBitMatrix::new(elements.num_points),
elements: elements,
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/librustc_mir/borrow_check/nll/renumber.rs
Expand Up @@ -47,6 +47,14 @@ impl<'a, 'gcx, 'tcx> NLLVisitor<'a, 'gcx, 'tcx> {
}

impl<'a, 'gcx, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'gcx, 'tcx> {
fn visit_mir(&mut self, mir: &mut Mir<'tcx>) {
for promoted in mir.promoted.iter_mut() {
self.visit_mir(promoted);
}

self.super_mir(mir);
}

fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
debug!("visit_ty(ty={:?}, ty_context={:?})", ty, ty_context);

Expand Down