Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Mar 14, 2024
1 parent 2906469 commit a49a8eb
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
ccx.tcx.disabled_nightly_feature(
&mut err,
body.source.def_id().as_local().map(|local| ccx.tcx.local_def_id_to_hir_id(local)),
vec![(String::new(), feature)].into_iter(),
[(String::new(), feature)],
);
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/astconv/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn generic_arg_mismatch_err(
tcx.disabled_nightly_feature(
&mut err,
param.def_id.as_local().map(|local| tcx.local_def_id_to_hir_id(local)),
vec![(String::new(), sym::generic_arg_infer)].into_iter(),
[(String::new(), sym::generic_arg_infer)],
);
}
}
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_hir_analysis/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,9 @@ fn default_body_is_unstable(
reason: reason_str,
});

let inject_span =
item_did.as_local().and_then(|id| tcx.crate_inject_span(tcx.local_def_id_to_hir_id(id)));
let inject_span = item_did
.as_local()
.and_then(|id| tcx.crate_level_attribute_injection_span(tcx.local_def_id_to_hir_id(id)));
rustc_session::parse::add_feature_diagnostics_for_issue(
&mut err,
&tcx.sess,
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,11 +1002,10 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
tcx.disabled_nightly_feature(
&mut diag,
Some(param.hir_id),
vec![(
[(
" more complex and user defined types".to_string(),
sym::adt_const_params,
)]
.into_iter(),
)],
);
}

Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,7 @@ impl<'tcx> TyCtxt<'tcx> {

/// Find the crate root and the appropriate span where `use` and outer attributes can be
/// inserted at.
pub fn crate_inject_span(self, hir_id: HirId) -> Option<Span> {
pub fn crate_level_attribute_injection_span(self, hir_id: HirId) -> Option<Span> {
for (_hir_id, node) in self.hir().parent_iter(hir_id) {
if let hir::Node::Crate(m) = node {
return Some(m.spans.inject_use_span.shrink_to_lo());
Expand All @@ -2188,14 +2188,15 @@ impl<'tcx> TyCtxt<'tcx> {
self,
diag: &mut Diag<'_, E>,
hir_id: Option<HirId>,
features: impl Iterator<Item = (String, Symbol)>,
features: impl IntoIterator<Item = (String, Symbol)>,
) {
if !self.sess.is_nightly_build() {
return;
}

let span = hir_id.and_then(|id| self.crate_inject_span(id));
let span = hir_id.and_then(|id| self.crate_level_attribute_injection_span(id));
for (desc, feature) in features {
// FIXME: make this string translatable
let msg =
format!("add `#![feature({feature})]` to the crate attributes to enable{desc}");
if let Some(span) = span {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3474,7 +3474,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
tcx.disabled_nightly_feature(
err,
Some(tcx.local_def_id_to_hir_id(body_id)),
vec![(String::new(), sym::trivial_bounds)].into_iter(),
[(String::new(), sym::trivial_bounds)],
);
}
ObligationCauseCode::OpaqueReturnType(expr_info) => {
Expand Down

0 comments on commit a49a8eb

Please sign in to comment.