Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

implement checks for tail calls #133607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
bors merged 6 commits into rust-lang:master from WaffleLapkin:tail-call-checks
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions compiler/rustc_middle/src/query/mod.rs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,12 @@ rustc_queries! {
cache_on_disk_if { true }
}

/// Checks well-formedness of tail calls (`become f()`).
query check_tail_calls(key: LocalDefId) -> Result<(), rustc_errors::ErrorGuaranteed> {
desc { |tcx| "tail-call-checking `{}`", tcx.def_path_str(key) }
cache_on_disk_if { true }
Copy link
Member

@compiler-errors compiler-errors Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably dont need this caching

Copy link
Member

@compiler-errors compiler-errors Dec 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or at least possibly seeing if this is perf sensitive

Copy link
Member Author

@WaffleLapkin WaffleLapkin Dec 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was copied from check_unsafety, we might want to change it too 🤔

}

/// Returns the types assumed to be well formed while "inside" of the given item.
///
/// Note that we've liberated the late bound regions of function signatures, so
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_mir_build/src/build/mod.rs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ pub(crate) fn mir_build<'tcx>(tcx: TyCtxtAt<'tcx>, def: LocalDefId) -> Body<'tcx
return construct_error(tcx, def, e);
}

if let Err(err) = tcx.check_tail_calls(def) {
return construct_error(tcx, def, err);
}

let body = match tcx.thir_body(def) {
Err(error_reported) => construct_error(tcx, def, error_reported),
Ok((thir, expr)) => {
Expand Down
Loading
Loading

AltStyle によって変換されたページ (->オリジナル) /