diff options
| author | Léo Lanteri Thauvin <leseulartichaut@gmail.com> | 2023-03-02 12:37:32 +0100 |
|---|---|---|
| committer | Léo Lanteri Thauvin <leseulartichaut@gmail.com> | 2023-03-12 14:57:38 +0100 |
| commit | db266939822a5a89473871abff6beea39b083af6 (patch) | |
| tree | 29377abd03b135ff72e6507441ac643b18f22150 /compiler/rustc_hir_analysis/src | |
| parent | 24c0b81c1fd5de8e00276524896d3352ed91a8cb (diff) | |
| download | rust-db266939822a5a89473871abff6beea39b083af6.tar.gz rust-db266939822a5a89473871abff6beea39b083af6.zip | |
Forbid the use of `#[target_feature]` on `main`
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/errors.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/lib.rs | 5 |
2 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index 8a697b4c514..5b445ead1d3 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -328,6 +328,14 @@ pub(crate) struct TrackCallerOnMain { } #[derive(Diagnostic)] +#[diag(hir_analysis_target_feature_on_main)] +pub(crate) struct TargetFeatureOnMain { + #[primary_span] + #[label(hir_analysis_target_feature_on_main)] + pub main: Span, +} + +#[derive(Diagnostic)] #[diag(hir_analysis_start_not_track_caller)] pub(crate) struct StartTrackCaller { #[primary_span] diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 6a4f5382878..098b003eaed 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -283,6 +283,11 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) { error = true; } + if !tcx.codegen_fn_attrs(main_def_id).target_features.is_empty() { + tcx.sess.emit_err(errors::TargetFeatureOnMain { main: main_span }); + error = true; + } + if error { return; } |
