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

Make sure feature gate errors are recoverable (take 2) #57272

Merged
merged 2 commits into from
Jan 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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