Skip to content

Commit ddca1e0

Browse files
committed
Auto merge of #67202 - JohnTitor:rollup-0xjm5pz, r=JohnTitor
Rollup of 9 pull requests Successful merges: - #66377 (Update RELEASES.md for 1.40.0) - #67134 (Ensure that we get a hard error on generic ZST constants if their bod…) - #67152 (Sort auto trait and blanket implementations display) - #67154 (Fix typos in src/libcore/alloc.rs docs) - #67168 (corrected comment in E0478) - #67178 (Move non clean impls items) - #67180 (doc: Use .copied() instead of .cloned() in Vec example) - #67181 (Update hashmap doc) - #67193 (In which we start tracking polonius in `-Z self-profile`) Failed merges: r? @ghost
2 parents a233302 + 398ed7f commit ddca1e0

File tree

19 files changed

+882
-646
lines changed

19 files changed

+882
-646
lines changed

RELEASES.md

+137
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,140 @@
1+
Version 1.40.0 (2019-12-19)
2+
===========================
3+
4+
Language
5+
--------
6+
- [You can now use tuple `struct`s and tuple `enum` variant's constructors in
7+
`const` contexts.][65188] e.g.
8+
9+
```rust
10+
pub struct Point(i32, i32);
11+
12+
const ORIGIN: Point = {
13+
let constructor = Point;
14+
15+
constructor(0, 0)
16+
};
17+
```
18+
19+
- [You can now mark `struct`s, `enum`s, and `enum` variants with the `#[non_exhaustive]` attribute to
20+
indicate that there may be variants or fields added in the future.][64639]
21+
For example this requires adding a wild-card branch (`_ => {}`) to any match
22+
statements on a non-exhaustive `enum`. [(RFC 2008)]
23+
- [You can now use function-like procedural macros in `extern` blocks and in
24+
type positions.][63931] e.g. `type Generated = macro!();`
25+
- [Function-like and attribute procedural macros can now emit
26+
`macro_rules!` items, so you can now have your macros generate macros.][64035]
27+
- [The `meta` pattern matcher in `macro_rules!` now correctly matches the modern
28+
attribute syntax.][63674] For example `(#[$m:meta])` now matches `#[attr]`,
29+
`#[attr{tokens}]`, `#[attr[tokens]]`, and `#[attr(tokens)]`.
30+
31+
Compiler
32+
--------
33+
- [Added tier 3 support\* for the
34+
`thumbv7neon-unknown-linux-musleabihf` target.][66103]
35+
- [Added tier 3 support for the
36+
`aarch64-unknown-none-softfloat` target.][64589]
37+
- [Added tier 3 support for the `mips64-unknown-linux-muslabi64`, and
38+
`mips64el-unknown-linux-muslabi64` targets.][65843]
39+
40+
\* Refer to Rust's [platform support page][forge-platform-support] for more
41+
information on Rust's tiered platform support.
42+
43+
Libraries
44+
---------
45+
- [The `is_power_of_two` method on unsigned numeric types is now a `const` function.][65092]
46+
47+
Stabilized APIs
48+
---------------
49+
- [`BTreeMap::get_key_value`]
50+
- [`HashMap::get_key_value`]
51+
- [`Option::as_deref_mut`]
52+
- [`Option::as_deref`]
53+
- [`Option::flatten`]
54+
- [`UdpSocket::peer_addr`]
55+
- [`f32::to_be_bytes`]
56+
- [`f32::to_le_bytes`]
57+
- [`f32::to_ne_bytes`]
58+
- [`f64::to_be_bytes`]
59+
- [`f64::to_le_bytes`]
60+
- [`f64::to_ne_bytes`]
61+
- [`f32::from_be_bytes`]
62+
- [`f32::from_le_bytes`]
63+
- [`f32::from_ne_bytes`]
64+
- [`f64::from_be_bytes`]
65+
- [`f64::from_le_bytes`]
66+
- [`f64::from_ne_bytes`]
67+
- [`mem::take`]
68+
- [`slice::repeat`]
69+
- [`todo!`]
70+
71+
Cargo
72+
-----
73+
- [Cargo will now always display warnings, rather than only on
74+
fresh builds.][cargo/7450]
75+
- [Feature flags (except `--all-features`) passed to a virtual workspace will
76+
now produce an error.][cargo/7507] Previously these flags were ignored.
77+
- [You can now publish `dev-dependencies` without including
78+
a `version`.][cargo/7333]
79+
80+
Misc
81+
----
82+
- [You can now specify the `#[cfg(doctest)]` attribute to include an item only
83+
when running documentation tests with `rustdoc`.][63803]
84+
85+
Compatibility Notes
86+
-------------------
87+
- [As previously announced, any previous NLL warnings in the 2015 edition are
88+
now hard errors.][64221]
89+
- [The `include!` macro will now warn if it failed to include the
90+
entire file.][64284] The `include!` macro unintentionally only includes the
91+
first _expression_ in a file, and this can be unintuitive. This will become
92+
either a hard error in a future release, or the behavior may be fixed to include all expressions as expected.
93+
- [Using `#[inline]` on function prototypes and consts now emits a warning under
94+
`unused_attribute` lint.][65294] Using `#[inline]` anywhere else inside traits
95+
or `extern` blocks now correctly emits a hard error.
96+
97+
[65294]: https://github.com/rust-lang/rust/pull/65294/
98+
[66103]: https://github.com/rust-lang/rust/pull/66103/
99+
[65843]: https://github.com/rust-lang/rust/pull/65843/
100+
[65188]: https://github.com/rust-lang/rust/pull/65188/
101+
[65092]: https://github.com/rust-lang/rust/pull/65092/
102+
[64589]: https://github.com/rust-lang/rust/pull/64589/
103+
[64639]: https://github.com/rust-lang/rust/pull/64639/
104+
[64221]: https://github.com/rust-lang/rust/pull/64221/
105+
[64284]: https://github.com/rust-lang/rust/pull/64284/
106+
[63931]: https://github.com/rust-lang/rust/pull/63931/
107+
[64035]: https://github.com/rust-lang/rust/pull/64035/
108+
[63674]: https://github.com/rust-lang/rust/pull/63674/
109+
[63803]: https://github.com/rust-lang/rust/pull/63803/
110+
[cargo/7450]: https://github.com/rust-lang/cargo/pull/7450/
111+
[cargo/7507]: https://github.com/rust-lang/cargo/pull/7507/
112+
[cargo/7525]: https://github.com/rust-lang/cargo/pull/7525/
113+
[cargo/7333]: https://github.com/rust-lang/cargo/pull/7333/
114+
[(rfc 2008)]: https://rust-lang.github.io/rfcs/2008-non-exhaustive.html
115+
[`f32::to_be_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.to_be_bytes
116+
[`f32::to_le_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.to_le_bytes
117+
[`f32::to_ne_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.to_ne_bytes
118+
[`f64::to_be_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.to_be_bytes
119+
[`f64::to_le_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.to_le_bytes
120+
[`f64::to_ne_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.to_ne_bytes
121+
[`f32::from_be_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.from_be_bytes
122+
[`f32::from_le_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.from_le_bytes
123+
[`f32::from_ne_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.from_ne_bytes
124+
[`f64::from_be_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.from_be_bytes
125+
[`f64::from_le_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.from_le_bytes
126+
[`f64::from_ne_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.from_ne_bytes
127+
[`option::flatten`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.flatten
128+
[`option::as_deref`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.as_deref
129+
[`option::as_deref_mut`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.as_deref_mut
130+
[`hashmap::get_key_value`]: https://doc.rust-lang.org/std/collections/struct.HashMap.html#method.get_key_value
131+
[`btreemap::get_key_value`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.get_key_value
132+
[`slice::repeat`]: https://doc.rust-lang.org/std/primitive.slice.html#method.repeat
133+
[`mem::take`]: https://doc.rust-lang.org/std/mem/fn.take.html
134+
[`udpsocket::peer_addr`]: https://doc.rust-lang.org/std/net/struct.UdpSocket.html#method.peer_addr
135+
[`todo!`]: https://doc.rust-lang.org/std/macro.todo.html
136+
137+
1138
Version 1.39.0 (2019-11-07)
2139
===========================
3140

src/liballoc/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ use crate::raw_vec::RawVec;
9292
/// vec[0] = 7;
9393
/// assert_eq!(vec[0], 7);
9494
///
95-
/// vec.extend([1, 2, 3].iter().cloned());
95+
/// vec.extend([1, 2, 3].iter().copied());
9696
///
9797
/// for x in &vec {
9898
/// println!("{}", x);

src/libcore/alloc.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl Layout {
253253

254254
/// Creates a layout describing the record for `self` followed by
255255
/// `next`, including any necessary padding to ensure that `next`
256-
/// will be properly aligned. Note that the result layout will
256+
/// will be properly aligned. Note that the resulting layout will
257257
/// satisfy the alignment properties of both `self` and `next`.
258258
///
259259
/// The resulting layout will be the same as that of a C struct containing
@@ -387,7 +387,7 @@ impl fmt::Display for CannotReallocInPlace {
387387
}
388388

389389
/// A memory allocator that can be registered as the standard library’s default
390-
/// though the `#[global_allocator]` attributes.
390+
/// through the `#[global_allocator]` attribute.
391391
///
392392
/// Some of the methods require that a memory block be *currently
393393
/// allocated* via an allocator. This means that:
@@ -458,7 +458,7 @@ pub unsafe trait GlobalAlloc {
458458
/// # Errors
459459
///
460460
/// Returning a null pointer indicates that either memory is exhausted
461-
/// or `layout` does not meet allocator's size or alignment constraints.
461+
/// or `layout` does not meet this allocator's size or alignment constraints.
462462
///
463463
/// Implementations are encouraged to return null on memory
464464
/// exhaustion rather than aborting, but this is not
@@ -1045,7 +1045,7 @@ pub unsafe trait Alloc {
10451045
/// Captures a common usage pattern for allocators.
10461046
///
10471047
/// The returned block is suitable for passing to the
1048-
/// `alloc`/`realloc` methods of this allocator.
1048+
/// `realloc`/`dealloc` methods of this allocator.
10491049
///
10501050
/// Note to implementors: If this returns `Ok(ptr)`, then `ptr`
10511051
/// must be considered "currently allocated" and must be
@@ -1111,7 +1111,7 @@ pub unsafe trait Alloc {
11111111
/// Captures a common usage pattern for allocators.
11121112
///
11131113
/// The returned block is suitable for passing to the
1114-
/// `alloc`/`realloc` methods of this allocator.
1114+
/// `realloc`/`dealloc` methods of this allocator.
11151115
///
11161116
/// Note to implementors: If this returns `Ok(ptr)`, then `ptr`
11171117
/// must be considered "currently allocated" and must be
@@ -1158,7 +1158,7 @@ pub unsafe trait Alloc {
11581158
/// Captures a common usage pattern for allocators.
11591159
///
11601160
/// The returned block is suitable for passing to the
1161-
/// `alloc`/`realloc` methods of this allocator.
1161+
/// `realloc`/`dealloc` methods of this allocator.
11621162
///
11631163
/// # Safety
11641164
///

src/librustc_codegen_ssa/mir/constant.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1616
constant: &mir::Constant<'tcx>,
1717
) -> Result<OperandRef<'tcx, Bx::Value>, ErrorHandled> {
1818
match constant.literal.val {
19+
// Special case unevaluated statics, because statics have an identity and thus should
20+
// use `get_static` to get at their id.
21+
// FIXME(oli-obk): can we unify this somehow, maybe by making const eval of statics
22+
// always produce `&STATIC`. This may also simplify how const eval works with statics.
1923
ty::ConstKind::Unevaluated(def_id, substs)
2024
if self.cx.tcx().is_static(def_id) => {
2125
assert!(substs.is_empty(), "we don't support generic statics yet");
@@ -46,7 +50,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
4650
instance,
4751
promoted: None,
4852
};
49-
self.cx.tcx().const_eval(ty::ParamEnv::reveal_all().and(cid))
53+
self.cx.tcx().const_eval(ty::ParamEnv::reveal_all().and(cid)).map_err(|err| {
54+
self.cx.tcx().sess.span_err(constant.span, "erroneous constant encountered");
55+
err
56+
})
5057
},
5158
_ => Ok(self.monomorphize(&constant.literal)),
5259
}

src/librustc_error_codes/error_codes/E0478.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ this issue, you need to specify it:
2121
```
2222
trait Wedding<'t>: 't { }
2323
24-
struct Prince<'kiss, 'SnowWhite: 'kiss> { // You say here that 'kiss must live
25-
// longer than 'SnowWhite.
24+
struct Prince<'kiss, 'SnowWhite: 'kiss> { // You say here that 'SnowWhite
25+
// must live longer than 'kiss.
2626
child: Box<Wedding<'kiss> + 'SnowWhite>, // And now it's all good!
2727
}
2828
```

src/librustc_mir/borrow_check/nll/constraint_generation.rs

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ impl<'cg, 'cx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'tcx> {
9797
location: Location,
9898
) {
9999
if let Some(all_facts) = self.all_facts {
100+
let _prof_timer = self.infcx.tcx.prof.generic_activity("polonius_fact_generation");
100101
all_facts.cfg_edge.push((
101102
self.location_table.start_index(location),
102103
self.location_table.mid_index(location),
@@ -142,6 +143,7 @@ impl<'cg, 'cx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'tcx> {
142143
location: Location,
143144
) {
144145
if let Some(all_facts) = self.all_facts {
146+
let _prof_timer = self.infcx.tcx.prof.generic_activity("polonius_fact_generation");
145147
all_facts.cfg_edge.push((
146148
self.location_table.start_index(location),
147149
self.location_table.mid_index(location),
@@ -205,6 +207,8 @@ impl<'cx, 'cg, 'tcx> ConstraintGeneration<'cx, 'cg, 'tcx> {
205207
/// as `killed`. For example, when assigning to a local, or on a call's return destination.
206208
fn record_killed_borrows_for_place(&mut self, place: &Place<'tcx>, location: Location) {
207209
if let Some(all_facts) = self.all_facts {
210+
let _prof_timer = self.infcx.tcx.prof.generic_activity("polonius_fact_generation");
211+
208212
// Depending on the `Place` we're killing:
209213
// - if it's a local, or a single deref of a local,
210214
// we kill all the borrows on the local.

src/librustc_mir/borrow_check/nll/invalidation.rs

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub(super) fn generate_invalidates<'tcx>(
3131
}
3232

3333
if let Some(all_facts) = all_facts {
34+
let _prof_timer = tcx.prof.generic_activity("polonius_fact_generation");
3435
let dominators = body.dominators();
3536
let mut ig = InvalidationGenerator {
3637
all_facts,

src/librustc_mir/borrow_check/nll/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
201201
);
202202

203203
if let Some(all_facts) = &mut all_facts {
204+
let _prof_timer = infcx.tcx.prof.generic_activity("polonius_fact_generation");
204205
all_facts
205206
.universal_region
206207
.extend(universal_regions.universal_regions());
@@ -302,6 +303,7 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
302303
.unwrap_or_else(|_| String::from("Naive"));
303304
let algorithm = Algorithm::from_str(&algorithm).unwrap();
304305
debug!("compute_regions: using polonius algorithm {:?}", algorithm);
306+
let _prof_timer = infcx.tcx.prof.generic_activity("polonius_analysis");
305307
Some(Rc::new(Output::compute(
306308
&all_facts,
307309
algorithm,

0 commit comments

Comments
 (0)