Skip to content
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
aef3d93
Add powerpc64-ibm-aix as Tier-3 target
ecnelises Aug 25, 2022
83701f5
Use ObligationCtxt intead of dyn TraitEngine
spastorino Nov 16, 2022
23422a8
Call fully_solve_obligations instead of repeating code
spastorino Nov 17, 2022
9864a63
Pass ObligationCtxt from enter_canonical_trait_query and use Obligati…
spastorino Nov 16, 2022
4e9ceef
Refactor `must_use` lint into two parts
Noratrieb Nov 13, 2022
644a5a3
enable fuzzy_provenance_casts lint in liballoc
RalfJung Nov 20, 2022
7f5addd
enable fuzzy_provenance_casts lint in libstd
RalfJung Nov 20, 2022
1a69666
dont attempt strict provenance in SGX
RalfJung Nov 21, 2022
2752e32
Allow opaque types in trait impl headers and rely on coherence to rej…
oli-obk Oct 24, 2022
94fe30f
Treat different opaque types of the same def id as equal during coher…
oli-obk Oct 27, 2022
ae80c76
Add an always-ambiguous predicate to make sure that we don't accident…
oli-obk Nov 2, 2022
9cd44f8
nit treat different opaque types
oli-obk Nov 14, 2022
9a8e1ee
Move a field around
oli-obk Nov 14, 2022
f42e490
Register obligations from type relation
oli-obk Nov 14, 2022
11ae334
Remove a function that doesn't actually do anything
oli-obk Nov 15, 2022
7301cd7
Type generalization should not look at opaque type in coherence
oli-obk Nov 17, 2022
11adf03
Add some more assertions for type relations not used during coherence
oli-obk Nov 17, 2022
c16a90f
Test generalization during coherence
oli-obk Nov 17, 2022
98cb7c8
Suggest `.clone()` or `ref binding` on E0382
estebank Nov 3, 2022
fface0c
Do not suggest `ref` multiple times for the same binding
estebank Nov 3, 2022
cca960d
Fix clippy code
estebank Nov 3, 2022
242dd83
Use `type_implements_trait`
estebank Nov 3, 2022
e88009b
Extract suggestion logic to its own method
estebank Nov 3, 2022
0994f8d
Remove logic duplication
estebank Nov 3, 2022
4918d4f
Tweak output in for loops
estebank Nov 3, 2022
33a6dc9
Fix wording
estebank Nov 3, 2022
6f77be4
Fix rustfmt
estebank Nov 3, 2022
a930d44
Tweak output to account for alternative bindings in the same pattern
estebank Nov 3, 2022
5bf1413
Fix rebase
estebank Nov 3, 2022
95a5beb
remove spurious commented out code
estebank Nov 4, 2022
2698d24
review comments: inline bindings and fix typo
estebank Nov 12, 2022
9a39012
Account for `x @ y` and suggest `ref x @ ref y`
estebank Nov 15, 2022
7cc4fb5
Account for closures
estebank Nov 16, 2022
3099dfd
Forbid inlining `thread_local!`'s `__getit` function on Windows
thomcc Sep 3, 2022
2d5d692
Add failing test for projections used as const generic
GuillaumeGomez Nov 22, 2022
04610ad
Fix `ClosureKind::to_def_id`
WaffleLapkin Nov 22, 2022
b80356a
Use `tcx.require_lang_item` instead of unwrapping
WaffleLapkin Nov 22, 2022
f2830f2
Speed up mpsc_stress test
Nov 22, 2022
90e8b94
Rollup merge of #101368 - thomcc:wintls-noinline, r=ChrisDenton
Manishearth Nov 22, 2022
ab6f755
Rollup merge of #102293 - ecnelises:aix.initial, r=davidtwco
Manishearth Nov 22, 2022
43eb708
Rollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnr
Manishearth Nov 22, 2022
b3a2eea
Rollup merge of #103908 - estebank:consider-cloning, r=compiler-errors
Manishearth Nov 22, 2022
1e12a3a
Rollup merge of #104359 - Nilstrieb:plus-one, r=fee1-dead
Manishearth Nov 22, 2022
bbe1843
Rollup merge of #104509 - spastorino:use-obligation-ctxt, r=lcnr
Manishearth Nov 22, 2022
7c56974
Rollup merge of #104647 - RalfJung:alloc-strict-provenance, r=thomcc
Manishearth Nov 22, 2022
e105d05
Rollup merge of #104717 - GuillaumeGomez:test-projection-used-as-cons…
Manishearth Nov 22, 2022
60a07e1
Rollup merge of #104722 - mejrs:stress, r=ChrisDenton
Manishearth Nov 22, 2022
2078dbd
Rollup merge of #104724 - WaffleLapkin:to_def_idn't, r=compiler-errors
Manishearth Nov 22, 2022
0c626d4
Rollup merge of #104728 - WaffleLapkin:require-lang-items-politely, r…
Manishearth Nov 22, 2022
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
16 changes: 2 additions & 14 deletions compiler/rustc_borrowck/src/type_check/relate_tys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use rustc_infer::infer::nll_relate::{NormalizationStrategy, TypeRelating, TypeRe
use rustc_infer::infer::NllRegionVariableOrigin;
use rustc_infer::traits::PredicateObligations;
use rustc_middle::mir::ConstraintCategory;
use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::relate::TypeRelation;
use rustc_middle::ty::{self, Const, Ty};
use rustc_middle::ty::{self, Ty};
use rustc_span::Span;
use rustc_trait_selection::traits::query::Fallible;

Expand Down Expand Up @@ -141,13 +140,6 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
);
}

// We don't have to worry about the equality of consts during borrow checking
// as consts always have a static lifetime.
// FIXME(oli-obk): is this really true? We can at least have HKL and with
// inline consts we may have further lifetimes that may be unsound to treat as
// 'static.
fn const_equate(&mut self, _a: Const<'tcx>, _b: Const<'tcx>) {}

fn normalization() -> NormalizationStrategy {
NormalizationStrategy::Eager
}
Expand All @@ -156,10 +148,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
true
}

fn register_opaque_type_obligations(
&mut self,
obligations: PredicateObligations<'tcx>,
) -> Result<(), TypeError<'tcx>> {
fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
self.type_checker
.fully_perform_op(
self.locations,
Expand All @@ -172,6 +161,5 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
},
)
.unwrap();
Ok(())
}
}
8 changes: 8 additions & 0 deletions compiler/rustc_hir_analysis/src/check/dropck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ impl<'tcx> TypeRelation<'tcx> for SimpleEqRelation<'tcx> {
self.tcx
}

fn intercrate(&self) -> bool {
false
}

fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.param_env
}
Expand All @@ -256,6 +260,10 @@ impl<'tcx> TypeRelation<'tcx> for SimpleEqRelation<'tcx> {
true
}

fn mark_ambiguous(&mut self) {
bug!()
}

fn relate_with_variance<T: Relate<'tcx>>(
&mut self,
_: ty::Variance,
Expand Down
53 changes: 0 additions & 53 deletions compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{struct_span_err, DelayDm};
use rustc_errors::{Diagnostic, ErrorGuaranteed};
use rustc_hir as hir;
use rustc_middle::ty::subst::GenericArgKind;
use rustc_middle::ty::subst::InternalSubsts;
use rustc_middle::ty::util::IgnoreRegions;
use rustc_middle::ty::{
Expand Down Expand Up @@ -47,58 +46,6 @@ fn do_orphan_check_impl<'tcx>(
let sp = tcx.def_span(def_id);
let tr = impl_.of_trait.as_ref().unwrap();

// Ensure no opaque types are present in this impl header. See issues #76202 and #86411 for examples,
// and #84660 where it would otherwise allow unsoundness.
if trait_ref.has_opaque_types() {
trace!("{:#?}", item);
// First we find the opaque type in question.
for ty in trait_ref.substs {
for ty in ty.walk() {
let ty::subst::GenericArgKind::Type(ty) = ty.unpack() else { continue };
let ty::Opaque(def_id, _) = *ty.kind() else { continue };
trace!(?def_id);

// Then we search for mentions of the opaque type's type alias in the HIR
struct SpanFinder<'tcx> {
sp: Span,
def_id: DefId,
tcx: TyCtxt<'tcx>,
}
impl<'v, 'tcx> hir::intravisit::Visitor<'v> for SpanFinder<'tcx> {
#[instrument(level = "trace", skip(self, _id))]
fn visit_path(&mut self, path: &'v hir::Path<'v>, _id: hir::HirId) {
// You can't mention an opaque type directly, so we look for type aliases
if let hir::def::Res::Def(hir::def::DefKind::TyAlias, def_id) = path.res {
// And check if that type alias's type contains the opaque type we're looking for
for arg in self.tcx.type_of(def_id).walk() {
if let GenericArgKind::Type(ty) = arg.unpack() {
if let ty::Opaque(def_id, _) = *ty.kind() {
if def_id == self.def_id {
// Finally we update the span to the mention of the type alias
self.sp = path.span;
return;
}
}
}
}
}
hir::intravisit::walk_path(self, path)
}
}

let mut visitor = SpanFinder { sp, def_id, tcx };
hir::intravisit::walk_item(&mut visitor, item);
let reported = tcx
.sess
.struct_span_err(visitor.sp, "cannot implement trait on type alias impl trait")
.span_note(tcx.def_span(def_id), "type alias impl trait defined here")
.emit();
return Err(reported);
}
}
span_bug!(sp, "opaque type not found, but `has_opaque_types` is set")
}

match traits::orphan_check(tcx, item.owner_id.to_def_id()) {
Ok(()) => {}
Err(err) => emit_orphan_check_error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ fn trait_predicate_kind<'tcx>(
| ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..)
| ty::PredicateKind::Ambiguous
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
}
}
1 change: 1 addition & 0 deletions compiler/rustc_hir_analysis/src/outlives/explicit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
| ty::PredicateKind::Coerce(..)
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..)
| ty::PredicateKind::Ambiguous
| ty::PredicateKind::TypeWellFormedFromEnv(..) => (),
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// code is looking for a self type of an unresolved
// inference variable.
| ty::PredicateKind::ClosureKind(..)
| ty::PredicateKind::Ambiguous
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
},
)
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/src/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
| ty::PredicateKind::TypeOutlives(..)
| ty::PredicateKind::ConstEvaluatable(..)
| ty::PredicateKind::ConstEquate(..)
| ty::PredicateKind::Ambiguous
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
}
});
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_infer/src/infer/at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl<'tcx> InferCtxt<'tcx> {
.normalize_fn_sig_for_diagnostic
.as_ref()
.map(|f| f.clone()),
intercrate: self.intercrate,
}
}
}
Expand Down
13 changes: 2 additions & 11 deletions compiler/rustc_infer/src/infer/canonical/query_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ use rustc_index::vec::Idx;
use rustc_index::vec::IndexVec;
use rustc_middle::arena::ArenaAllocatable;
use rustc_middle::mir::ConstraintCategory;
use rustc_middle::ty::error::TypeError;
use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::relate::TypeRelation;
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
use rustc_middle::ty::{self, BoundVar, Const, ToPredicate, Ty, TyCtxt};
use rustc_middle::ty::{self, BoundVar, ToPredicate, Ty, TyCtxt};
use rustc_span::Span;
use std::fmt::Debug;
use std::iter;
Expand Down Expand Up @@ -729,10 +728,6 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
});
}

fn const_equate(&mut self, _a: Const<'tcx>, _b: Const<'tcx>) {
span_bug!(self.cause.span(), "generic_const_exprs: unreachable `const_equate`");
}

fn normalization() -> NormalizationStrategy {
NormalizationStrategy::Eager
}
Expand All @@ -741,11 +736,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
true
}

fn register_opaque_type_obligations(
&mut self,
obligations: PredicateObligations<'tcx>,
) -> Result<(), TypeError<'tcx>> {
fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
self.obligations.extend(obligations);
Ok(())
}
}
31 changes: 31 additions & 0 deletions compiler/rustc_infer/src/infer/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,15 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
ty::Binder::dummy(predicate),
));
}

pub fn mark_ambiguous(&mut self) {
self.obligations.push(Obligation::new(
self.tcx(),
self.trace.cause.clone(),
self.param_env,
ty::Binder::dummy(ty::PredicateKind::Ambiguous),
));
}
}

struct Generalizer<'cx, 'tcx> {
Expand Down Expand Up @@ -521,6 +530,11 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx
}

fn intercrate(&self) -> bool {
self.infcx.intercrate
}

fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.param_env
}
Expand All @@ -533,6 +547,10 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
true
}

fn mark_ambiguous(&mut self) {
span_bug!(self.cause.span, "opaque types are handled in `tys`");
}

fn binders<T>(
&mut self,
a: ty::Binder<'tcx, T>,
Expand Down Expand Up @@ -657,6 +675,10 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
// relatable.
Ok(t)
}
ty::Opaque(def_id, substs) => {
let s = self.relate(substs, substs)?;
Ok(if s == substs { t } else { self.infcx.tcx.mk_opaque(def_id, s) })
}
_ => relate::super_relate_tys(self, t, t),
}?;

Expand Down Expand Up @@ -799,6 +821,11 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
self.infcx.tcx
}

fn intercrate(&self) -> bool {
assert!(!self.infcx.intercrate);
false
}

fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.param_env
}
Expand All @@ -811,6 +838,10 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
true
}

fn mark_ambiguous(&mut self) {
bug!()
}

fn relate_with_variance<T: Relate<'tcx>>(
&mut self,
_variance: ty::Variance,
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_infer/src/infer/equate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
self.fields.tcx()
}

fn intercrate(&self) -> bool {
self.fields.infcx.intercrate
}

fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}
Expand All @@ -40,6 +44,10 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
self.a_is_expected
}

fn mark_ambiguous(&mut self) {
self.fields.mark_ambiguous();
}

fn relate_item_substs(
&mut self,
_item_def_id: DefId,
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2937,6 +2937,11 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
self.0.tcx
}

fn intercrate(&self) -> bool {
assert!(!self.0.intercrate);
false
}

fn param_env(&self) -> ty::ParamEnv<'tcx> {
// Unused, only for consts which we treat as always equal
ty::ParamEnv::empty()
Expand All @@ -2950,6 +2955,10 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
true
}

fn mark_ambiguous(&mut self) {
bug!()
}

fn relate_with_variance<T: relate::Relate<'tcx>>(
&mut self,
_variance: ty::Variance,
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_infer/src/infer/glb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> {
"Glb"
}

fn intercrate(&self) -> bool {
assert!(!self.fields.infcx.intercrate);
false
}

fn tcx(&self) -> TyCtxt<'tcx> {
self.fields.tcx()
}
Expand All @@ -42,6 +47,10 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> {
self.a_is_expected
}

fn mark_ambiguous(&mut self) {
bug!("mark_ambiguous used outside of coherence");
}

fn relate_with_variance<T: Relate<'tcx>>(
&mut self,
variance: ty::Variance,
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_infer/src/infer/lub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ impl<'tcx> TypeRelation<'tcx> for Lub<'_, '_, 'tcx> {
"Lub"
}

fn intercrate(&self) -> bool {
assert!(!self.fields.infcx.intercrate);
false
}

fn tcx(&self) -> TyCtxt<'tcx> {
self.fields.tcx()
}
Expand All @@ -42,6 +47,10 @@ impl<'tcx> TypeRelation<'tcx> for Lub<'_, '_, 'tcx> {
self.a_is_expected
}

fn mark_ambiguous(&mut self) {
bug!("mark_ambiguous used outside of coherence");
}

fn relate_with_variance<T: Relate<'tcx>>(
&mut self,
variance: ty::Variance,
Expand Down
Loading