Skip to content

Commit 1114ab6

Browse files
committed
Auto merge of #53832 - pietroalbini:rollup, r=pietroalbini
Rollup of 20 pull requests Successful merges: - #51760 (Add another PartialEq example) - #53113 (Add example for Cow) - #53129 (remove `let x = baz` which was obscuring the real error) - #53389 (document effect of join on memory ordering) - #53472 (Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc.) - #53476 (Add partialeq implementation for TryFromIntError type) - #53513 (Force-inline `shallow_resolve` at its hottest call site.) - #53655 (set applicability) - #53702 (Fix stabilisation version for macro_vis_matcher.) - #53727 (Do not suggest dereferencing in macro) - #53732 (save-analysis: Differentiate foreign functions and statics.) - #53740 (add llvm-readobj to llvm-tools-preview) - #53743 (fix a typo: taget_env -> target_env) - #53747 (Rustdoc fixes) - #53753 (expand keep-stage --help text) - #53756 (Fix typo in comment) - #53768 (move file-extension based .gitignore down to src/) - #53785 (Fix a comment in src/libcore/slice/mod.rs) - #53786 (Replace usages of 'bad_style' with 'nonstandard_style'.) - #53806 (Fix UI issues on Implementations on Foreign types) Failed merges: r? @ghost
2 parents 8adc69a + 6b1fffa commit 1114ab6

File tree

93 files changed

+568
-344
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+568
-344
lines changed

Diff for: .gitignore

-46
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,3 @@
1-
*.a
2-
*.aux
3-
*.bc
4-
*.boot
5-
*.bz2
6-
*.cmi
7-
*.cmo
8-
*.cmx
9-
*.cp
10-
*.cps
11-
*.d
12-
*.dSYM
13-
*.def
14-
*.diff
15-
*.dll
16-
*.dylib
17-
*.elc
18-
*.epub
19-
*.exe
20-
*.fn
21-
*.html
22-
*.kdev4
23-
*.ky
24-
*.ll
25-
*.llvm
26-
*.log
27-
*.o
28-
*.orig
29-
*.out
30-
*.patch
31-
*.pdb
32-
*.pdf
33-
*.pg
34-
*.pot
35-
*.pyc
36-
*.rej
37-
*.rlib
38-
*.rustc
39-
*.so
40-
*.swo
41-
*.swp
42-
*.tmp
43-
*.toc
44-
*.tp
45-
*.vr
46-
*.x86
471
*~
482
.#*
493
.DS_Store

Diff for: src/.gitignore

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
*.a
2+
*.aux
3+
*.bc
4+
*.boot
5+
*.bz2
6+
*.cmi
7+
*.cmo
8+
*.cmx
9+
*.cp
10+
*.cps
11+
*.d
12+
*.dSYM
13+
*.def
14+
*.diff
15+
*.dll
16+
*.dylib
17+
*.elc
18+
*.epub
19+
*.exe
20+
*.fn
21+
*.html
22+
*.kdev4
23+
*.ky
24+
*.ll
25+
*.llvm
26+
*.log
27+
*.o
28+
*.orig
29+
*.out
30+
*.patch
31+
*.pdb
32+
*.pdf
33+
*.pg
34+
*.pot
35+
*.pyc
36+
*.rej
37+
*.rlib
38+
*.rustc
39+
*.so
40+
*.swo
41+
*.swp
42+
*.tmp
43+
*.toc
44+
*.tp
45+
*.vr
46+
*.x86

Diff for: src/bootstrap/flags.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`"
125125
"stage to build (indicates compiler to use/test, e.g. stage 0 uses the \
126126
bootstrap compiler, stage 1 the stage 0 rustc artifacts, etc.)",
127127
"N");
128-
opts.optmulti("", "keep-stage", "stage(s) to keep without recompiling", "N");
128+
opts.optmulti("", "keep-stage", "stage(s) to keep without recompiling \
129+
(pass multiple times to keep e.g. both stages 0 and 1)", "N");
129130
opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
130131
opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
131132
opts.optflag("h", "help", "print this help message");

Diff for: src/bootstrap/job.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
//! Note that this module has a #[cfg(windows)] above it as none of this logic
3838
//! is required on Unix.
3939
40-
#![allow(bad_style, dead_code)]
40+
#![allow(nonstandard_style, dead_code)]
4141

4242
use std::env;
4343
use std::io;

Diff for: src/bootstrap/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ const LLVM_TOOLS: &[&str] = &[
211211
"llvm-objcopy", // used to transform ELFs into binary format which flashing tools consume
212212
"llvm-objdump", // used to disassemble programs
213213
"llvm-profdata", // used to inspect and merge files generated by profiles
214+
"llvm-readobj", // used to get information from ELFs/objects that the other tools don't provide
214215
"llvm-size", // used to prints the size of the linker sections of a program
215216
"llvm-strip", // used to discard symbols from binary files to reduce their size
216217
];

Diff for: src/bootstrap/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub fn symlink_dir(config: &Config, src: &Path, dest: &Path) -> io::Result<()> {
137137
//
138138
// Copied from std
139139
#[cfg(windows)]
140-
#[allow(bad_style)]
140+
#[allow(nonstandard_style)]
141141
fn symlink_dir_inner(target: &Path, junction: &Path) -> io::Result<()> {
142142
use std::ptr;
143143
use std::ffi::OsStr;

Diff for: src/liballoc/borrow.rs

+35
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,41 @@ impl<T> ToOwned for T
141141
/// let mut input = Cow::from(vec![-1, 0, 1]);
142142
/// abs_all(&mut input);
143143
/// ```
144+
///
145+
/// Another example showing how to keep `Cow` in a struct:
146+
///
147+
/// ```
148+
/// use std::borrow::{Cow, ToOwned};
149+
///
150+
/// struct Items<'a, X: 'a> where [X]: ToOwned<Owned=Vec<X>> {
151+
/// values: Cow<'a, [X]>,
152+
/// }
153+
///
154+
/// impl<'a, X: Clone + 'a> Items<'a, X> where [X]: ToOwned<Owned=Vec<X>> {
155+
/// fn new(v: Cow<'a, [X]>) -> Self {
156+
/// Items { values: v }
157+
/// }
158+
/// }
159+
///
160+
/// // Creates a container from borrowed values of a slice
161+
/// let readonly = [1, 2];
162+
/// let borrowed = Items::new((&readonly[..]).into());
163+
/// match borrowed {
164+
/// Items { values: Cow::Borrowed(b) } => println!("borrowed {:?}", b),
165+
/// _ => panic!("expect borrowed value"),
166+
/// }
167+
///
168+
/// let mut clone_on_write = borrowed;
169+
/// // Mutates the data from slice into owned vec and pushes a new value on top
170+
/// clone_on_write.values.to_mut().push(3);
171+
/// println!("clone_on_write = {:?}", clone_on_write.values);
172+
///
173+
/// // The data was mutated. Let check it out.
174+
/// match clone_on_write {
175+
/// Items { values: Cow::Owned(_) } => println!("clone_on_write contains owned data"),
176+
/// _ => panic!("expect owned data"),
177+
/// }
178+
/// ```
144179
#[stable(feature = "rust1", since = "1.0.0")]
145180
pub enum Cow<'a, B: ?Sized + 'a>
146181
where B: ToOwned

Diff for: src/liballoc_system/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ mod platform {
220220
}
221221

222222
#[cfg(windows)]
223-
#[allow(bad_style)]
223+
#[allow(nonstandard_style)]
224224
mod platform {
225225
use MIN_ALIGN;
226226
use System;

Diff for: src/libcore/cmp.rs

+84-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ use self::Ordering::*;
7575
/// the same book if their ISBN matches, even if the formats differ:
7676
///
7777
/// ```
78-
/// enum BookFormat { Paperback, Hardback, Ebook }
78+
/// enum BookFormat {
79+
/// Paperback,
80+
/// Hardback,
81+
/// Ebook,
82+
/// }
83+
///
7984
/// struct Book {
8085
/// isbn: i32,
8186
/// format: BookFormat,
@@ -95,6 +100,84 @@ use self::Ordering::*;
95100
/// assert!(b1 != b3);
96101
/// ```
97102
///
103+
/// ## How can I compare two different types?
104+
///
105+
/// The type you can compare with is controlled by `PartialEq`'s type parameter.
106+
/// For example, let's tweak our previous code a bit:
107+
///
108+
/// ```
109+
/// enum BookFormat {
110+
/// Paperback,
111+
/// Hardback,
112+
/// Ebook,
113+
/// }
114+
///
115+
/// struct Book {
116+
/// isbn: i32,
117+
/// format: BookFormat,
118+
/// }
119+
///
120+
/// impl PartialEq<BookFormat> for Book {
121+
/// fn eq(&self, other: &BookFormat) -> bool {
122+
/// match (&self.format, other) {
123+
/// (BookFormat::Paperback, BookFormat::Paperback) => true,
124+
/// (BookFormat::Hardback, BookFormat::Hardback) => true,
125+
/// (BookFormat::Ebook, BookFormat::Ebook) => true,
126+
/// (_, _) => false,
127+
/// }
128+
/// }
129+
/// }
130+
///
131+
/// let b1 = Book { isbn: 3, format: BookFormat::Paperback };
132+
///
133+
/// assert!(b1 == BookFormat::Paperback);
134+
/// assert!(b1 != BookFormat::Ebook);
135+
/// ```
136+
///
137+
/// By changing `impl PartialEq for Book` to `impl PartialEq<BookFormat> for Book`,
138+
/// we've changed what type we can use on the right side of the `==` operator.
139+
/// This lets us use it in the `assert!` statements at the bottom.
140+
///
141+
/// You can also combine these implementations to let the `==` operator work with
142+
/// two different types:
143+
///
144+
/// ```
145+
/// enum BookFormat {
146+
/// Paperback,
147+
/// Hardback,
148+
/// Ebook,
149+
/// }
150+
///
151+
/// struct Book {
152+
/// isbn: i32,
153+
/// format: BookFormat,
154+
/// }
155+
///
156+
/// impl PartialEq<BookFormat> for Book {
157+
/// fn eq(&self, other: &BookFormat) -> bool {
158+
/// match (&self.format, other) {
159+
/// (&BookFormat::Paperback, &BookFormat::Paperback) => true,
160+
/// (&BookFormat::Hardback, &BookFormat::Hardback) => true,
161+
/// (&BookFormat::Ebook, &BookFormat::Ebook) => true,
162+
/// (_, _) => false,
163+
/// }
164+
/// }
165+
/// }
166+
///
167+
/// impl PartialEq for Book {
168+
/// fn eq(&self, other: &Book) -> bool {
169+
/// self.isbn == other.isbn
170+
/// }
171+
/// }
172+
///
173+
/// let b1 = Book { isbn: 3, format: BookFormat::Paperback };
174+
/// let b2 = Book { isbn: 3, format: BookFormat::Ebook };
175+
///
176+
/// assert!(b1 == BookFormat::Paperback);
177+
/// assert!(b1 != BookFormat::Ebook);
178+
/// assert!(b1 == b2);
179+
/// ```
180+
///
98181
/// # Examples
99182
///
100183
/// ```

Diff for: src/libcore/num/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4323,7 +4323,7 @@ from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 }
43234323

43244324
/// The error type returned when a checked integral type conversion fails.
43254325
#[unstable(feature = "try_from", issue = "33417")]
4326-
#[derive(Debug, Copy, Clone)]
4326+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
43274327
pub struct TryFromIntError(());
43284328

43294329
impl TryFromIntError {

Diff for: src/libcore/slice/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,9 @@
2121
// The library infrastructure for slices is fairly messy. There's
2222
// a lot of stuff defined here. Let's keep it clean.
2323
//
24-
// Since slices don't support inherent methods; all operations
25-
// on them are defined on traits, which are then re-exported from
26-
// the prelude for convenience. So there are a lot of traits here.
27-
//
2824
// The layout of this file is thus:
2925
//
30-
// * Slice-specific 'extension' traits and their implementations. This
31-
// is where most of the slice API resides.
26+
// * Inherent methods. This is where most of the slice API resides.
3227
// * Implementations of a few common traits with important slice ops.
3328
// * Definitions of a bunch of iterators.
3429
// * Free functions.

Diff for: src/libpanic_unwind/seh.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
//! [win64]: http://msdn.microsoft.com/en-us/library/1eyas8tf.aspx
5555
//! [llvm]: http://llvm.org/docs/ExceptionHandling.html#background-on-windows-exceptions
5656
57-
#![allow(bad_style)]
57+
#![allow(nonstandard_style)]
5858
#![allow(private_no_mangle_fns)]
5959

6060
use alloc::boxed::Box;

Diff for: src/libpanic_unwind/seh64_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! Unwinding implementation of top of native Win64 SEH,
1212
//! however the unwind handler data (aka LSDA) uses GCC-compatible encoding.
1313
14-
#![allow(bad_style)]
14+
#![allow(nonstandard_style)]
1515
#![allow(private_no_mangle_fns)]
1616

1717
use alloc::boxed::Box;

Diff for: src/libpanic_unwind/windows.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![allow(bad_style)]
11+
#![allow(nonstandard_style)]
1212
#![allow(dead_code)]
1313
#![cfg(windows)]
1414

Diff for: src/librustc/hir/lowering.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ use hir::GenericArg;
5050
use lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
5151
ELIDED_LIFETIMES_IN_PATHS};
5252
use middle::cstore::CrateStore;
53+
use rustc_data_structures::fx::FxHashSet;
5354
use rustc_data_structures::indexed_vec::IndexVec;
5455
use rustc_data_structures::small_vec::OneVector;
5556
use rustc_data_structures::thin_vec::ThinVec;
5657
use session::Session;
5758
use util::common::FN_OUTPUT_NAME;
5859
use util::nodemap::{DefIdMap, NodeMap};
5960

60-
use std::collections::{BTreeMap, HashSet};
61+
use std::collections::BTreeMap;
6162
use std::fmt::Debug;
6263
use std::iter;
6364
use std::mem;
@@ -1342,7 +1343,7 @@ impl<'a> LoweringContext<'a> {
13421343
exist_ty_id: NodeId,
13431344
collect_elided_lifetimes: bool,
13441345
currently_bound_lifetimes: Vec<hir::LifetimeName>,
1345-
already_defined_lifetimes: HashSet<hir::LifetimeName>,
1346+
already_defined_lifetimes: FxHashSet<hir::LifetimeName>,
13461347
output_lifetimes: Vec<hir::GenericArg>,
13471348
output_lifetime_params: Vec<hir::GenericParam>,
13481349
}
@@ -1476,7 +1477,7 @@ impl<'a> LoweringContext<'a> {
14761477
exist_ty_id,
14771478
collect_elided_lifetimes: true,
14781479
currently_bound_lifetimes: Vec::new(),
1479-
already_defined_lifetimes: HashSet::new(),
1480+
already_defined_lifetimes: FxHashSet::default(),
14801481
output_lifetimes: Vec::new(),
14811482
output_lifetime_params: Vec::new(),
14821483
};

Diff for: src/librustc/infer/mod.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
11161116
self.resolve_type_vars_if_possible(t).to_string()
11171117
}
11181118

1119-
pub fn shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
1119+
// We have this force-inlined variant of shallow_resolve() for the one
1120+
// callsite that is extremely hot. All other callsites use the normal
1121+
// variant.
1122+
#[inline(always)]
1123+
pub fn inlined_shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
11201124
match typ.sty {
11211125
ty::Infer(ty::TyVar(v)) => {
11221126
// Not entirely obvious: if `typ` is a type variable,
@@ -1157,6 +1161,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
11571161
}
11581162
}
11591163

1164+
pub fn shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
1165+
self.inlined_shallow_resolve(typ)
1166+
}
1167+
11601168
pub fn resolve_type_vars_if_possible<T>(&self, value: &T) -> T
11611169
where T: TypeFoldable<'tcx>
11621170
{

0 commit comments

Comments
 (0)