Skip to content

Commit 92d5b96

Browse files
authored
Unrolled build for #149244
Rollup merge of #149244 - spastorino:fix-mem-drop-rustdoc, r=ChrisDenton Fix std::mem::drop rustdoc misleading statement This is a bit misleading, we were discussing this with our Rust team and some people could think that the compiler does some special magic for this specific function and that's not true or well the compiler does something special but for every function. The reality according to my understanding is that this is a normal function that takes ownership of the given value and as with every other function mir building injects Drop Terminators , drop elaboration refines this and then we would insert the corresponding drop glue, then potentially calling Drop::drop. Not sure if it would be best to remove the sentence as this PR does or explaining something along the lines of the previous text.
2 parents 568b117 + d60f780 commit 92d5b96

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

library/core/src/mem/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,6 @@ pub const fn replace<T>(dest: &mut T, src: T) -> T {
898898

899899
/// Disposes of a value.
900900
///
901-
/// This does so by calling the argument's implementation of [`Drop`][drop].
902-
///
903901
/// This effectively does nothing for types which implement `Copy`, e.g.
904902
/// integers. Such values are copied and _then_ moved into the function, so the
905903
/// value persists after this function call.
@@ -910,7 +908,7 @@ pub const fn replace<T>(dest: &mut T, src: T) -> T {
910908
/// pub fn drop<T>(_x: T) {}
911909
/// ```
912910
///
913-
/// Because `_x` is moved into the function, it is automatically dropped before
911+
/// Because `_x` is moved into the function, it is automatically [dropped][drop] before
914912
/// the function returns.
915913
///
916914
/// [drop]: Drop

tests/ui/thir-print/offset_of.stdout

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ body:
6868
)
6969
else_block: None
7070
lint_level: Explicit(HirId(DefId(offset_of::concrete).10))
71-
span: $DIR/offset_of.rs:37:5: 1435:57 (#0)
71+
span: $DIR/offset_of.rs:37:5: 1433:57 (#0)
7272
}
7373
}
7474
Stmt {
@@ -117,7 +117,7 @@ body:
117117
)
118118
else_block: None
119119
lint_level: Explicit(HirId(DefId(offset_of::concrete).20))
120-
span: $DIR/offset_of.rs:38:5: 1435:57 (#0)
120+
span: $DIR/offset_of.rs:38:5: 1433:57 (#0)
121121
}
122122
}
123123
Stmt {
@@ -166,7 +166,7 @@ body:
166166
)
167167
else_block: None
168168
lint_level: Explicit(HirId(DefId(offset_of::concrete).30))
169-
span: $DIR/offset_of.rs:39:5: 1435:57 (#0)
169+
span: $DIR/offset_of.rs:39:5: 1433:57 (#0)
170170
}
171171
}
172172
Stmt {
@@ -215,7 +215,7 @@ body:
215215
)
216216
else_block: None
217217
lint_level: Explicit(HirId(DefId(offset_of::concrete).40))
218-
span: $DIR/offset_of.rs:40:5: 1435:57 (#0)
218+
span: $DIR/offset_of.rs:40:5: 1433:57 (#0)
219219
}
220220
}
221221
Stmt {
@@ -264,7 +264,7 @@ body:
264264
)
265265
else_block: None
266266
lint_level: Explicit(HirId(DefId(offset_of::concrete).50))
267-
span: $DIR/offset_of.rs:41:5: 1435:57 (#0)
267+
span: $DIR/offset_of.rs:41:5: 1433:57 (#0)
268268
}
269269
}
270270
]
@@ -864,7 +864,7 @@ body:
864864
)
865865
else_block: None
866866
lint_level: Explicit(HirId(DefId(offset_of::generic).12))
867-
span: $DIR/offset_of.rs:45:5: 1435:57 (#0)
867+
span: $DIR/offset_of.rs:45:5: 1433:57 (#0)
868868
}
869869
}
870870
Stmt {
@@ -913,7 +913,7 @@ body:
913913
)
914914
else_block: None
915915
lint_level: Explicit(HirId(DefId(offset_of::generic).24))
916-
span: $DIR/offset_of.rs:46:5: 1435:57 (#0)
916+
span: $DIR/offset_of.rs:46:5: 1433:57 (#0)
917917
}
918918
}
919919
Stmt {
@@ -962,7 +962,7 @@ body:
962962
)
963963
else_block: None
964964
lint_level: Explicit(HirId(DefId(offset_of::generic).36))
965-
span: $DIR/offset_of.rs:47:5: 1435:57 (#0)
965+
span: $DIR/offset_of.rs:47:5: 1433:57 (#0)
966966
}
967967
}
968968
Stmt {
@@ -1011,7 +1011,7 @@ body:
10111011
)
10121012
else_block: None
10131013
lint_level: Explicit(HirId(DefId(offset_of::generic).48))
1014-
span: $DIR/offset_of.rs:48:5: 1435:57 (#0)
1014+
span: $DIR/offset_of.rs:48:5: 1433:57 (#0)
10151015
}
10161016
}
10171017
]

0 commit comments

Comments
 (0)