-
-
Notifications
You must be signed in to change notification settings - Fork 17.6k
don't report errors in dispatchability checking #163201
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
Open
dianne
wants to merge
1
commit into
rust-lang:main
Choose a base branch
from
dianne:normalize-param-env-or-delay-bugs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -326,12 +326,19 @@ where | |
| }) | ||
| } | ||
|
|
||
| #[derive(Copy, Clone, Debug)] | ||
| enum ReportErrors { | ||
| Yes, | ||
| DelayBugs, | ||
| } | ||
|
|
||
| #[instrument(level = "debug", skip(tcx, elaborated_env))] | ||
| fn do_normalize_clauses<'tcx>( | ||
| tcx: TyCtxt<'tcx>, | ||
| cause: ObligationCause<'tcx>, | ||
| elaborated_env: ty::ParamEnv<'tcx>, | ||
| clauses: Vec<ty::Clause<'tcx>>, | ||
| report_errors: ReportErrors, | ||
| ) -> Vec<ty::Clause<'tcx>> { | ||
| // FIXME. We should really... do something with these region | ||
| // obligations. But this call just continues the older | ||
|
|
@@ -382,7 +389,12 @@ fn do_normalize_clauses<'tcx>( | |
| let errors = ocx.evaluate_obligations_error_on_ambiguity(); | ||
| let clauses = if let TraitErrors::HasErrors(errors) = errors { | ||
| debug!("do_normalize_clauses: failed to normalize clauses"); | ||
| let guar = infcx.err_ctxt().report_fulfillment_errors(errors); | ||
| let guar = match report_errors { | ||
| ReportErrors::Yes => infcx.err_ctxt().report_fulfillment_errors(errors), | ||
| ReportErrors::DelayBugs => tcx | ||
| .dcx() | ||
| .span_delayed_bug(cause.span, format!("failed to normalize clauses: {errors:?}")), | ||
| }; | ||
| replace_infer_and_non_rigid_alias_with_error(&infcx, clauses, guar, ReplaceRegions::No) | ||
| } else { | ||
| clauses | ||
|
|
@@ -430,13 +442,11 @@ fn do_normalize_clauses<'tcx>( | |
| } | ||
| } | ||
|
|
||
| // FIXME: this is gonna need to be removed ... | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe this FIXME should be duplicated? for now I've just kept it on the function it was originally on |
||
| /// Normalizes the parameter environment, reporting errors if they occur. | ||
| #[instrument(level = "debug", skip(tcx))] | ||
| pub fn normalize_param_env_or_error<'tcx>( | ||
| fn normalize_param_env_or_optionally_error<'tcx>( | ||
| tcx: TyCtxt<'tcx>, | ||
| unnormalized_env: ty::ParamEnv<'tcx>, | ||
| cause: ObligationCause<'tcx>, | ||
| report_errors: ReportErrors, | ||
| ) -> ty::ParamEnv<'tcx> { | ||
| // I'm not wild about reporting errors here; I'd prefer to | ||
| // have the errors get reported at a defined place (e.g., | ||
|
|
@@ -560,7 +570,8 @@ pub fn normalize_param_env_or_error<'tcx>( | |
| "normalize_param_env_or_error: clauses=(non-outlives={:?}, outlives={:?})", | ||
| clauses, outlives_clauses | ||
| ); | ||
| let non_outlives_clauses = do_normalize_clauses(tcx, cause.clone(), elaborated_env, clauses); | ||
| let non_outlives_clauses = | ||
| do_normalize_clauses(tcx, cause.clone(), elaborated_env, clauses, report_errors); | ||
|
|
||
| debug!("normalize_param_env_or_error: non-outlives clauses={:?}", non_outlives_clauses); | ||
|
|
||
|
|
@@ -569,7 +580,8 @@ pub fn normalize_param_env_or_error<'tcx>( | |
| // clauses here anyway. Keeping them here anyway because it seems safer. | ||
| let outlives_env = non_outlives_clauses.iter().chain(&outlives_clauses).cloned(); | ||
| let outlives_env = ty::ParamEnv::new(tcx, outlives_env); | ||
| let outlives_clauses = do_normalize_clauses(tcx, cause, outlives_env, outlives_clauses); | ||
| let outlives_clauses = | ||
| do_normalize_clauses(tcx, cause, outlives_env, outlives_clauses, report_errors); | ||
| debug!("normalize_param_env_or_error: outlives clauses={:?}", outlives_clauses); | ||
|
|
||
| let mut clauses = non_outlives_clauses; | ||
|
|
@@ -578,6 +590,28 @@ pub fn normalize_param_env_or_error<'tcx>( | |
| ty::ParamEnv::new(tcx, clauses) | ||
| } | ||
|
|
||
| // FIXME: this is gonna need to be removed ... | ||
| /// Normalizes the parameter environment, reporting errors if they occur. | ||
| #[instrument(level = "debug", skip(tcx))] | ||
| pub fn normalize_param_env_or_error<'tcx>( | ||
| tcx: TyCtxt<'tcx>, | ||
| unnormalized_env: ty::ParamEnv<'tcx>, | ||
| cause: ObligationCause<'tcx>, | ||
| ) -> ty::ParamEnv<'tcx> { | ||
| normalize_param_env_or_optionally_error(tcx, unnormalized_env, cause, ReportErrors::Yes) | ||
| } | ||
|
|
||
| /// Variant of [`normalize_param_env_or_error`] that creates delayed bugs instead of reporting | ||
| /// errors, for use in cases where we shouldn't be reporting errors (such as normalizing the | ||
| /// synthetic param-env used when testing whether method receivers are dispatchable). | ||
| pub fn normalize_param_env_or_delay_bugs<'tcx>( | ||
| tcx: TyCtxt<'tcx>, | ||
| unnormalized_env: ty::ParamEnv<'tcx>, | ||
| cause: ObligationCause<'tcx>, | ||
| ) -> ty::ParamEnv<'tcx> { | ||
| normalize_param_env_or_optionally_error(tcx, unnormalized_env, cause, ReportErrors::DelayBugs) | ||
| } | ||
|
|
||
| #[derive(Debug)] | ||
| pub enum EvaluateConstErr<E> { | ||
| /// The constant being evaluated was either a generic parameter or inference variable, *or*, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.