Skip to content

Commit 8d9a687

Browse files
committed
Make sure feature gate errors are recoverable (take 2)
1 parent c0bbc39 commit 8d9a687

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
@@ -2801,16 +2801,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
28012801
self.impl_polarity(def_id1) == self.impl_polarity(def_id2)
28022802
&& trait1_is_empty
28032803
&& trait2_is_empty
2804-
} else if self.features().marker_trait_attr {
2804+
} else {
28052805
let is_marker_impl = |def_id: DefId| -> bool {
28062806
let trait_ref = self.impl_trait_ref(def_id);
28072807
trait_ref.map_or(false, |tr| self.trait_def(tr.def_id).is_marker)
28082808
};
28092809
self.impl_polarity(def_id1) == self.impl_polarity(def_id2)
28102810
&& is_marker_impl(def_id1)
28112811
&& is_marker_impl(def_id2)
2812-
} else {
2813-
false
28142812
}
28152813
}
28162814

src/librustc_driver/driver.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,23 +1101,20 @@ where
11011101
ast_validation::check_crate(sess, &krate)
11021102
});
11031103

1104-
time(sess, "name resolution", || -> CompileResult {
1104+
time(sess, "name resolution", || {
11051105
resolver.resolve_crate(&krate);
1106-
Ok(())
1107-
})?;
1106+
});
11081107

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

11221119
// Lower ast -> hir.
11231120
// 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)