Skip to content

Commit c0e02ad

Browse files
committed
Auto merge of #68363 - Dylan-DPC:rollup-33enndv, r=Dylan-DPC
Rollup of 3 pull requests Successful merges: - #67682 ([const-prop] Remove useless typedef) - #68247 (Clean up err codes) - #68348 (Make iter::Empty<T> Send and Sync for any T) Failed merges: r? @ghost
2 parents 6250d56 + d276e69 commit c0e02ad

File tree

5 files changed

+26
-18
lines changed

5 files changed

+26
-18
lines changed

src/libcore/iter/sources.rs

+5
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ pub fn repeat_with<A, F: FnMut() -> A>(repeater: F) -> RepeatWith<F> {
208208
#[stable(feature = "iter_empty", since = "1.2.0")]
209209
pub struct Empty<T>(marker::PhantomData<T>);
210210

211+
#[stable(feature = "iter_empty_send_sync", since = "1.42.0")]
212+
unsafe impl<T> Send for Empty<T> {}
213+
#[stable(feature = "iter_empty_send_sync", since = "1.42.0")]
214+
unsafe impl<T> Sync for Empty<T> {}
215+
211216
#[stable(feature = "core_impl_debug", since = "1.9.0")]
212217
impl<T> fmt::Debug for Empty<T> {
213218
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

src/librustc_error_codes/error_codes/E0195.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Your method's lifetime parameters do not match the trait declaration.
1+
The lifetime parameters of the method do not match the trait declaration.
2+
23
Erroneous code example:
34

45
```compile_fail,E0195
@@ -16,7 +17,7 @@ impl Trait for Foo {
1617
}
1718
```
1819

19-
The lifetime constraint `'b` for bar() implementation does not match the
20+
The lifetime constraint `'b` for `bar()` implementation does not match the
2021
trait declaration. Ensure lifetime declarations match exactly in both trait
2122
declaration and implementation. Example:
2223

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1+
An inherent implementation was marked unsafe.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0197
6+
struct Foo;
7+
8+
unsafe impl Foo { } // error!
9+
```
10+
111
Inherent implementations (one that do not implement a trait but provide
212
methods associated with a type) are always safe because they are not
313
implementing an unsafe trait. Removing the `unsafe` keyword from the inherent
414
implementation will resolve this error.
515

6-
```compile_fail,E0197
16+
```
717
struct Foo;
818
9-
// this will cause this error
10-
unsafe impl Foo { }
11-
// converting it to this will fix it
12-
impl Foo { }
19+
impl Foo { } // ok!
1320
```

src/librustc_mir/transform/const_prop.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine {
288288
}
289289
}
290290

291-
type Const<'tcx> = OpTy<'tcx>;
292-
293291
/// Finds optimization opportunities on the MIR.
294292
struct ConstPropagator<'mir, 'tcx> {
295293
ecx: InterpCx<'mir, 'tcx, ConstPropMachine>,
@@ -387,7 +385,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
387385
}
388386
}
389387

390-
fn get_const(&self, local: Local) -> Option<Const<'tcx>> {
388+
fn get_const(&self, local: Local) -> Option<OpTy<'tcx>> {
391389
if local == RETURN_PLACE {
392390
// Try to read the return place as an immediate so that if it is representable as a
393391
// scalar, we can handle it as such, but otherwise, just return the value as is.
@@ -466,11 +464,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
466464
r
467465
}
468466

469-
fn eval_constant(
470-
&mut self,
471-
c: &Constant<'tcx>,
472-
source_info: SourceInfo,
473-
) -> Option<Const<'tcx>> {
467+
fn eval_constant(&mut self, c: &Constant<'tcx>, source_info: SourceInfo) -> Option<OpTy<'tcx>> {
474468
self.ecx.tcx.span = c.span;
475469

476470
// FIXME we need to revisit this for #67176
@@ -510,12 +504,12 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
510504
}
511505
}
512506

513-
fn eval_place(&mut self, place: &Place<'tcx>, source_info: SourceInfo) -> Option<Const<'tcx>> {
507+
fn eval_place(&mut self, place: &Place<'tcx>, source_info: SourceInfo) -> Option<OpTy<'tcx>> {
514508
trace!("eval_place(place={:?})", place);
515509
self.use_ecx(source_info, |this| this.ecx.eval_place_to_op(place, None))
516510
}
517511

518-
fn eval_operand(&mut self, op: &Operand<'tcx>, source_info: SourceInfo) -> Option<Const<'tcx>> {
512+
fn eval_operand(&mut self, op: &Operand<'tcx>, source_info: SourceInfo) -> Option<OpTy<'tcx>> {
519513
match *op {
520514
Operand::Constant(ref c) => self.eval_constant(c, source_info),
521515
Operand::Move(ref place) | Operand::Copy(ref place) => {
@@ -664,7 +658,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
664658
fn replace_with_const(
665659
&mut self,
666660
rval: &mut Rvalue<'tcx>,
667-
value: Const<'tcx>,
661+
value: OpTy<'tcx>,
668662
source_info: SourceInfo,
669663
) {
670664
trace!("attepting to replace {:?} with {:?}", rval, value);

src/test/ui/threads-sendsync/sync-send-iterators-in-libcore.rs

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ fn main() {
8888
is_sync_send!((1..));
8989
is_sync_send!(repeat(1));
9090
is_sync_send!(empty::<usize>());
91+
is_sync_send!(empty::<*mut i32>());
9192
is_sync_send!(once(1));
9293

9394
// for option.rs

0 commit comments

Comments
 (0)