Skip to content

Commit 10a00e1

Browse files
committed
Make sure feature gate errors are recoverable (take 2)
1 parent af2c159 commit 10a00e1

File tree

54 files changed

+244
-128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+244
-128
lines changed

src/librustc/ty/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,16 +2839,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
28392839
self.impl_polarity(def_id1) == self.impl_polarity(def_id2)
28402840
&& trait1_is_empty
28412841
&& trait2_is_empty
2842-
} else if self.features().marker_trait_attr {
2842+
} else {
28432843
let is_marker_impl = |def_id: DefId| -> bool {
28442844
let trait_ref = self.impl_trait_ref(def_id);
28452845
trait_ref.map_or(false, |tr| self.trait_def(tr.def_id).is_marker)
28462846
};
28472847
self.impl_polarity(def_id1) == self.impl_polarity(def_id2)
28482848
&& is_marker_impl(def_id1)
28492849
&& is_marker_impl(def_id2)
2850-
} else {
2851-
false
28522850
};
28532851

28542852
if is_legit {

src/librustc_driver/driver.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,23 +1098,20 @@ where
10981098
ast_validation::check_crate(sess, &krate)
10991099
});
11001100

1101-
time(sess, "name resolution", || -> CompileResult {
1101+
time(sess, "name resolution", || {
11021102
resolver.resolve_crate(&krate);
1103-
Ok(())
1104-
})?;
1103+
});
11051104

11061105
// Needs to go *after* expansion to be able to check the results of macro expansion.
11071106
time(sess, "complete gated feature checking", || {
1108-
sess.track_errors(|| {
1109-
syntax::feature_gate::check_crate(
1110-
&krate,
1111-
&sess.parse_sess,
1112-
&sess.features_untracked(),
1113-
&attributes,
1114-
sess.opts.unstable_features,
1115-
);
1116-
})
1117-
})?;
1107+
syntax::feature_gate::check_crate(
1108+
&krate,
1109+
&sess.parse_sess,
1110+
&sess.features_untracked(),
1111+
&attributes,
1112+
sess.opts.unstable_features,
1113+
);
1114+
});
11181115

11191116
// Lower ast -> hir.
11201117
// First, we need to collect the dep_graph.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
//
2-
// compile-flags: --cfg broken
3-
41
// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044
52

3+
// compile-flags: --cfg broken
4+
5+
#![crate_type = "lib"]
66
#![cfg_attr(broken, no_core)] //~ ERROR no_core is experimental
77

8-
fn main() { }
8+
pub struct S {}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//
21
// compile-flags: --cfg broken
32

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

7-
fn main() { }
7+
pub struct S {}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//
21
// compile-flags: --cfg broken
32

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

7-
fn main() { }
7+
pub struct S {}

src/test/ui/feature-gates/feature-gate-alloc-error-handler.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ use core::alloc::Layout;
99
fn oom(info: Layout) -> ! {
1010
loop {}
1111
}
12+
13+
#[panic_handler]
14+
fn panic(_: &core::panic::PanicInfo) -> ! { loop {} }

src/test/ui/feature-gates/feature-gate-allow_fail.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ fn ok_to_fail() {
55
assert!(false);
66
}
77

8+
fn main() {}

src/test/ui/feature-gates/feature-gate-async-await-2015-edition.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ async fn foo() {} //~ ERROR async fn is unstable
66

77
fn main() {
88
let _ = async {}; //~ ERROR cannot find struct, variant or union type `async`
9-
let _ = async || {}; //~ ERROR cannot find value `async` in this scope
9+
let _ = async || { true }; //~ ERROR cannot find value `async` in this scope
1010
}

src/test/ui/feature-gates/feature-gate-async-await-2015-edition.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | let _ = async {}; //~ ERROR cannot find struct, variant or union type `
77
error[E0425]: cannot find value `async` in this scope
88
--> $DIR/feature-gate-async-await-2015-edition.rs:9:13
99
|
10-
LL | let _ = async || {}; //~ ERROR cannot find value `async` in this scope
10+
LL | let _ = async || { true }; //~ ERROR cannot find value `async` in this scope
1111
| ^^^^^ not found in this scope
1212

1313
error[E0658]: async fn is unstable (see issue #50547)

src/test/ui/feature-gates/feature-gate-const_fn.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ trait Foo {
99
//~| ERROR trait fns cannot be declared const
1010
}
1111

12-
impl Foo {
13-
const fn baz() -> u32 { 0 } // ok
14-
}
15-
1612
impl Foo for u32 {
1713
const fn foo() -> u32 { 0 } //~ ERROR trait fns cannot be declared const
1814
}
1915

16+
trait Bar {}
17+
18+
impl dyn Bar {
19+
const fn baz() -> u32 { 0 } // ok
20+
}
21+
2022
static FOO: usize = foo();
2123
const BAR: usize = foo();
2224

0 commit comments

Comments
 (0)