Skip to content

Commit

Permalink
Auto merge of #57272 - petrochenkov:featrecov, r=estebank
Browse files Browse the repository at this point in the history
Make sure feature gate errors are recoverable (take 2)

Continuation of 15cefe4.
Turns out I missed the most important part - the main feature gate checking pass.
  • Loading branch information
bors committed Jan 6, 2019
2 parents 6b2c311 + 3751177 commit b92552d
Show file tree
Hide file tree
Showing 56 changed files with 308 additions and 191 deletions.
4 changes: 1 addition & 3 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2839,16 +2839,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
self.impl_polarity(def_id1) == self.impl_polarity(def_id2)
&& trait1_is_empty
&& trait2_is_empty
} else if self.features().marker_trait_attr {
} else {
let is_marker_impl = |def_id: DefId| -> bool {
let trait_ref = self.impl_trait_ref(def_id);
trait_ref.map_or(false, |tr| self.trait_def(tr.def_id).is_marker)
};
self.impl_polarity(def_id1) == self.impl_polarity(def_id2)
&& is_marker_impl(def_id1)
&& is_marker_impl(def_id2)
} else {
false
};

if is_legit {
Expand Down
23 changes: 10 additions & 13 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,23 +1098,20 @@ where
ast_validation::check_crate(sess, &krate)
});

time(sess, "name resolution", || -> CompileResult {
time(sess, "name resolution", || {
resolver.resolve_crate(&krate);
Ok(())
})?;
});

// Needs to go *after* expansion to be able to check the results of macro expansion.
time(sess, "complete gated feature checking", || {
sess.track_errors(|| {
syntax::feature_gate::check_crate(
&krate,
&sess.parse_sess,
&sess.features_untracked(),
&attributes,
sess.opts.unstable_features,
);
})
})?;
syntax::feature_gate::check_crate(
&krate,
&sess.parse_sess,
&sess.features_untracked(),
&attributes,
sess.opts.unstable_features,
);
});

// Lower ast -> hir.
// First, we need to collect the dep_graph.
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/conditional-compilation/cfg-attr-crate-2.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//
// compile-flags: --cfg broken

// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044

// compile-flags: --cfg broken

#![crate_type = "lib"]
#![cfg_attr(broken, no_core)] //~ ERROR no_core is experimental

fn main() { }
pub struct S {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// compile-flags: --cfg broken

#![feature(cfg_attr_multi)]
#![crate_type = "lib"]
#![cfg_attr(broken, no_core, no_std)] //~ ERROR no_core is experimental

fn main() { }
pub struct S {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// compile-flags: --cfg broken

#![feature(cfg_attr_multi)]
#![crate_type = "lib"]
#![cfg_attr(broken, no_std, no_core)] //~ ERROR no_core is experimental

fn main() { }
pub struct S {}
1 change: 1 addition & 0 deletions src/test/ui/feature-gates/feature-gate-abi.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// only-x86_64
// ignore-tidy-linelength
// gate-test-intrinsics
// gate-test-platform_intrinsics
Expand Down
Loading

0 comments on commit b92552d

Please sign in to comment.