Skip to content

Commit cd8377d

Browse files
committedJan 4, 2020
Auto merge of #67866 - GuillaumeGomez:rollup-32vsg5b, r=GuillaumeGomez
Rollup of 4 pull requests Successful merges: - #67822 (Revert `const_err` lint checking of casts) - #67823 (improve some `Drop`-related error messages) - #67837 (Clean up err codes) - #67848 (Remove unused `#[link_name = "m"]` attributes) Failed merges: r? @ghost
2 parents 79cf5e4 + a86a189 commit cd8377d

23 files changed

+204
-218
lines changed
 

‎src/librustc_error_codes/error_codes/E0136.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
A binary can only have one entry point, and by default that entry point is the
2-
function `main()`. If there are multiple such functions, please rename one.
1+
More than one `main` function was found.
32

43
Erroneous code example:
54

@@ -14,3 +13,7 @@ fn main() { // error!
1413
// ...
1514
}
1615
```
16+
17+
A binary can only have one entry point, and by default that entry point is the
18+
`main()` function. If there are multiple instances of this function, please
19+
rename one of them.

‎src/librustc_error_codes/error_codes/E0161.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
A value was moved. However, its size was not known at compile time, and only
2-
values of a known size can be moved.
1+
A value was moved whose size was not known at compile time.
32

43
Erroneous code example:
54

+29-9
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,44 @@
1-
This error means that an attempt was made to match a struct type enum
2-
variant as a non-struct type:
1+
Something which is neither a tuple struct nor a tuple variant was used as a
2+
pattern.
3+
4+
Erroneous code example:
35

46
```compile_fail,E0164
5-
enum Foo { B { i: u32 } }
7+
enum A {
8+
B,
9+
C,
10+
}
11+
12+
impl A {
13+
fn new() {}
14+
}
615
7-
fn bar(foo: Foo) -> u32 {
16+
fn bar(foo: A) {
817
match foo {
9-
Foo::B(i) => i, // error E0164
18+
A::new() => (), // error!
19+
_ => {}
1020
}
1121
}
1222
```
1323

14-
Try using `{}` instead:
24+
This error means that an attempt was made to match something which is neither a
25+
tuple struct nor a tuple variant. Only these two elements are allowed as a
26+
pattern:
1527

1628
```
17-
enum Foo { B { i: u32 } }
29+
enum A {
30+
B,
31+
C,
32+
}
33+
34+
impl A {
35+
fn new() {}
36+
}
1837
19-
fn bar(foo: Foo) -> u32 {
38+
fn bar(foo: A) {
2039
match foo {
21-
Foo::B{i} => i,
40+
A::B => (), // ok!
41+
_ => {}
2242
}
2343
}
2444
```

‎src/librustc_mir/transform/const_prop.rs

+7-63
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use rustc::mir::visit::{
1212
MutVisitor, MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor,
1313
};
1414
use rustc::mir::{
15-
read_only, AggregateKind, BasicBlock, BinOp, Body, BodyAndCache, CastKind, ClearCrossCrate,
16-
Constant, Local, LocalDecl, LocalKind, Location, Operand, Place, PlaceBase,
17-
ReadOnlyBodyAndCache, Rvalue, SourceInfo, SourceScope, SourceScopeData, Statement,
18-
StatementKind, Terminator, TerminatorKind, UnOp, RETURN_PLACE,
15+
read_only, AggregateKind, BasicBlock, BinOp, Body, BodyAndCache, ClearCrossCrate, Constant,
16+
Local, LocalDecl, LocalKind, Location, Operand, Place, PlaceBase, ReadOnlyBodyAndCache, Rvalue,
17+
SourceInfo, SourceScope, SourceScopeData, Statement, StatementKind, Terminator, TerminatorKind,
18+
UnOp, RETURN_PLACE,
1919
};
2020
use rustc::ty::layout::{
2121
HasDataLayout, HasTyCtxt, LayoutError, LayoutOf, Size, TargetDataLayout, TyLayout,
@@ -29,9 +29,9 @@ use syntax::ast::Mutability;
2929

3030
use crate::const_eval::error_to_const_error;
3131
use crate::interpret::{
32-
self, intern_const_alloc_recursive, truncate, AllocId, Allocation, Frame, ImmTy, Immediate,
33-
InterpCx, LocalState, LocalValue, Memory, MemoryKind, OpTy, Operand as InterpOperand, PlaceTy,
34-
Pointer, ScalarMaybeUndef, StackPopCleanup,
32+
self, intern_const_alloc_recursive, AllocId, Allocation, Frame, ImmTy, Immediate, InterpCx,
33+
LocalState, LocalValue, Memory, MemoryKind, OpTy, Operand as InterpOperand, PlaceTy, Pointer,
34+
ScalarMaybeUndef, StackPopCleanup,
3535
};
3636
use crate::rustc::ty::subst::Subst;
3737
use crate::transform::{MirPass, MirSource};
@@ -539,57 +539,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
539539
Some(())
540540
}
541541

542-
fn check_cast(
543-
&mut self,
544-
op: &Operand<'tcx>,
545-
ty: Ty<'tcx>,
546-
source_info: SourceInfo,
547-
place_layout: TyLayout<'tcx>,
548-
) -> Option<()> {
549-
if !ty.is_integral() || !op.ty(&self.local_decls, self.tcx).is_integral() {
550-
return Some(());
551-
}
552-
553-
let value = self.use_ecx(source_info, |this| {
554-
this.ecx.read_immediate(this.ecx.eval_operand(op, None)?)
555-
})?;
556-
557-
// Do not try to read bits for ZSTs. This can occur when casting an enum with one variant
558-
// to an integer. Such enums are represented as ZSTs but still have a discriminant value
559-
// which can be casted.
560-
if value.layout.is_zst() {
561-
return Some(());
562-
}
563-
564-
let value_size = value.layout.size;
565-
let value_bits = value.to_scalar().and_then(|r| r.to_bits(value_size));
566-
if let Ok(value_bits) = value_bits {
567-
let truncated = truncate(value_bits, place_layout.size);
568-
if truncated != value_bits {
569-
let scope = source_info.scope;
570-
let lint_root = match &self.source_scopes[scope].local_data {
571-
ClearCrossCrate::Set(data) => data.lint_root,
572-
ClearCrossCrate::Clear => return None,
573-
};
574-
self.tcx.lint_hir(
575-
::rustc::lint::builtin::CONST_ERR,
576-
lint_root,
577-
source_info.span,
578-
&format!(
579-
"truncating cast: the value {} requires {} bits but the target type is \
580-
only {} bits",
581-
value_bits,
582-
value_size.bits(),
583-
place_layout.size.bits()
584-
),
585-
);
586-
return None;
587-
}
588-
}
589-
590-
Some(())
591-
}
592-
593542
fn const_prop(
594543
&mut self,
595544
rvalue: &Rvalue<'tcx>,
@@ -651,11 +600,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
651600
}
652601
}
653602

654-
Rvalue::Cast(CastKind::Misc, op, ty) => {
655-
trace!("checking Cast(Misc, {:?}, {:?})", op, ty);
656-
self.check_cast(op, ty, source_info, place_layout)?;
657-
}
658-
659603
_ => {}
660604
}
661605

‎src/librustc_typeck/check/dropck.rs

+18-16
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ pub fn check_drop_impl(tcx: TyCtxt<'_>, drop_impl_did: DefId) -> Result<(), Erro
4747

4848
ensure_drop_predicates_are_implied_by_item_defn(
4949
tcx,
50-
drop_impl_did,
5150
dtor_predicates,
5251
adt_def.did,
5352
self_to_impl_substs,
@@ -95,16 +94,23 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
9594
}
9695
Err(_) => {
9796
let item_span = tcx.def_span(self_type_did);
97+
let self_descr = tcx
98+
.def_kind(self_type_did)
99+
.map(|kind| kind.descr(self_type_did))
100+
.unwrap_or("type");
98101
struct_span_err!(
99102
tcx.sess,
100103
drop_impl_span,
101104
E0366,
102-
"Implementations of Drop cannot be specialized"
105+
"`Drop` impls cannot be specialized"
103106
)
104107
.span_note(
105108
item_span,
106-
"Use same sequence of generic type and region \
107-
parameters that is on the struct/enum definition",
109+
&format!(
110+
"use the same sequence of generic type, lifetime and const parameters \
111+
as the {} definition",
112+
self_descr,
113+
),
108114
)
109115
.emit();
110116
return Err(ErrorReported);
@@ -143,7 +149,6 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
143149
/// implied by assuming the predicates attached to self_type_did.
144150
fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
145151
tcx: TyCtxt<'tcx>,
146-
drop_impl_did: DefId,
147152
dtor_predicates: ty::GenericPredicates<'tcx>,
148153
self_type_did: DefId,
149154
self_to_impl_substs: SubstsRef<'tcx>,
@@ -187,8 +192,6 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
187192

188193
let self_type_hir_id = tcx.hir().as_local_hir_id(self_type_did).unwrap();
189194

190-
let drop_impl_span = tcx.def_span(drop_impl_did);
191-
192195
// We can assume the predicates attached to struct/enum definition
193196
// hold.
194197
let generic_assumptions = tcx.predicates_of(self_type_did);
@@ -205,7 +208,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
205208
// just to look for all the predicates directly.
206209

207210
assert_eq!(dtor_predicates.parent, None);
208-
for (predicate, _) in dtor_predicates.predicates {
211+
for (predicate, predicate_sp) in dtor_predicates.predicates {
209212
// (We do not need to worry about deep analysis of type
210213
// expressions etc because the Drop impls are already forced
211214
// to take on a structure that is roughly an alpha-renaming of
@@ -241,18 +244,17 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
241244

242245
if !assumptions_in_impl_context.iter().any(predicate_matches_closure) {
243246
let item_span = tcx.hir().span(self_type_hir_id);
247+
let self_descr =
248+
tcx.def_kind(self_type_did).map(|kind| kind.descr(self_type_did)).unwrap_or("type");
244249
struct_span_err!(
245250
tcx.sess,
246-
drop_impl_span,
251+
*predicate_sp,
247252
E0367,
248-
"The requirement `{}` is added only by the Drop impl.",
249-
predicate
250-
)
251-
.span_note(
252-
item_span,
253-
"The same requirement must be part of \
254-
the struct/enum definition",
253+
"`Drop` impl requires `{}` but the {} it is implemented for does not",
254+
predicate,
255+
self_descr,
255256
)
257+
.span_note(item_span, "the implementor must specify the same requirement")
256258
.emit();
257259
result = Err(ErrorReported);
258260
}

‎src/librustc_typeck/coherence/builtin.rs

+18-29
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use rustc::ty::util::CopyImplementationError;
1313
use rustc::ty::TypeFoldable;
1414
use rustc::ty::{self, Ty, TyCtxt};
1515

16-
use hir::Node;
1716
use rustc::hir::def_id::DefId;
1817
use rustc::hir::{self, ItemKind};
1918

@@ -51,35 +50,25 @@ impl<'tcx> Checker<'tcx> {
5150
}
5251

5352
fn visit_implementation_of_drop(tcx: TyCtxt<'_>, impl_did: DefId) {
54-
if let ty::Adt(..) = tcx.type_of(impl_did).kind {
55-
/* do nothing */
56-
} else {
57-
// Destructors only work on nominal types.
58-
if let Some(impl_hir_id) = tcx.hir().as_local_hir_id(impl_did) {
59-
if let Some(Node::Item(item)) = tcx.hir().find(impl_hir_id) {
60-
let span = match item.kind {
61-
ItemKind::Impl(.., ref ty, _) => ty.span,
62-
_ => item.span,
63-
};
64-
struct_span_err!(
65-
tcx.sess,
66-
span,
67-
E0120,
68-
"the Drop trait may only be implemented on \
69-
structures"
70-
)
71-
.span_label(span, "implementing Drop requires a struct")
72-
.emit();
73-
} else {
74-
bug!("didn't find impl in ast map");
75-
}
76-
} else {
77-
bug!(
78-
"found external impl of Drop trait on \
79-
something other than a struct"
80-
);
81-
}
53+
// Destructors only work on nominal types.
54+
if let ty::Adt(..) | ty::Error = tcx.type_of(impl_did).kind {
55+
return;
8256
}
57+
58+
let impl_hir_id = tcx.hir().as_local_hir_id(impl_did).expect("foreign Drop impl on non-ADT");
59+
let sp = match tcx.hir().expect_item(impl_hir_id).kind {
60+
ItemKind::Impl(.., ty, _) => ty.span,
61+
_ => bug!("expected Drop impl item"),
62+
};
63+
64+
struct_span_err!(
65+
tcx.sess,
66+
sp,
67+
E0120,
68+
"the `Drop` trait may only be implemented for structs, enums, and unions",
69+
)
70+
.span_label(sp, "must be a struct, enum, or union")
71+
.emit();
8372
}
8473

8574
fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: DefId) {

‎src/libstd/sys/unix/cmath.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
use libc::{c_double, c_float};
44

5-
#[link_name = "m"]
65
extern "C" {
76
pub fn acos(n: c_double) -> c_double;
87
pub fn acosf(n: c_float) -> c_float;

‎src/libstd/sys/vxworks/cmath.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
use libc::{c_double, c_float};
44

5-
#[link_name = "m"]
65
extern "C" {
76
pub fn acos(n: c_double) -> c_double;
87
pub fn acosf(n: c_float) -> c_float;

‎src/libstd/sys/windows/cmath.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
use libc::{c_double, c_float};
44

5-
#[link_name = "m"]
65
extern "C" {
76
pub fn acos(n: c_double) -> c_double;
87
pub fn asin(n: c_double) -> c_double;
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
// build-fail
2-
// ignore-tidy-linelength
1+
// check-pass
2+
3+
enum Foo {
4+
Bar = -42,
5+
Baz = 42,
6+
}
37

48
fn main() {
59
let _ = 0u8 as u32;
6-
let _ = (1u32 << 31) as u16; //~ ERROR truncating cast: the value 2147483648 requires 32 bits but the target type is only 16 bits
7-
let _ = (1u16 << 15) as u8; //~ ERROR truncating cast: the value 32768 requires 16 bits but the target type is only 8 bits
8-
let _ = (!0u16) as u8; //~ ERROR truncating cast: the value 65535 requires 16 bits but the target type is only 8 bits
10+
let _ = (1u32 << 31) as u16;
11+
let _ = (1u16 << 15) as u8;
12+
let _ = (!0u16) as u8;
13+
let _ = (-1i16) as i8;
14+
let _ = (Foo::Bar) as i8;
915
}

‎src/test/ui/consts/const-prop-overflowing-casts.stderr

-22
This file was deleted.
+6-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
impl<'a> Drop for &'a mut isize {
2-
//~^ ERROR the Drop trait may only be implemented on structures
2+
//~^ ERROR the `Drop` trait may only be implemented for structs, enums, and unions
33
//~^^ ERROR E0117
44
fn drop(&mut self) {
55
println!("kaboom");
66
}
77
}
88

9+
impl Drop for Nonexistent {
10+
//~^ ERROR cannot find type `Nonexistent`
11+
fn drop(&mut self) { }
12+
}
13+
914
fn main() {
1015
}

‎src/test/ui/dropck/drop-on-non-struct.stderr

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
error[E0120]: the Drop trait may only be implemented on structures
1+
error[E0412]: cannot find type `Nonexistent` in this scope
2+
--> $DIR/drop-on-non-struct.rs:9:15
3+
|
4+
LL | impl Drop for Nonexistent {
5+
| ^^^^^^^^^^^ not found in this scope
6+
7+
error[E0120]: the `Drop` trait may only be implemented for structs, enums, and unions
28
--> $DIR/drop-on-non-struct.rs:1:19
39
|
410
LL | impl<'a> Drop for &'a mut isize {
5-
| ^^^^^^^^^^^^^ implementing Drop requires a struct
11+
| ^^^^^^^^^^^^^ must be a struct, enum, or union
612

713
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
814
--> $DIR/drop-on-non-struct.rs:1:1
@@ -15,7 +21,7 @@ LL | impl<'a> Drop for &'a mut isize {
1521
|
1622
= note: define and implement a trait or new type instead
1723

18-
error: aborting due to 2 previous errors
24+
error: aborting due to 3 previous errors
1925

20-
Some errors have detailed explanations: E0117, E0120.
26+
Some errors have detailed explanations: E0117, E0120, E0412.
2127
For more information about an error, try `rustc --explain E0117`.

‎src/test/ui/error-codes/E0117.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
impl Drop for u32 {} //~ ERROR E0117
2-
//~| ERROR the Drop trait may only be implemented on structures
3-
//~| implementing Drop requires a struct
2+
//~| ERROR the `Drop` trait may only be implemented for structs, enums, and unions
43

54
fn main() {
65
}

‎src/test/ui/error-codes/E0117.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0120]: the Drop trait may only be implemented on structures
1+
error[E0120]: the `Drop` trait may only be implemented for structs, enums, and unions
22
--> $DIR/E0117.rs:1:15
33
|
44
LL | impl Drop for u32 {}
5-
| ^^^ implementing Drop requires a struct
5+
| ^^^ must be a struct, enum, or union
66

77
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
88
--> $DIR/E0117.rs:1:1

‎src/test/ui/error-codes/E0120.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0120]: the Drop trait may only be implemented on structures
1+
error[E0120]: the `Drop` trait may only be implemented for structs, enums, and unions
22
--> $DIR/E0120.rs:3:15
33
|
44
LL | impl Drop for dyn MyTrait {
5-
| ^^^^^^^^^^^ implementing Drop requires a struct
5+
| ^^^^^^^^^^^ must be a struct, enum, or union
66

77
error: aborting due to previous error
88

‎src/test/ui/issues/issue-17959.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct G<T: ?Sized> {
99
}
1010

1111
impl<T> Drop for G<T> {
12-
//~^ ERROR: The requirement `T: std::marker::Sized` is added only by the Drop impl. [E0367]
12+
//~^ ERROR `Drop` impl requires `T: std::marker::Sized`
1313
fn drop(&mut self) {
1414
if !self._ptr.is_null() {
1515
}

‎src/test/ui/issues/issue-17959.stderr

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
error[E0367]: The requirement `T: std::marker::Sized` is added only by the Drop impl.
2-
--> $DIR/issue-17959.rs:11:1
1+
error[E0367]: `Drop` impl requires `T: std::marker::Sized` but the struct it is implemented for does not
2+
--> $DIR/issue-17959.rs:11:6
33
|
4-
LL | / impl<T> Drop for G<T> {
5-
LL | |
6-
LL | | fn drop(&mut self) {
7-
LL | | if !self._ptr.is_null() {
8-
LL | | }
9-
LL | | }
10-
LL | | }
11-
| |_^
4+
LL | impl<T> Drop for G<T> {
5+
| ^
126
|
13-
note: The same requirement must be part of the struct/enum definition
7+
note: the implementor must specify the same requirement
148
--> $DIR/issue-17959.rs:7:1
159
|
1610
LL | / struct G<T: ?Sized> {

‎src/test/ui/issues/issue-38868.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0366]: Implementations of Drop cannot be specialized
1+
error[E0366]: `Drop` impls cannot be specialized
22
--> $DIR/issue-38868.rs:5:1
33
|
44
LL | / impl Drop for List<i32> {
@@ -8,7 +8,7 @@ LL | | }
88
LL | | }
99
| |_^
1010
|
11-
note: Use same sequence of generic type and region parameters that is on the struct/enum definition
11+
note: use the same sequence of generic type, lifetime and const parameters as the struct definition
1212
--> $DIR/issue-38868.rs:1:1
1313
|
1414
LL | / pub struct List<T> {

‎src/test/ui/issues/issue-41974.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ LL | impl<T> Drop for T where T: A {
99
where T: ?Sized;
1010
= note: downstream crates may implement trait `A` for type `std::boxed::Box<_>`
1111

12-
error[E0120]: the Drop trait may only be implemented on structures
12+
error[E0120]: the `Drop` trait may only be implemented for structs, enums, and unions
1313
--> $DIR/issue-41974.rs:7:18
1414
|
1515
LL | impl<T> Drop for T where T: A {
16-
| ^ implementing Drop requires a struct
16+
| ^ must be a struct, enum, or union
1717

1818
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
1919
--> $DIR/issue-41974.rs:7:6

‎src/test/ui/reject-specialized-drops-8142.rs

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Issue 8142: Test that Drop impls cannot be specialized beyond the
2-
// predicates attached to the struct/enum definition itself.
2+
// predicates attached to the type definition itself.
33

44
trait Bound { fn foo(&self) { } }
55
struct K<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 }
@@ -16,12 +16,16 @@ struct U;
1616
struct V<Tva, Tvb> { x: *const Tva, y: *const Tvb }
1717
struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 }
1818

19+
enum Enum<T> { Variant(T) }
20+
struct TupleStruct<T>(T);
21+
union Union<T: Copy> { f: T }
22+
1923
impl<'al,'adds_bnd:'al> Drop for K<'al,'adds_bnd> { // REJECT
20-
//~^ ERROR The requirement `'adds_bnd : 'al` is added only by the Drop impl.
24+
//~^ ERROR `Drop` impl requires `'adds_bnd : 'al`
2125
fn drop(&mut self) { } }
2226

2327
impl<'al,'adds_bnd> Drop for L<'al,'adds_bnd> where 'adds_bnd:'al { // REJECT
24-
//~^ ERROR The requirement `'adds_bnd : 'al` is added only by the Drop impl.
28+
//~^ ERROR `Drop` impl requires `'adds_bnd : 'al`
2529
fn drop(&mut self) { } }
2630

2731
impl<'ml> Drop for M<'ml> { fn drop(&mut self) { } } // ACCEPT
@@ -34,13 +38,13 @@ impl Drop for N<'static> { fn drop(&mut self) { } } // RE
3438
impl<COkNoBound> Drop for O<COkNoBound> { fn drop(&mut self) { } } // ACCEPT
3539

3640
impl Drop for P<i8> { fn drop(&mut self) { } } // REJECT
37-
//~^ ERROR Implementations of Drop cannot be specialized
41+
//~^ ERROR `Drop` impls cannot be specialized
3842

3943
impl<AddsBnd:Bound> Drop for Q<AddsBnd> { fn drop(&mut self) { } } // REJECT
40-
//~^ ERROR The requirement `AddsBnd: Bound` is added only by the Drop impl.
44+
//~^ ERROR `Drop` impl requires `AddsBnd: Bound`
4145

4246
impl<'rbnd,AddsRBnd:'rbnd> Drop for R<AddsRBnd> { fn drop(&mut self) { } } // REJECT
43-
//~^ ERROR The requirement `AddsRBnd : 'rbnd` is added only by the Drop impl.
47+
//~^ ERROR `Drop` impl requires `AddsRBnd : 'rbnd`
4448

4549
impl<Bs:Bound> Drop for S<Bs> { fn drop(&mut self) { } } // ACCEPT
4650

@@ -49,9 +53,18 @@ impl<'t,Bt:'t> Drop for T<'t,Bt> { fn drop(&mut self) { } } // ACCEPT
4953
impl Drop for U { fn drop(&mut self) { } } // ACCEPT
5054

5155
impl<One> Drop for V<One,One> { fn drop(&mut self) { } } // REJECT
52-
//~^ ERROR Implementations of Drop cannot be specialized
56+
//~^ ERROR `Drop` impls cannot be specialized
5357

5458
impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT
5559
//~^ ERROR cannot infer an appropriate lifetime for lifetime parameter `'lw`
5660

61+
impl<AddsBnd:Bound> Drop for Enum<AddsBnd> { fn drop(&mut self) { } } // REJECT
62+
//~^ ERROR `Drop` impl requires `AddsBnd: Bound`
63+
64+
impl<AddsBnd:Bound> Drop for TupleStruct<AddsBnd> { fn drop(&mut self) { } } // REJECT
65+
//~^ ERROR `Drop` impl requires `AddsBnd: Bound`
66+
67+
impl<AddsBnd:Copy + Bound> Drop for Union<AddsBnd> { fn drop(&mut self) { } } // REJECT
68+
//~^ ERROR `Drop` impl requires `AddsBnd: Bound`
69+
5770
pub fn main() { }
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
1-
error[E0367]: The requirement `'adds_bnd : 'al` is added only by the Drop impl.
2-
--> $DIR/reject-specialized-drops-8142.rs:19:1
1+
error[E0367]: `Drop` impl requires `AddsBnd: Bound` but the union it is implemented for does not
2+
--> $DIR/reject-specialized-drops-8142.rs:67:21
3+
|
4+
LL | impl<AddsBnd:Copy + Bound> Drop for Union<AddsBnd> { fn drop(&mut self) { } } // REJECT
5+
| ^^^^^
6+
|
7+
note: the implementor must specify the same requirement
8+
--> $DIR/reject-specialized-drops-8142.rs:21:1
9+
|
10+
LL | union Union<T: Copy> { f: T }
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error[E0367]: `Drop` impl requires `'adds_bnd : 'al` but the struct it is implemented for does not
14+
--> $DIR/reject-specialized-drops-8142.rs:23:20
315
|
4-
LL | / impl<'al,'adds_bnd:'al> Drop for K<'al,'adds_bnd> { // REJECT
5-
LL | |
6-
LL | | fn drop(&mut self) { } }
7-
| |____________________________^
16+
LL | impl<'al,'adds_bnd:'al> Drop for K<'al,'adds_bnd> { // REJECT
17+
| ^^^
818
|
9-
note: The same requirement must be part of the struct/enum definition
19+
note: the implementor must specify the same requirement
1020
--> $DIR/reject-specialized-drops-8142.rs:5:1
1121
|
1222
LL | struct K<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 }
1323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1424

15-
error[E0367]: The requirement `'adds_bnd : 'al` is added only by the Drop impl.
16-
--> $DIR/reject-specialized-drops-8142.rs:23:1
25+
error[E0367]: `Drop` impl requires `'adds_bnd : 'al` but the struct it is implemented for does not
26+
--> $DIR/reject-specialized-drops-8142.rs:27:67
1727
|
18-
LL | / impl<'al,'adds_bnd> Drop for L<'al,'adds_bnd> where 'adds_bnd:'al { // REJECT
19-
LL | |
20-
LL | | fn drop(&mut self) { } }
21-
| |____________________________^
28+
LL | impl<'al,'adds_bnd> Drop for L<'al,'adds_bnd> where 'adds_bnd:'al { // REJECT
29+
| ^^^
2230
|
23-
note: The same requirement must be part of the struct/enum definition
31+
note: the implementor must specify the same requirement
2432
--> $DIR/reject-specialized-drops-8142.rs:6:1
2533
|
2634
LL | struct L<'l1,'l2> { x: &'l1 i8, y: &'l2 u8 }
2735
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2836

2937
error[E0308]: mismatched types
30-
--> $DIR/reject-specialized-drops-8142.rs:29:1
38+
--> $DIR/reject-specialized-drops-8142.rs:33:1
3139
|
3240
LL | impl Drop for N<'static> { fn drop(&mut self) { } } // REJECT
3341
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
@@ -41,56 +49,56 @@ LL | struct N<'n> { x: &'n i8 }
4149
| ^^
4250
= note: ...does not necessarily outlive the static lifetime
4351

44-
error[E0366]: Implementations of Drop cannot be specialized
45-
--> $DIR/reject-specialized-drops-8142.rs:36:1
52+
error[E0366]: `Drop` impls cannot be specialized
53+
--> $DIR/reject-specialized-drops-8142.rs:40:1
4654
|
4755
LL | impl Drop for P<i8> { fn drop(&mut self) { } } // REJECT
4856
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4957
|
50-
note: Use same sequence of generic type and region parameters that is on the struct/enum definition
58+
note: use the same sequence of generic type, lifetime and const parameters as the struct definition
5159
--> $DIR/reject-specialized-drops-8142.rs:10:1
5260
|
5361
LL | struct P<Tp> { x: *const Tp }
5462
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5563

56-
error[E0367]: The requirement `AddsBnd: Bound` is added only by the Drop impl.
57-
--> $DIR/reject-specialized-drops-8142.rs:39:1
64+
error[E0367]: `Drop` impl requires `AddsBnd: Bound` but the struct it is implemented for does not
65+
--> $DIR/reject-specialized-drops-8142.rs:43:14
5866
|
5967
LL | impl<AddsBnd:Bound> Drop for Q<AddsBnd> { fn drop(&mut self) { } } // REJECT
60-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
68+
| ^^^^^
6169
|
62-
note: The same requirement must be part of the struct/enum definition
70+
note: the implementor must specify the same requirement
6371
--> $DIR/reject-specialized-drops-8142.rs:11:1
6472
|
6573
LL | struct Q<Tq> { x: *const Tq }
6674
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6775

68-
error[E0367]: The requirement `AddsRBnd : 'rbnd` is added only by the Drop impl.
69-
--> $DIR/reject-specialized-drops-8142.rs:42:1
76+
error[E0367]: `Drop` impl requires `AddsRBnd : 'rbnd` but the struct it is implemented for does not
77+
--> $DIR/reject-specialized-drops-8142.rs:46:21
7078
|
7179
LL | impl<'rbnd,AddsRBnd:'rbnd> Drop for R<AddsRBnd> { fn drop(&mut self) { } } // REJECT
72-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80+
| ^^^^^
7381
|
74-
note: The same requirement must be part of the struct/enum definition
82+
note: the implementor must specify the same requirement
7583
--> $DIR/reject-specialized-drops-8142.rs:12:1
7684
|
7785
LL | struct R<Tr> { x: *const Tr }
7886
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7987

80-
error[E0366]: Implementations of Drop cannot be specialized
81-
--> $DIR/reject-specialized-drops-8142.rs:51:1
88+
error[E0366]: `Drop` impls cannot be specialized
89+
--> $DIR/reject-specialized-drops-8142.rs:55:1
8290
|
8391
LL | impl<One> Drop for V<One,One> { fn drop(&mut self) { } } // REJECT
8492
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8593
|
86-
note: Use same sequence of generic type and region parameters that is on the struct/enum definition
94+
note: use the same sequence of generic type, lifetime and const parameters as the struct definition
8795
--> $DIR/reject-specialized-drops-8142.rs:16:1
8896
|
8997
LL | struct V<Tva, Tvb> { x: *const Tva, y: *const Tvb }
9098
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9199

92100
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'lw` due to conflicting requirements
93-
--> $DIR/reject-specialized-drops-8142.rs:54:1
101+
--> $DIR/reject-specialized-drops-8142.rs:58:1
94102
|
95103
LL | impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT
96104
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -106,14 +114,38 @@ note: ...but the lifetime must also be valid for the lifetime `'l2` as defined o
106114
LL | struct W<'l1, 'l2> { x: &'l1 i8, y: &'l2 u8 }
107115
| ^^^
108116
note: ...so that the types are compatible
109-
--> $DIR/reject-specialized-drops-8142.rs:54:1
117+
--> $DIR/reject-specialized-drops-8142.rs:58:1
110118
|
111119
LL | impl<'lw> Drop for W<'lw,'lw> { fn drop(&mut self) { } } // REJECT
112120
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
113121
= note: expected `W<'l1, 'l2>`
114122
found `W<'_, '_>`
115123

116-
error: aborting due to 8 previous errors
124+
error[E0367]: `Drop` impl requires `AddsBnd: Bound` but the enum it is implemented for does not
125+
--> $DIR/reject-specialized-drops-8142.rs:61:14
126+
|
127+
LL | impl<AddsBnd:Bound> Drop for Enum<AddsBnd> { fn drop(&mut self) { } } // REJECT
128+
| ^^^^^
129+
|
130+
note: the implementor must specify the same requirement
131+
--> $DIR/reject-specialized-drops-8142.rs:19:1
132+
|
133+
LL | enum Enum<T> { Variant(T) }
134+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
135+
136+
error[E0367]: `Drop` impl requires `AddsBnd: Bound` but the struct it is implemented for does not
137+
--> $DIR/reject-specialized-drops-8142.rs:64:14
138+
|
139+
LL | impl<AddsBnd:Bound> Drop for TupleStruct<AddsBnd> { fn drop(&mut self) { } } // REJECT
140+
| ^^^^^
141+
|
142+
note: the implementor must specify the same requirement
143+
--> $DIR/reject-specialized-drops-8142.rs:20:1
144+
|
145+
LL | struct TupleStruct<T>(T);
146+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
147+
148+
error: aborting due to 11 previous errors
117149

118150
Some errors have detailed explanations: E0308, E0366, E0367, E0495.
119151
For more information about an error, try `rustc --explain E0308`.

‎src/test/ui/simd/simd-intrinsic-generic-cast.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#![feature(repr_simd, platform_intrinsics, concat_idents, test)]
66
#![allow(non_camel_case_types)]
7-
#![allow(const_err)] // the test macro casts i32s to i8 and u8 which causes lots of warnings
87

98
extern crate test;
109

0 commit comments

Comments
 (0)
Please sign in to comment.