Skip to content

Rollup of 6 pull requests #59684

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 34 commits into from
Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1cfed0d
be more direct about borrow requirenments
matklad Apr 3, 2019
ab3b657
Updated the documentation of core::hints::spin_loop and core::sync::s…
Apr 3, 2019
becee90
Updated the reference in core::hint::spin_loop to the correct relativ…
Apr 3, 2019
7e37b46
Updated the environment description in rustc.
Apr 3, 2019
c796b1f
Add tests for internal lints
flip1995 Dec 6, 2018
5c06567
Add internal lints default_hash_types and usage_of_ty_tykind
flip1995 Dec 6, 2018
4c9fb93
Uplift match_def_path from Clippy
flip1995 Dec 6, 2018
a2a8c44
Add register_internals function to `rustc_lint`
flip1995 Dec 6, 2018
157e797
Fix rebase fallout
flip1995 Feb 24, 2019
16acf7d
use check_path instead of check_expr
flip1995 Feb 28, 2019
9b2bf70
Make internal lints allow-by-default
flip1995 Mar 16, 2019
5a788f0
Fix bug in TyKind lint
flip1995 Mar 19, 2019
e536037
Deduplicate code in TyKind lint
flip1995 Mar 21, 2019
28a5c41
Check for unstable-options flag before register internals
flip1995 Mar 21, 2019
2045dfe
Update tests
flip1995 Mar 21, 2019
dfcd1ef
Add unstable-options flag to stage!=0
flip1995 Mar 31, 2019
69f74df
Deny internal lints in librustc
flip1995 Mar 31, 2019
d3f0cb9
Deny internal lints on non conflicting crates
flip1995 Mar 31, 2019
818d300
Deny internal lints on librustc_interface
flip1995 Mar 31, 2019
d2bc991
Deny internal lints on librustc_lint
flip1995 Mar 31, 2019
e4b87f5
Deny internal lints on librustc_mir
flip1995 Mar 31, 2019
4d2a3bb
Deny internal lints on librustc_typeck
flip1995 Mar 31, 2019
dd7483c
Remove TyKind arg from report_bin_hex_error function
flip1995 Apr 2, 2019
51a792d
Add trait_object_dummy_self to CommonTypes
flip1995 Apr 3, 2019
076abfa
Deny internal lints on two more crates
flip1995 Apr 3, 2019
c81ce06
Compare `Ty`s directly instead of their `TyKind`s
flip1995 Apr 3, 2019
da99f46
rustfix coverage: Skip UI tests with non-json error-format
phansch Apr 3, 2019
fba110c
reduce repetition in librustc(_lint) wrt. impl LintPass
Centril Apr 3, 2019
dcccab5
Rollup merge of #59316 - flip1995:internal_lints_take_2, r=oli-obk
Centril Apr 3, 2019
b78cbe6
Rollup merge of #59663 - matklad:borrow, r=dtolnay
Centril Apr 3, 2019
b4686ca
Rollup merge of #59664 - DevQps:improve-yield-spinlock-docs, r=alexcr…
Centril Apr 3, 2019
c87cce6
Rollup merge of #59666 - DevQps:update-rustc-environment-descriptions…
Centril Apr 3, 2019
eb3215e
Rollup merge of #59669 - Centril:lint-pass-macro, r=oli-obk
Centril Apr 3, 2019
231bd48
Rollup merge of #59677 - phansch:rustfix_coverage_handle_other_error_…
Centril Apr 3, 2019
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
Prev Previous commit
Next Next commit
Add trait_object_dummy_self to CommonTypes
  • Loading branch information
flip1995 committed Apr 3, 2019
commit 51a792d01b3af2c96850d3be9392139a592931dd
7 changes: 7 additions & 0 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ pub struct CommonTypes<'tcx> {
pub never: Ty<'tcx>,
pub err: Ty<'tcx>,

/// Dummy type used for the `Self` of a `TraitRef` created for converting
/// a trait object, and which gets removed in `ExistentialTraitRef`.
/// This type must not appear anywhere in other converted types.
pub trait_object_dummy_self: Ty<'tcx>,

pub re_empty: Region<'tcx>,
pub re_static: Region<'tcx>,
pub re_erased: Region<'tcx>,
Expand Down Expand Up @@ -955,6 +960,8 @@ impl<'tcx> CommonTypes<'tcx> {
f32: mk(Float(ast::FloatTy::F32)),
f64: mk(Float(ast::FloatTy::F64)),

trait_object_dummy_self: mk(Infer(ty::FreshTy(0))),

re_empty: mk_region(RegionKind::ReEmpty),
re_static: mk_region(RegionKind::ReStatic),
re_erased: mk_region(RegionKind::ReErased),
Expand Down
20 changes: 8 additions & 12 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ enum GenericArgPosition {
MethodCall,
}

/// Dummy type used for the `Self` of a `TraitRef` created for converting
/// a trait object, and which gets removed in `ExistentialTraitRef`.
/// This type must not appear anywhere in other converted types.
#[cfg_attr(not(stage0), allow(usage_of_ty_tykind))]
const TRAIT_OBJECT_DUMMY_SELF: ty::TyKind<'static> = ty::Infer(ty::FreshTy(0));

impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
pub fn ast_region_to_region(&self,
lifetime: &hir::Lifetime,
Expand Down Expand Up @@ -596,7 +590,9 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
infer_types,
);

let is_object = self_ty.map_or(false, |ty| ty.sty == TRAIT_OBJECT_DUMMY_SELF);
let is_object = self_ty.map_or(false, |ty| {
ty.sty == self.tcx().types.trait_object_dummy_self.sty
});
let default_needs_object_self = |param: &ty::GenericParamDef| {
if let GenericParamDefKind::Type { has_default, .. } = param.kind {
if is_object && has_default {
Expand Down Expand Up @@ -957,10 +953,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
}

/// Transform a `PolyTraitRef` into a `PolyExistentialTraitRef` by
/// removing the dummy `Self` type (`TRAIT_OBJECT_DUMMY_SELF`).
/// removing the dummy `Self` type (`trait_object_dummy_self`).
fn trait_ref_to_existential(&self, trait_ref: ty::TraitRef<'tcx>)
-> ty::ExistentialTraitRef<'tcx> {
if trait_ref.self_ty().sty != TRAIT_OBJECT_DUMMY_SELF {
if trait_ref.self_ty().sty != self.tcx().types.trait_object_dummy_self.sty {
bug!("trait_ref_to_existential called on {:?} with non-dummy Self", trait_ref);
}
ty::ExistentialTraitRef::erase_self_ty(self.tcx(), trait_ref)
Expand All @@ -981,7 +977,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
}

let mut projection_bounds = Vec::new();
let dummy_self = tcx.mk_ty(TRAIT_OBJECT_DUMMY_SELF);
let dummy_self = self.tcx().types.trait_object_dummy_self;
let (principal, potential_assoc_types) = self.instantiate_poly_trait_ref(
&trait_bounds[0],
dummy_self,
Expand Down Expand Up @@ -1031,7 +1027,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
}
ty::Predicate::Projection(pred) => {
// A `Self` within the original bound will be substituted with a
// `TRAIT_OBJECT_DUMMY_SELF`, so check for that.
// `trait_object_dummy_self`, so check for that.
let references_self =
pred.skip_binder().ty.walk().any(|t| t == dummy_self);

Expand Down Expand Up @@ -1131,7 +1127,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
err.emit();
}

// Erase the `dummy_self` (`TRAIT_OBJECT_DUMMY_SELF`) used above.
// Erase the `dummy_self` (`trait_object_dummy_self`) used above.
let existential_principal = principal.map_bound(|trait_ref| {
self.trait_ref_to_existential(trait_ref)
});
Expand Down