-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Improve ty.needs_drop
#68679
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
Merged
Improve ty.needs_drop
#68679
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
91cf0e7
Don't requery the param_env of a union
matthewjasper 570c161
Remove unnecessary features in rustc_ty
matthewjasper 3973322
Add IS_MANUALLY_DROP to AdtFlags
matthewjasper d196521
Improve needs_drop query
matthewjasper d20646b
Address review comments
matthewjasper 465b862
Use correct `ParamEnv` in `Instance::resolve`
matthewjasper 3eb5241
Apply suggestions from code review
matthewjasper 842938a
cache adt_drop_tys
matthewjasper 30a8353
Specify overflow checks behaviour in test
matthewjasper 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
Improve needs_drop query
* Handle cycles in `needs_drop` correctly * Normalize types when computing `needs_drop` * Move queries from rustc to rustc_ty
- Loading branch information
commit d1965216a34dc2831cf44d2e15ad9d78403d10cc
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//! Queries for checking whether a type implements one of a few common traits. | ||
|
||
use rustc::middle::lang_items; | ||
use rustc::traits; | ||
use rustc::ty::{self, Ty, TyCtxt}; | ||
use rustc_span::DUMMY_SP; | ||
|
||
fn is_copy_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { | ||
is_item_raw(tcx, query, lang_items::CopyTraitLangItem) | ||
} | ||
|
||
fn is_sized_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { | ||
is_item_raw(tcx, query, lang_items::SizedTraitLangItem) | ||
} | ||
|
||
fn is_freeze_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { | ||
is_item_raw(tcx, query, lang_items::FreezeTraitLangItem) | ||
} | ||
|
||
fn is_item_raw<'tcx>( | ||
tcx: TyCtxt<'tcx>, | ||
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>, | ||
item: lang_items::LangItem, | ||
) -> bool { | ||
let (param_env, ty) = query.into_parts(); | ||
let trait_def_id = tcx.require_lang_item(item, None); | ||
tcx.infer_ctxt().enter(|infcx| { | ||
traits::type_known_to_meet_bound_modulo_regions( | ||
&infcx, | ||
param_env, | ||
ty, | ||
trait_def_id, | ||
DUMMY_SP, | ||
) | ||
}) | ||
} | ||
|
||
pub(crate) fn provide(providers: &mut ty::query::Providers<'_>) { | ||
*providers = ty::query::Providers { is_copy_raw, is_sized_raw, is_freeze_raw, ..*providers }; | ||
} |
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.
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.