X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_passes%2Fsrc%2Flib_features.rs;h=4c6a9b23fdf12a9ed33c99f71337ce81c64364d0;hb=5ff6cdca7ec664c7f96653e6c028b524757d60c4;hp=b5843c0ae488b1f17c58d81c1ae91758baf4e8e7;hpb=e702534763599db252f2ca308739ec340d0933de;p=rust.git diff --git a/compiler/rustc_passes/src/lib_features.rs b/compiler/rustc_passes/src/lib_features.rs index b5843c0ae48..4c6a9b23fdf 100644 --- a/compiler/rustc_passes/src/lib_features.rs +++ b/compiler/rustc_passes/src/lib_features.rs @@ -137,6 +137,12 @@ fn visit_attribute(&mut self, attr: &'tcx Attribute) { } fn lib_features(tcx: TyCtxt<'_>, (): ()) -> LibFeatures { + // If `staged_api` is not enabled then we aren't allowed to define lib + // features; there is no point collecting them. + if !tcx.features().staged_api { + return new_lib_features(); + } + let mut collector = LibFeatureCollector::new(tcx); tcx.hir().walk_attributes(&mut collector); collector.lib_features