Skip to content

Commit b5f5c60

Browse files
committed
Auto merge of #52308 - pietroalbini:beta-backports, r=pietroalbini
[beta] Rollup backports Merged and approved: * #51722: Updated RELEASES for 1.28.0 * #52193: step_by: leave time of item skip unspecified * #52194: Remove rustdoc's plugins feature * #52196: rustdoc: Hide struct and enum variant constructor imports * #52310: Backport 1.27.1 release notes to master r? @ghost
2 parents 718e759 + 89402d1 commit b5f5c60

File tree

6 files changed

+234
-66
lines changed

6 files changed

+234
-66
lines changed

RELEASES.md

+168-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,169 @@
1+
Version 1.28.0 (2018-08-02)
2+
===========================
3+
4+
Language
5+
--------
6+
- [The `#[repr(transparent)]` attribute is now stable.][51562] This attribute
7+
allows a Rust newtype wrapper (`struct NewType<T>(T);`) to be represented as
8+
the inner type across Foreign Function Interface (FFI) boundaries.
9+
- [The keywords `pure`, `sizeof`, `alignof`, and `offsetof` have been unreserved
10+
and can now be used as identifiers.][51196]
11+
- [The `GlobalAlloc` trait and `#[global_allocator]` attribute are now
12+
stable.][51241] This will allow users to specify a global allocator for
13+
their program.
14+
- [Unit test functions marked with the `#[test]` attribute can now return
15+
`Result<(), E: Debug>` in addition to `()`.][51298]
16+
- [The `lifetime` specifier for `macro_rules!` is now stable.][50385] This
17+
allows macros to easily target lifetimes.
18+
19+
Compiler
20+
--------
21+
- [The `s` and `z` optimisation levels are now stable.][50265] These optimisations
22+
prioritise making smaller binary sizes. `z` is the same as `s` with the
23+
exception that it does not vectorise loops, which typically results in an even
24+
smaller binary.
25+
- [The short error format is now stable.][49546] Specified with
26+
`--error-format=short` this option will provide a more compressed output of
27+
rust error messages.
28+
- [Added a lint warning when you have duplicated `macro_export`s.][50143]
29+
- [Reduced the number of allocations in the macro parser.][50855] This can
30+
improve compile times of macro heavy crates on average by 5%.
31+
32+
Libraries
33+
---------
34+
- [Implemented `Default` for `&mut str`.][51306]
35+
- [Implemented `From<bool>` for all integer and unsigned number types.][50554]
36+
- [Implemented `Extend` for `()`.][50234]
37+
- [The `Debug` implementation of `time::Duration` should now be more easily
38+
human readable.][50364] Previously a `Duration` of one second would printed as
39+
`Duration { secs: 1, nanos: 0 }` and will now be printed as `1s`.
40+
- [Implemented `From<&String>` for `Cow<str>`, `From<&Vec<T>>` for `Cow<[T]>`,
41+
`From<Cow<CStr>>` for `CString`, `From<CString>, From<CStr>, From<&CString>`
42+
for `Cow<CStr>`, `From<OsString>, From<OsStr>, From<&OsString>` for
43+
`Cow<OsStr>`, `From<&PathBuf>` for `Cow<Path>`, and `From<Cow<Path>>`
44+
for `PathBuf`.][50170]
45+
- [Implemented `Shl` and `Shr` for `Wrapping<u128>`
46+
and `Wrapping<i128>`.][50465]
47+
- [`DirEntry::metadata` now uses `fstatat` instead of `lstat` when
48+
possible.][51050] This can provide up to a 40% speed increase.
49+
- [Improved error messages when using `format!`.][50610]
50+
51+
Stabilized APIs
52+
---------------
53+
- [`Iterator::step_by`]
54+
- [`Path::ancestors`]
55+
- [`btree_map::Entry::or_default`]
56+
- [`fmt::Alignment`]
57+
- [`hash_map::Entry::or_default`]
58+
- [`iter::repeat_with`]
59+
- [`num::NonZeroUsize`]
60+
- [`num::NonZeroU128`]
61+
- [`num::NonZeroU16`]
62+
- [`num::NonZeroU32`]
63+
- [`num::NonZeroU64`]
64+
- [`num::NonZeroU8`]
65+
- [`ops::RangeBounds`]
66+
- [`slice::SliceIndex`]
67+
- [`slice::from_mut`]
68+
- [`slice::from_ref`]
69+
- [`{Any + Send + Sync}::downcast_mut`]
70+
- [`{Any + Send + Sync}::downcast_ref`]
71+
- [`{Any + Send + Sync}::is`]
72+
73+
Cargo
74+
-----
75+
- [Cargo will now no longer allow you to publish crates with build scripts that
76+
modify the `src` directory.][cargo/5584] The `src` directory in a crate should be
77+
considered to be immutable.
78+
79+
Misc
80+
----
81+
- [The `suggestion_applicability` field in `rustc`'s json output is now
82+
stable.][50486] This will allow dev tools to check whether a code suggestion
83+
would apply to them.
84+
85+
Compatibility Notes
86+
-------------------
87+
- [Rust will no longer consider trait objects with duplicated constraints to
88+
have implementations.][51276] For example the below code will now fail
89+
to compile.
90+
```rust
91+
trait Trait {}
92+
93+
impl Trait + Send {
94+
fn test(&self) { println!("one"); } //~ ERROR duplicate definitions with name `test`
95+
}
96+
97+
impl Trait + Send + Send {
98+
fn test(&self) { println!("two"); }
99+
}
100+
```
101+
102+
[49546]: https://github.com/rust-lang/rust/pull/49546/
103+
[50143]: https://github.com/rust-lang/rust/pull/50143/
104+
[50170]: https://github.com/rust-lang/rust/pull/50170/
105+
[50234]: https://github.com/rust-lang/rust/pull/50234/
106+
[50265]: https://github.com/rust-lang/rust/pull/50265/
107+
[50364]: https://github.com/rust-lang/rust/pull/50364/
108+
[50385]: https://github.com/rust-lang/rust/pull/50385/
109+
[50465]: https://github.com/rust-lang/rust/pull/50465/
110+
[50486]: https://github.com/rust-lang/rust/pull/50486/
111+
[50554]: https://github.com/rust-lang/rust/pull/50554/
112+
[50610]: https://github.com/rust-lang/rust/pull/50610/
113+
[50855]: https://github.com/rust-lang/rust/pull/50855/
114+
[51050]: https://github.com/rust-lang/rust/pull/51050/
115+
[51196]: https://github.com/rust-lang/rust/pull/51196/
116+
[51200]: https://github.com/rust-lang/rust/pull/51200/
117+
[51241]: https://github.com/rust-lang/rust/pull/51241/
118+
[51276]: https://github.com/rust-lang/rust/pull/51276/
119+
[51298]: https://github.com/rust-lang/rust/pull/51298/
120+
[51306]: https://github.com/rust-lang/rust/pull/51306/
121+
[51562]: https://github.com/rust-lang/rust/pull/51562/
122+
[cargo/5584]: https://github.com/rust-lang/cargo/pull/5584/
123+
[`Iterator::step_by`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.step_by
124+
[`Path::ancestors`]: https://doc.rust-lang.org/std/path/struct.Path.html#method.ancestors
125+
[`btree_map::Entry::or_default`]: https://doc.rust-lang.org/std/collections/btree_map/enum.Entry.html#method.or_default
126+
[`fmt::Alignment`]: https://doc.rust-lang.org/std/fmt/enum.Alignment.html
127+
[`hash_map::Entry::or_default`]: https://doc.rust-lang.org/std/collections/btree_map/enum.Entry.html#method.or_default
128+
[`iter::repeat_with`]: https://doc.rust-lang.org/std/iter/fn.repeat_with.html
129+
[`num::NonZeroUsize`]: https://doc.rust-lang.org/std/num/struct.NonZeroUsize.html
130+
[`num::NonZeroU128`]: https://doc.rust-lang.org/std/num/struct.NonZeroU128.html
131+
[`num::NonZeroU16`]: https://doc.rust-lang.org/std/num/struct.NonZeroU16.html
132+
[`num::NonZeroU32`]: https://doc.rust-lang.org/std/num/struct.NonZeroU32.html
133+
[`num::NonZeroU64`]: https://doc.rust-lang.org/std/num/struct.NonZeroU64.html
134+
[`num::NonZeroU8`]: https://doc.rust-lang.org/std/num/struct.NonZeroU8.html
135+
[`ops::RangeBounds`]: https://doc.rust-lang.org/std/ops/trait.RangeBounds.html
136+
[`slice::SliceIndex`]: https://doc.rust-lang.org/std/slice/trait.SliceIndex.html
137+
[`slice::from_mut`]: https://doc.rust-lang.org/std/slice/fn.from_mut.html
138+
[`slice::from_ref`]: https://doc.rust-lang.org/std/slice/fn.from_ref.html
139+
[`{Any + Send + Sync}::downcast_mut`]: https://doc.rust-lang.org/std/any/trait.Any.html#method.downcast_mut-2
140+
[`{Any + Send + Sync}::downcast_ref`]: https://doc.rust-lang.org/std/any/trait.Any.html#method.downcast_ref-2
141+
[`{Any + Send + Sync}::is`]: https://doc.rust-lang.org/std/any/trait.Any.html#method.is-2
142+
143+
Version 1.27.1 (2018-07-10)
144+
===========================
145+
146+
Security Notes
147+
--------------
148+
149+
- rustdoc would execute plugins in the /tmp/rustdoc/plugins directory
150+
when running, which enabled executing code as some other user on a
151+
given machine. This release fixes that vulnerability; you can read
152+
more about this on the [blog][rustdoc-sec]. The associated CVE is [CVE-2018-1000622].
153+
154+
Thank you to Red Hat for responsibily disclosing this vulnerability to us.
155+
156+
Compatibility Notes
157+
-------------------
158+
159+
- The borrow checker was fixed to avoid an additional potential unsoundness when using
160+
match ergonomics: [#51415][51415], [#49534][49534].
161+
162+
[51415]: https://github.com/rust-lang/rust/issues/51415
163+
[49534]: https://github.com/rust-lang/rust/issues/49534
164+
[rustdoc-sec]: https://blog.rust-lang.org/2018/07/06/security-advisory-for-rustdoc.html
165+
[CVE-2018-1000622]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=%20CVE-2018-1000622
166+
1167
Version 1.27.0 (2018-06-21)
2168
==========================
3169

@@ -188,7 +354,7 @@ Language
188354
- [Closures now implement `Copy` and/or `Clone` if all captured variables
189355
implement either or both traits.][49299]
190356
- [The inclusive range syntax e.g. `for x in 0..=10` is now stable.][47813]
191-
- [Stablise `'_`. The underscore lifetime can be used anywhere where a
357+
- [The `'_` lifetime is now stable. The underscore lifetime can be used anywhere where a
192358
lifetime can be elided.][49458]
193359
- [`impl Trait` is now stable allowing you to have abstract types in returns
194360
or in function parameters.][49255] e.g. `fn foo() -> impl Iterator<Item=u8>` or
@@ -389,7 +555,7 @@ Version 1.25.0 (2018-03-29)
389555

390556
Language
391557
--------
392-
- [Stabilised `#[repr(align(x))]`.][47006] [RFC 1358]
558+
- [The `#[repr(align(x))]` attribute is now stable.][47006] [RFC 1358]
393559
- [You can now use nested groups of imports.][47948]
394560
e.g. `use std::{fs::File, io::Read, path::{Path, PathBuf}};`
395561
- [You can now have `|` at the start of a match arm.][47947] e.g.

src/libcore/iter/iterator.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,30 @@ pub trait Iterator {
271271
/// Creates an iterator starting at the same point, but stepping by
272272
/// the given amount at each iteration.
273273
///
274-
/// Note that it will always return the first element of the iterator,
274+
/// Note 1: The first element of the iterator will always be returned,
275275
/// regardless of the step given.
276276
///
277+
/// Note 2: The time at which ignored elements are pulled is not fixed.
278+
/// `StepBy` behaves like the sequence `next(), nth(step-1), nth(step-1), …`,
279+
/// but is also free to behave like the sequence
280+
/// `advance_n_and_return_first(step), advance_n_and_return_first(step), …`
281+
/// Which way is used may change for some iterators for performance reasons.
282+
/// The second way will advance the iterator earlier and may consume more items.
283+
///
284+
/// `advance_n_and_return_first` is the equivalent of:
285+
/// ```
286+
/// fn advance_n_and_return_first<I>(iter: &mut I, total_step: usize) -> Option<I::Item>
287+
/// where
288+
/// I: Iterator,
289+
/// {
290+
/// let next = iter.next();
291+
/// if total_step > 1 {
292+
/// iter.nth(total_step-2);
293+
/// }
294+
/// next
295+
/// }
296+
/// ```
297+
///
277298
/// # Panics
278299
///
279300
/// The method will panic if the given step is `0`.

src/librustdoc/lib.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub fn opts() -> Vec<RustcOptGroup> {
159159
o.optmulti("", "extern", "pass an --extern to rustc", "NAME=PATH")
160160
}),
161161
stable("plugin-path", |o| {
162-
o.optmulti("", "plugin-path", "directory to load plugins from", "DIR")
162+
o.optmulti("", "plugin-path", "removed", "DIR")
163163
}),
164164
stable("C", |o| {
165165
o.optmulti("C", "codegen", "pass a codegen option to rustc", "OPT[=VALUE]")
@@ -172,7 +172,7 @@ pub fn opts() -> Vec<RustcOptGroup> {
172172
"PASSES")
173173
}),
174174
stable("plugins", |o| {
175-
o.optmulti("", "plugins", "space separated list of plugins to also load",
175+
o.optmulti("", "plugins", "removed",
176176
"PLUGINS")
177177
}),
178178
stable("no-default", |o| {
@@ -710,9 +710,16 @@ where R: 'static + Send,
710710
}
711711
}
712712

713+
if !plugins.is_empty() {
714+
eprintln!("WARNING: --plugins no longer functions; see CVE-2018-1000622");
715+
}
716+
717+
if !plugin_path.is_none() {
718+
eprintln!("WARNING: --plugin-path no longer functions; see CVE-2018-1000622");
719+
}
720+
713721
// Load all plugins/passes into a PluginManager
714-
let path = plugin_path.unwrap_or("/tmp/rustdoc/plugins".to_string());
715-
let mut pm = plugins::PluginManager::new(PathBuf::from(path));
722+
let mut pm = plugins::PluginManager::new();
716723
for pass in &passes {
717724
let plugin = match passes::PASSES.iter()
718725
.position(|&(p, ..)| {
@@ -726,10 +733,6 @@ where R: 'static + Send,
726733
};
727734
pm.add_plugin(plugin);
728735
}
729-
info!("loading plugins...");
730-
for pname in plugins {
731-
pm.load_plugin(pname);
732-
}
733736

734737
// Run everything!
735738
info!("Executing passes/plugins");
@@ -745,8 +748,6 @@ fn check_deprecated_options(matches: &getopts::Matches, diag: &errors::Handler)
745748
let deprecated_flags = [
746749
"input-format",
747750
"output-format",
748-
"plugin-path",
749-
"plugins",
750751
"no-defaults",
751752
"passes",
752753
];

src/librustdoc/plugins.rs

+1-48
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,20 @@
1212

1313
use clean;
1414

15-
use std::mem;
16-
use std::string::String;
17-
use std::path::PathBuf;
18-
19-
use rustc_metadata::dynamic_lib as dl;
20-
2115
pub type PluginResult = clean::Crate;
2216
pub type PluginCallback = fn (clean::Crate) -> PluginResult;
2317

2418
/// Manages loading and running of plugins
2519
pub struct PluginManager {
26-
dylibs: Vec<dl::DynamicLibrary> ,
2720
callbacks: Vec<PluginCallback> ,
28-
/// The directory plugins will be loaded from
29-
pub prefix: PathBuf,
3021
}
3122

3223
impl PluginManager {
3324
/// Create a new plugin manager
34-
pub fn new(prefix: PathBuf) -> PluginManager {
25+
pub fn new() -> PluginManager {
3526
PluginManager {
36-
dylibs: Vec::new(),
3727
callbacks: Vec::new(),
38-
prefix,
39-
}
40-
}
41-
42-
/// Load a plugin with the given name.
43-
///
44-
/// Turns `name` into the proper dynamic library filename for the given
45-
/// platform. On windows, it turns into name.dll, on macOS, name.dylib, and
46-
/// elsewhere, libname.so.
47-
pub fn load_plugin(&mut self, name: String) {
48-
let x = self.prefix.join(libname(name));
49-
let lib_result = dl::DynamicLibrary::open(Some(&x));
50-
let lib = lib_result.unwrap();
51-
unsafe {
52-
let plugin = lib.symbol("rustdoc_plugin_entrypoint").unwrap();
53-
self.callbacks.push(mem::transmute::<*mut u8,PluginCallback>(plugin));
5428
}
55-
self.dylibs.push(lib);
5629
}
5730

5831
/// Load a normal Rust function as a plugin.
@@ -70,23 +43,3 @@ impl PluginManager {
7043
krate
7144
}
7245
}
73-
74-
#[cfg(target_os = "windows")]
75-
fn libname(mut n: String) -> String {
76-
n.push_str(".dll");
77-
n
78-
}
79-
80-
#[cfg(target_os="macos")]
81-
fn libname(mut n: String) -> String {
82-
n.push_str(".dylib");
83-
n
84-
}
85-
86-
#[cfg(all(not(target_os="windows"), not(target_os="macos")))]
87-
fn libname(n: String) -> String {
88-
let mut i = String::from("lib");
89-
i.push_str(&n);
90-
i.push_str(".so");
91-
i
92-
}

src/librustdoc/visit_ast.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,6 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
365365
});
366366
true
367367
}
368-
hir_map::NodeStructCtor(_) if !glob => {
369-
// struct constructors always show up alongside their struct definitions, we've
370-
// already processed that so just discard this
371-
true
372-
}
373368
_ => false,
374369
};
375370
self.view_item_stack.remove(&def_node_id);
@@ -417,6 +412,13 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
417412
hir::ItemUse(ref path, kind) => {
418413
let is_glob = kind == hir::UseKind::Glob;
419414

415+
// struct and variant constructors always show up alongside their definitions, we've
416+
// already processed them so just discard these.
417+
match path.def {
418+
Def::StructCtor(..) | Def::VariantCtor(..) => return,
419+
_ => {}
420+
}
421+
420422
// If there was a private module in the current path then don't bother inlining
421423
// anything as it will probably be stripped anyway.
422424
if item.vis == hir::Public && self.inside_public_path {

0 commit comments

Comments
 (0)