Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ee3fc9d
never consider unsafe blocks unused if they would be required with un…
RalfJung Aug 2, 2022
3e44ca9
remove some unused code and types
RalfJung Aug 2, 2022
35a35d8
update comment
RalfJung Aug 2, 2022
86e2ca3
add link to discussion
RalfJung Aug 2, 2022
3c8563a
make NOP dyn casts not require anything about the vtable
RalfJung Aug 6, 2022
4a5c46f
Manually implement Debug for ImportKind.
cjgillot Aug 15, 2022
611221d
Update compiler/rustc_resolve/src/imports.rs
cjgillot Aug 15, 2022
fd934c9
Do not allow Drop impl on foreign fundamental types
compiler-errors Jul 21, 2022
7b45718
pass when where clause found
ouz-a Aug 13, 2022
86645c9
Ignore substs when checking inlining history.
cjgillot Aug 14, 2022
2d968a1
Simplify rustdoc themes by relying more on CSS variables
GuillaumeGomez Aug 13, 2022
9898793
Update existing rustdoc-gui tests and add a new one
GuillaumeGomez Aug 13, 2022
09396fc
Remove unused CSS rule
GuillaumeGomez Aug 18, 2022
05ed13b
ADD - diagnostic lints to type_ir
JhonnyBillM Aug 18, 2022
748c606
rustdoc: count deref and non-deref as same set of used methods
notriddle Aug 18, 2022
0788442
Rollup merge of #99576 - compiler-errors:foreign-fundamental-drop-is-…
Dylan-DPC Aug 19, 2022
2fe2975
Rollup merge of #100081 - RalfJung:unused-unsafe-in-unsafe-fn, r=jack…
Dylan-DPC Aug 19, 2022
c4707ff
Rollup merge of #100208 - RalfJung:dyn-upcast-nop, r=petrochenkov
Dylan-DPC Aug 19, 2022
3cebcba
Rollup merge of #100494 - GuillaumeGomez:cleanup-themes, r=jsha
Dylan-DPC Aug 19, 2022
d83abe8
Rollup merge of #100522 - cjgillot:inline-polymorphic-recursion, r=tm…
Dylan-DPC Aug 19, 2022
769ad70
Rollup merge of #100592 - cjgillot:debug-import-kind, r=TaKO8Ki
Dylan-DPC Aug 19, 2022
490d04b
Rollup merge of #100598 - ouz-a:91633, r=compiler-errors
Dylan-DPC Aug 19, 2022
30e65ce
Rollup merge of #100721 - JhonnyBillM:enable-diag-lint-in-type-ir, r=…
Dylan-DPC Aug 19, 2022
ecd2885
Rollup merge of #100731 - notriddle:notriddle/deref-methods-1, r=jsha
Dylan-DPC Aug 19, 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
4 changes: 2 additions & 2 deletions compiler/rustc_error_messages/locales/en-US/typeck.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ typeck_lifetimes_or_bounds_mismatch_on_trait =
.generics_label = lifetimes in impl do not match this {$item_kind} in trait

typeck_drop_impl_on_wrong_item =
the `Drop` trait may only be implemented for structs, enums, and unions
.label = must be a struct, enum, or union
the `Drop` trait may only be implemented for local structs, enums, and unions
.label = must be a struct, enum, or union in the current crate

typeck_field_already_declared =
field `{$field_name}` is already declared
Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_typeck/src/coherence/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ impl<'tcx> Checker<'tcx> {
}

fn visit_implementation_of_drop(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
// Destructors only work on nominal types.
if let ty::Adt(..) | ty::Error(_) = tcx.type_of(impl_did).kind() {
return;
// Destructors only work on local ADT types.
match tcx.type_of(impl_did).kind() {
ty::Adt(def, _) if def.did().is_local() => return,
ty::Error(_) => return,
_ => {}
}

let sp = match tcx.hir().expect_item(impl_did).kind {
Expand Down
23 changes: 23 additions & 0 deletions src/test/ui/drop/drop-foreign-fundamental.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use std::ops::Deref;
use std::pin::Pin;

struct Whatever<T>(T);

impl<T> Deref for Whatever<T> {
type Target = T;

fn deref(&self) -> &T {
&self.0
}
}

struct A;

impl Drop for Pin<Whatever<A>> {
//~^ ERROR the `Drop` trait may only be implemented for local structs, enums, and unions
fn drop(&mut self) {}
}

fn main() {
let x = Pin::new(Whatever(1.0f32));
}
9 changes: 9 additions & 0 deletions src/test/ui/drop/drop-foreign-fundamental.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0120]: the `Drop` trait may only be implemented for local structs, enums, and unions
--> $DIR/drop-foreign-fundamental.rs:16:15
|
LL | impl Drop for Pin<Whatever<A>> {
| ^^^^^^^^^^^^^^^^ must be a struct, enum, or union in the current crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0120`.
7 changes: 3 additions & 4 deletions src/test/ui/dropck/drop-on-non-struct.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
impl<'a> Drop for &'a mut isize {
//~^ ERROR the `Drop` trait may only be implemented for structs, enums, and unions
//~^ ERROR the `Drop` trait may only be implemented for local structs, enums, and unions
//~^^ ERROR E0117
fn drop(&mut self) {
println!("kaboom");
Expand All @@ -8,8 +8,7 @@ impl<'a> Drop for &'a mut isize {

impl Drop for Nonexistent {
//~^ ERROR cannot find type `Nonexistent`
fn drop(&mut self) { }
fn drop(&mut self) {}
}

fn main() {
}
fn main() {}
4 changes: 2 additions & 2 deletions src/test/ui/dropck/drop-on-non-struct.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ LL | impl<'a> Drop for &'a mut isize {
|
= note: define and implement a trait or new type instead

error[E0120]: the `Drop` trait may only be implemented for structs, enums, and unions
error[E0120]: the `Drop` trait may only be implemented for local structs, enums, and unions
--> $DIR/drop-on-non-struct.rs:1:19
|
LL | impl<'a> Drop for &'a mut isize {
| ^^^^^^^^^^^^^ must be a struct, enum, or union
| ^^^^^^^^^^^^^ must be a struct, enum, or union in the current crate

error: aborting due to 3 previous errors

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0117.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
impl Drop for u32 {} //~ ERROR E0117
//~| ERROR the `Drop` trait may only be implemented for structs, enums, and unions
//~| ERROR the `Drop` trait may only be implemented for local structs, enums, and unions

fn main() {}
4 changes: 2 additions & 2 deletions src/test/ui/error-codes/E0117.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ LL | impl Drop for u32 {}
|
= note: define and implement a trait or new type instead

error[E0120]: the `Drop` trait may only be implemented for structs, enums, and unions
error[E0120]: the `Drop` trait may only be implemented for local structs, enums, and unions
--> $DIR/E0117.rs:1:15
|
LL | impl Drop for u32 {}
| ^^^ must be a struct, enum, or union
| ^^^ must be a struct, enum, or union in the current crate

error: aborting due to 2 previous errors

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/error-codes/E0120.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0120]: the `Drop` trait may only be implemented for structs, enums, and unions
error[E0120]: the `Drop` trait may only be implemented for local structs, enums, and unions
--> $DIR/E0120.rs:3:15
|
LL | impl Drop for dyn MyTrait {
| ^^^^^^^^^^^ must be a struct, enum, or union
| ^^^^^^^^^^^ must be a struct, enum, or union in the current crate

error: aborting due to previous error

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-41974.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ LL | impl<T> Drop for T where T: A {
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
= note: only traits defined in the current crate can be implemented for a type parameter

error[E0120]: the `Drop` trait may only be implemented for structs, enums, and unions
error[E0120]: the `Drop` trait may only be implemented for local structs, enums, and unions
--> $DIR/issue-41974.rs:7:18
|
LL | impl<T> Drop for T where T: A {
| ^ must be a struct, enum, or union
| ^ must be a struct, enum, or union in the current crate

error: aborting due to 2 previous errors

Expand Down