Skip to content

Rollup of 8 pull requests #100881

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 25 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
90abfe9
expand inner `or` pattern
ouz-a Jun 17, 2022
661d488
use true recursion
ouz-a Jun 24, 2022
f7d8805
Fix `Ipv6Addr::is_global` to check for global reachability rather tha…
CDirkx Jun 25, 2021
f299064
Change `Ipv4Addr::is_global` to be in line with `Ipv6Addr::is_global`
CDirkx Jun 25, 2021
3365b06
Reincorporated changes from #87689
chotchki Jul 30, 2022
f659088
Original branch seems to have missed excluding the benchmark range fr…
chotchki Jul 30, 2022
2bb7e1e
Guarantee `try_reserve` preserves the contents on error
lo48576 Aug 9, 2022
ee30cc8
make some const prop tests unit-test
Noratrieb Jul 26, 2022
ddf23cb
add new test and combine old ones
ouz-a Aug 17, 2022
ed084ba
Remove useless pointer cast
WaffleLapkin Aug 19, 2022
efef211
Make use of `pointer::is_aligned[_to]`
WaffleLapkin Aug 19, 2022
ffcaa0d
Migrate diagnostics in parser/expr to SessionDiagnostic
Xiretza Aug 17, 2022
0227b71
Add guarantee that Vec::default() does not alloc
JanBeh Aug 22, 2022
d744f36
Fix wf check on `#[const_trait]` return types
fee1-dead Aug 9, 2022
460daf3
remove stray comment
fee1-dead Aug 22, 2022
f019b6c
Overhaul 100222 test; wf always remap to nonconst
fee1-dead Aug 22, 2022
f1db3be
fix tidy
fee1-dead Aug 22, 2022
56ba13a
Rollup merge of #98200 - ouz-a:issue-98177, r=oli-obk
Dylan-DPC Aug 22, 2022
e77c208
Rollup merge of #99770 - Nilstrieb:mir-pass-unit-test, r=oli-obk
Dylan-DPC Aug 22, 2022
c1a5ec7
Rollup merge of #99957 - chotchki:ip-globally-reachable_rebase, r=Mar…
Dylan-DPC Aug 22, 2022
382ba73
Rollup merge of #100331 - lo48576:try-reserve-preserve-on-failure, r=…
Dylan-DPC Aug 22, 2022
14c8a68
Rollup merge of #100336 - fee1-dead-contrib:fix-wf-const-trait, r=oli…
Dylan-DPC Aug 22, 2022
75b7089
Rollup merge of #100713 - Xiretza:parser-expr-session-diagnostics, r=…
Dylan-DPC Aug 22, 2022
58d2373
Rollup merge of #100820 - WaffleLapkin:use_ptr_is_aligned_methods, r=…
Dylan-DPC Aug 22, 2022
4ed8fa4
Rollup merge of #100872 - JanBeh:PR_vec_default_alloc_doc, r=fee1-dead
Dylan-DPC Aug 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
Prev Previous commit
Next Next commit
Overhaul 100222 test; wf always remap to nonconst
  • Loading branch information
fee1-dead committed Aug 22, 2022
commit f019b6c5e8f2bb7e5985ea595b0946479c5aa4c2
21 changes: 5 additions & 16 deletions compiler/rustc_typeck/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,11 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
span: Span,
loc: Option<WellFormedLoc>,
arg: ty::GenericArg<'tcx>,
override_constness: Option<hir::Constness>,
) {
let cause =
traits::ObligationCause::new(span, self.body_id, ObligationCauseCode::WellFormed(loc));
let param_env = if let Some(constness) = override_constness {
self.param_env.with_constness(constness)
} else {
self.param_env
};
// for a type to be WF, we do not need to check if const trait predicates satisfy.
let param_env = self.param_env.without_const();
self.ocx.register_obligation(traits::Obligation::new(
cause,
param_env,
Expand Down Expand Up @@ -991,7 +987,7 @@ fn check_associated_item(
ty::AssocKind::Const => {
let ty = tcx.type_of(item.def_id);
let ty = wfcx.normalize(span, Some(WellFormedLoc::Ty(item_id)), ty);
wfcx.register_wf_obligation(span, loc, ty.into(), None);
wfcx.register_wf_obligation(span, loc, ty.into());
}
ty::AssocKind::Fn => {
let sig = tcx.fn_sig(item.def_id);
Expand All @@ -1012,7 +1008,7 @@ fn check_associated_item(
if item.defaultness(tcx).has_value() {
let ty = tcx.type_of(item.def_id);
let ty = wfcx.normalize(span, Some(WellFormedLoc::Ty(item_id)), ty);
wfcx.register_wf_obligation(span, loc, ty.into(), None);
wfcx.register_wf_obligation(span, loc, ty.into());
}
}
}
Expand Down Expand Up @@ -1048,7 +1044,6 @@ fn check_type_defn<'tcx, F>(
field.span,
Some(WellFormedLoc::Ty(field.def_id)),
field.ty.into(),
None,
)
}

Expand Down Expand Up @@ -1202,7 +1197,6 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: LocalDefId, ty_span: Span, allow_fo
ty_span,
Some(WellFormedLoc::Ty(item_id)),
item_ty.into(),
None,
);
if forbid_unsized {
wfcx.register_bound(
Expand Down Expand Up @@ -1272,7 +1266,6 @@ fn check_impl<'tcx>(
ast_self_ty.span,
Some(WellFormedLoc::Ty(item.hir_id().expect_owner())),
self_ty.into(),
None,
);
}
}
Expand Down Expand Up @@ -1317,7 +1310,6 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
tcx.def_span(param.def_id),
None,
ty.into(),
None,
);
}
}
Expand All @@ -1334,7 +1326,6 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
tcx.def_span(param.def_id),
None,
default_ct.into(),
None,
);
}
}
Expand Down Expand Up @@ -1463,7 +1454,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
assert_eq!(predicates.predicates.len(), predicates.spans.len());
let wf_obligations =
iter::zip(&predicates.predicates, &predicates.spans).flat_map(|(&p, &sp)| {
traits::wf::predicate_obligations(infcx, wfcx.param_env, wfcx.body_id, p, sp)
traits::wf::predicate_obligations(infcx, wfcx.param_env.without_const(), wfcx.body_id, p, sp)
});

let obligations: Vec<_> = wf_obligations.chain(default_obligations).collect();
Expand Down Expand Up @@ -1515,15 +1506,13 @@ fn check_fn_or_method<'tcx>(
ty.span,
Some(WellFormedLoc::Param { function: def_id, param_idx: i.try_into().unwrap() }),
input_ty.into(),
None,
);
}

wfcx.register_wf_obligation(
hir_decl.output.span(),
None,
sig.output().into(),
Some(hir::Constness::NotConst),
);

check_where_clauses(wfcx, span, def_id);
Expand Down
21 changes: 17 additions & 4 deletions src/test/ui/rfc-2632-const-trait-impl/issue-100222.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
// revisions: nn ny yn yy
// check-pass
#![feature(const_trait_impl)]
#![feature(const_trait_impl, associated_type_defaults, const_mut_refs)]

#[const_trait]
#[cfg_attr(any(yn, yy), const_trait)]
pub trait Index {
type Output;
}

#[const_trait]
#[cfg_attr(any(ny, yy), const_trait)]
pub trait IndexMut where Self: Index {
fn foo(&mut self) -> <Self as Index>::Output;
const C: <Self as Index>::Output;
type Assoc = <Self as Index>::Output;
fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output;
}

impl Index for () { type Output = (); }

impl const IndexMut for <() as Index>::Output {
const C: <Self as Index>::Output = ();
type Assoc = <Self as Index>::Output;
fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output where <Self as Index>::Output: {}
}

const C: <() as Index>::Output = ();

fn main() {}