diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-01-19 11:48:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-19 11:48:15 +0100 |
| commit | 4842ff4a85c9315103885eca2f2fc98bd2ee7826 (patch) | |
| tree | 0d72bf1e59968c8338c248d6d59a88cdaac29899 /compiler/rustc_const_eval/src/check_consts/check.rs | |
| parent | c62b732724b6beb50a5c73be26d0c5f668504059 (diff) | |
| parent | e68a8ce0350892d97ff24323bf98771d65d0ed52 (diff) | |
| download | rust-4842ff4a85c9315103885eca2f2fc98bd2ee7826.tar.gz rust-4842ff4a85c9315103885eca2f2fc98bd2ee7826.zip | |
Rollup merge of #134858 - estebank:issue-81370, r=Noratrieb
Provide structured suggestion for `#![feature(..)]` in more cases Fix #81370.
Diffstat (limited to 'compiler/rustc_const_eval/src/check_consts/check.rs')
| -rw-r--r-- | compiler/rustc_const_eval/src/check_consts/check.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index 06d6a5a5af5..ed34996a7a7 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -464,6 +464,12 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { err_span, ); } + + fn crate_inject_span(&self) -> Option<Span> { + self.tcx.hir_crate_items(()).definitions().next().and_then(|id| { + self.tcx.crate_level_attribute_injection_span(self.tcx.local_def_id_to_hir_id(id)) + }) + } } impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { @@ -809,6 +815,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { name: intrinsic.name, feature, const_stable_indirect: is_const_stable, + suggestion: self.crate_inject_span(), }); } Some(ConstStability { level: StabilityLevel::Stable { .. }, .. }) => { @@ -897,7 +904,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { // regular stability. feature == sym::rustc_private && issue == NonZero::new(27812) - && self.tcx.sess.opts.unstable_opts.force_unstable_if_unmarked + && tcx.sess.opts.unstable_opts.force_unstable_if_unmarked }; // Even if the feature is enabled, we still need check_op to double-check // this if the callee is not safe to expose on stable. @@ -907,6 +914,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { feature, feature_enabled, safe_to_expose_on_stable: callee_safe_to_expose_on_stable, + suggestion_span: self.crate_inject_span(), }); } } |
