Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 3b1c08c

Browse files
committed
Auto merge of rust-lang#73635 - Dylan-DPC:rollup-b4wbp42, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - rust-lang#71756 (add Windows system error codes that should map to io::ErrorKind::TimedOut) - rust-lang#73495 (Converted all platform-specific stdin/stdout/stderr implementations to use io:: traits) - rust-lang#73575 (Fix typo in error_codes doc) - rust-lang#73578 (Make is_freeze and is_copy_modulo_regions take TyCtxtAt) - rust-lang#73586 (switch_ty is redundant) - rust-lang#73600 (Fix spurious 'value moved here in previous iteration of loop' messages) - rust-lang#73610 (Clean up E0699 explanation) Failed merges: r? @ghost
2 parents dcd470f + e979392 commit 3b1c08c

File tree

37 files changed

+176
-114
lines changed

37 files changed

+176
-114
lines changed

src/librustc_codegen_ssa/mir/block.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
200200
targets: &Vec<mir::BasicBlock>,
201201
) {
202202
let discr = self.codegen_operand(&mut bx, &discr);
203+
// `switch_ty` is redundant, sanity-check that.
204+
assert_eq!(discr.layout.ty, switch_ty);
203205
if targets.len() == 2 {
204206
// If there are two targets, emit br instead of switch
205207
let lltrue = helper.llblock(self, targets[0]);

src/librustc_codegen_ssa/traits/type_.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
7474
}
7575

7676
fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
77-
ty.is_freeze(self.tcx(), ty::ParamEnv::reveal_all(), DUMMY_SP)
77+
ty.is_freeze(self.tcx().at(DUMMY_SP), ty::ParamEnv::reveal_all())
7878
}
7979

8080
fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool {

src/librustc_error_codes/error_codes/E0081.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
A discrimant value is present more than once.
1+
A discriminant value is present more than once.
22

33
Erroneous code example:
44

src/librustc_error_codes/error_codes/E0699.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
A method was called on a raw pointer whose inner type wasn't completely known.
22

3-
For example, you may have done something like:
3+
Erroneous code example:
44

5-
```compile_fail
5+
```compile_fail,edition2018,E0699
66
# #![deny(warnings)]
7+
# fn main() {
78
let foo = &1;
89
let bar = foo as *const _;
910
if bar.is_null() {
1011
// ...
1112
}
13+
# }
1214
```
1315

1416
Here, the type of `bar` isn't known; it could be a pointer to anything. Instead,

src/librustc_lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
562562
return;
563563
}
564564
let param_env = ty::ParamEnv::empty();
565-
if ty.is_copy_modulo_regions(cx.tcx, param_env, item.span) {
565+
if ty.is_copy_modulo_regions(cx.tcx.at(item.span), param_env) {
566566
return;
567567
}
568568
if can_type_implement_copy(cx.tcx, param_env, ty).is_ok() {

src/librustc_middle/mir/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,8 @@ pub enum TerminatorKind<'tcx> {
10751075
discr: Operand<'tcx>,
10761076

10771077
/// The type of value being tested.
1078+
/// This is always the same as the type of `discr`.
1079+
/// FIXME: remove this redundant information. Currently, it is relied on by pretty-printing.
10781080
switch_ty: Ty<'tcx>,
10791081

10801082
/// Possible values. The locations to branch to in each case

src/librustc_middle/ty/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2159,7 +2159,7 @@ where
21592159

21602160
ty::Ref(_, ty, mt) if offset.bytes() == 0 => {
21612161
let tcx = cx.tcx();
2162-
let is_freeze = ty.is_freeze(tcx, cx.param_env(), DUMMY_SP);
2162+
let is_freeze = ty.is_freeze(tcx.at(DUMMY_SP), cx.param_env());
21632163
let kind = match mt {
21642164
hir::Mutability::Not => {
21652165
if is_freeze {

src/librustc_middle/ty/util.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -681,11 +681,10 @@ impl<'tcx> ty::TyS<'tcx> {
681681
/// winds up being reported as an error during NLL borrow check.
682682
pub fn is_copy_modulo_regions(
683683
&'tcx self,
684-
tcx: TyCtxt<'tcx>,
684+
tcx_at: TyCtxtAt<'tcx>,
685685
param_env: ty::ParamEnv<'tcx>,
686-
span: Span,
687686
) -> bool {
688-
tcx.at(span).is_copy_raw(param_env.and(self))
687+
tcx_at.is_copy_raw(param_env.and(self))
689688
}
690689

691690
/// Checks whether values of this type `T` have a size known at
@@ -706,13 +705,8 @@ impl<'tcx> ty::TyS<'tcx> {
706705
/// that the `Freeze` trait is not exposed to end users and is
707706
/// effectively an implementation detail.
708707
// FIXME: use `TyCtxtAt` instead of separate `Span`.
709-
pub fn is_freeze(
710-
&'tcx self,
711-
tcx: TyCtxt<'tcx>,
712-
param_env: ty::ParamEnv<'tcx>,
713-
span: Span,
714-
) -> bool {
715-
self.is_trivially_freeze() || tcx.at(span).is_freeze_raw(param_env.and(self))
708+
pub fn is_freeze(&'tcx self, tcx_at: TyCtxtAt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool {
709+
self.is_trivially_freeze() || tcx_at.is_freeze_raw(param_env.and(self))
716710
}
717711

718712
/// Fast path helper for testing if a type is `Freeze`.

src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
138138

139139
let move_msg = if move_spans.for_closure() { " into closure" } else { "" };
140140

141-
if span == move_span {
141+
if location == move_out.source {
142142
err.span_label(
143143
span,
144144
format!("value moved{} here, in previous iteration of loop", move_msg),

src/librustc_mir/dataflow/impls/borrowed_locals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl MutBorrow<'mir, 'tcx> {
233233
///
234234
/// [rust-lang/unsafe-code-guidelines#134]: https://github.com/rust-lang/unsafe-code-guidelines/issues/134
235235
fn shared_borrow_allows_mutation(&self, place: Place<'tcx>) -> bool {
236-
!place.ty(self.body, self.tcx).ty.is_freeze(self.tcx, self.param_env, DUMMY_SP)
236+
!place.ty(self.body, self.tcx).ty.is_freeze(self.tcx.at(DUMMY_SP), self.param_env)
237237
}
238238
}
239239

0 commit comments

Comments
 (0)