Skip to content

Commit 5b96425

Browse files
committed
Auto merge of #59910 - Centril:rollup-yjv7b06, r=Centril
Rollup of 15 pull requests Successful merges: - #59680 (Document the -Z flag to the rustc book) - #59711 (Add back the substring test) - #59806 (compiletest: Improve no_prefer_dynamic docs) - #59809 (Make trait_methods_not_found use a lock) - #59811 (Kill dead code dominator code.) - #59814 (Fix broken links on std::boxed doc page) - #59821 (improve unknown enum variant errors) - #59831 (Remove strange formatting in `Ordering` docs.) - #59836 (std::ops::Div examples: correct nominator to numerator) - #59857 (SGX target: fix cfg(test) build) - #59876 (Update TRPL to use mdbook 0.2) - #59880 (Remove note about transmute for float bitpatterns.) - #59889 (Update diagnostics.rs) - #59891 (Fix the link to sort_by_cached_key) - #59894 (save-analysis: Pull associated type definition using `qpath_def`) Failed merges: r? @ghost
2 parents 876a3bc + 7a8329f commit 5b96425

Some content is hidden

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

41 files changed

+295
-209
lines changed

RELEASES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Compatibility Notes
133133
[`num::NonZeroI64`]: https://doc.rust-lang.org/std/num/struct.NonZeroI64.html
134134
[`num::NonZeroI8`]: https://doc.rust-lang.org/std/num/struct.NonZeroI8.html
135135
[`num::NonZeroIsize`]: https://doc.rust-lang.org/std/num/struct.NonZeroIsize.html
136-
[`slice::sort_by_cached_key`]: https://doc.rust-lang.org/std/slice/fn.sort_by_cached_key
136+
[`slice::sort_by_cached_key`]: https://doc.rust-lang.org/std/primitive.slice.html#method.sort_by_cached_key
137137
[`str::escape_debug`]: https://doc.rust-lang.org/std/primitive.str.html#method.escape_debug
138138
[`str::escape_default`]: https://doc.rust-lang.org/std/primitive.str.html#method.escape_default
139139
[`str::escape_unicode`]: https://doc.rust-lang.org/std/primitive.str.html#method.escape_unicode

src/bootstrap/doc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ impl Step for TheBook {
277277
builder.ensure(Rustbook {
278278
target,
279279
name: INTERNER.intern_string(name.to_string()),
280-
version: RustbookVersion::MdBook1,
280+
version: RustbookVersion::MdBook2,
281281
});
282282

283283
// building older edition redirects
@@ -286,21 +286,21 @@ impl Step for TheBook {
286286
builder.ensure(Rustbook {
287287
target,
288288
name: INTERNER.intern_string(source_name),
289-
version: RustbookVersion::MdBook1,
289+
version: RustbookVersion::MdBook2,
290290
});
291291

292292
let source_name = format!("{}/second-edition", name);
293293
builder.ensure(Rustbook {
294294
target,
295295
name: INTERNER.intern_string(source_name),
296-
version: RustbookVersion::MdBook1,
296+
version: RustbookVersion::MdBook2,
297297
});
298298

299299
let source_name = format!("{}/2018-edition", name);
300300
builder.ensure(Rustbook {
301301
target,
302302
name: INTERNER.intern_string(source_name),
303-
version: RustbookVersion::MdBook1,
303+
version: RustbookVersion::MdBook2,
304304
});
305305

306306
// build the version info page and CSS

src/doc/rustc/src/command-line-arguments.md

+7
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ This flag will set which lints should be set to the [deny level](lints/levels.ht
8686

8787
This flag will set which lints should be set to the [forbid level](lints/levels.html#forbid).
8888

89+
## `-Z`: set unstable options
90+
91+
This flag will allow you to set unstable options of rustc. In order to set multiple options,
92+
the -Z flag can be used multiple times. For example: `rustc -Z verbose -Z time`.
93+
Specifying options with -Z is only available on nightly. To view all available options
94+
run: `rustc -Z help`.
95+
8996
## `--cap-lints`: set the most restrictive lint level
9097

9198
This flag lets you 'cap' lints, for more, [see here](lints/levels.html#capping-lints).

src/liballoc/boxed.rs

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
//!
6464
//! [dereferencing]: ../../std/ops/trait.Deref.html
6565
//! [`Box`]: struct.Box.html
66+
//! [`Global`]: ../alloc/struct.Global.html
67+
//! [`Layout`]: ../alloc/struct.Layout.html
6668
6769
#![stable(feature = "rust1", since = "1.0.0")]
6870

src/libcore/cmp.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,13 @@ pub struct AssertParamIsEq<T: Eq + ?Sized> { _field: ::marker::PhantomData<T> }
286286
#[derive(Clone, Copy, PartialEq, Debug, Hash)]
287287
#[stable(feature = "rust1", since = "1.0.0")]
288288
pub enum Ordering {
289-
/// An ordering where a compared value is less [than another].
289+
/// An ordering where a compared value is less than another.
290290
#[stable(feature = "rust1", since = "1.0.0")]
291291
Less = -1,
292-
/// An ordering where a compared value is equal [to another].
292+
/// An ordering where a compared value is equal to another.
293293
#[stable(feature = "rust1", since = "1.0.0")]
294294
Equal = 0,
295-
/// An ordering where a compared value is greater [than another].
295+
/// An ordering where a compared value is greater than another.
296296
#[stable(feature = "rust1", since = "1.0.0")]
297297
Greater = 1,
298298
}

src/libcore/intrinsics.rs

-10
Original file line numberDiff line numberDiff line change
@@ -737,16 +737,6 @@ extern "rust-intrinsic" {
737737
///
738738
/// There are a few things that `transmute` is really useful for.
739739
///
740-
/// Getting the bitpattern of a floating point type (or, more generally,
741-
/// type punning, when `T` and `U` aren't pointers):
742-
///
743-
/// ```
744-
/// let bitpattern = unsafe {
745-
/// std::mem::transmute::<f32, u32>(1.0)
746-
/// };
747-
/// assert_eq!(bitpattern, 0x3F800000);
748-
/// ```
749-
///
750740
/// Turning a pointer into a function pointer. This is *not* portable to
751741
/// machines where function pointers and data pointers have different sizes.
752742
///

src/libcore/ops/arith.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -220,21 +220,21 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
220220
/// // derive `Eq` and `PartialEq`.
221221
/// #[derive(Debug, Eq, PartialEq)]
222222
/// struct Rational {
223-
/// nominator: usize,
223+
/// numerator: usize,
224224
/// denominator: usize,
225225
/// }
226226
///
227227
/// impl Rational {
228-
/// fn new(nominator: usize, denominator: usize) -> Self {
228+
/// fn new(numerator: usize, denominator: usize) -> Self {
229229
/// if denominator == 0 {
230230
/// panic!("Zero is an invalid denominator!");
231231
/// }
232232
///
233233
/// // Reduce to lowest terms by dividing by the greatest common
234234
/// // divisor.
235-
/// let gcd = gcd(nominator, denominator);
235+
/// let gcd = gcd(numerator, denominator);
236236
/// Rational {
237-
/// nominator: nominator / gcd,
237+
/// numerator: numerator / gcd,
238238
/// denominator: denominator / gcd,
239239
/// }
240240
/// }
@@ -245,9 +245,9 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
245245
/// type Output = Self;
246246
///
247247
/// fn mul(self, rhs: Self) -> Self {
248-
/// let nominator = self.nominator * rhs.nominator;
248+
/// let numerator = self.numerator * rhs.numerator;
249249
/// let denominator = self.denominator * rhs.denominator;
250-
/// Rational::new(nominator, denominator)
250+
/// Rational::new(numerator, denominator)
251251
/// }
252252
/// }
253253
///
@@ -340,21 +340,21 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
340340
/// // derive `Eq` and `PartialEq`.
341341
/// #[derive(Debug, Eq, PartialEq)]
342342
/// struct Rational {
343-
/// nominator: usize,
343+
/// numerator: usize,
344344
/// denominator: usize,
345345
/// }
346346
///
347347
/// impl Rational {
348-
/// fn new(nominator: usize, denominator: usize) -> Self {
348+
/// fn new(numerator: usize, denominator: usize) -> Self {
349349
/// if denominator == 0 {
350350
/// panic!("Zero is an invalid denominator!");
351351
/// }
352352
///
353353
/// // Reduce to lowest terms by dividing by the greatest common
354354
/// // divisor.
355-
/// let gcd = gcd(nominator, denominator);
355+
/// let gcd = gcd(numerator, denominator);
356356
/// Rational {
357-
/// nominator: nominator / gcd,
357+
/// numerator: numerator / gcd,
358358
/// denominator: denominator / gcd,
359359
/// }
360360
/// }
@@ -365,13 +365,13 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
365365
/// type Output = Self;
366366
///
367367
/// fn div(self, rhs: Self) -> Self::Output {
368-
/// if rhs.nominator == 0 {
368+
/// if rhs.numerator == 0 {
369369
/// panic!("Cannot divide by zero-valued `Rational`!");
370370
/// }
371371
///
372-
/// let nominator = self.nominator * rhs.denominator;
373-
/// let denominator = self.denominator * rhs.nominator;
374-
/// Rational::new(nominator, denominator)
372+
/// let numerator = self.numerator * rhs.denominator;
373+
/// let denominator = self.denominator * rhs.numerator;
374+
/// Rational::new(numerator, denominator)
375375
/// }
376376
/// }
377377
///

src/librustc/session/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub struct Session {
166166
pub driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
167167

168168
/// `Span`s of trait methods that weren't found to avoid emitting object safety errors
169-
pub trait_methods_not_found: OneThread<RefCell<FxHashSet<Span>>>,
169+
pub trait_methods_not_found: Lock<FxHashSet<Span>>,
170170
}
171171

172172
pub struct PerfStats {
@@ -1236,7 +1236,7 @@ fn build_session_(
12361236
has_global_allocator: Once::new(),
12371237
has_panic_handler: Once::new(),
12381238
driver_lint_caps,
1239-
trait_methods_not_found: OneThread::new(RefCell::new(Default::default())),
1239+
trait_methods_not_found: Lock::new(Default::default()),
12401240
};
12411241

12421242
validate_commandline_args_with_session_available(&sess);

src/librustc_data_structures/graph/dominators/mod.rs

-47
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ use super::super::indexed_vec::{Idx, IndexVec};
88
use super::iterate::reverse_post_order;
99
use super::ControlFlowGraph;
1010

11-
use std::fmt;
12-
1311
#[cfg(test)]
1412
mod test;
1513

@@ -158,48 +156,3 @@ impl<'dom, Node: Idx> Iterator for Iter<'dom, Node> {
158156
}
159157
}
160158
}
161-
162-
pub struct DominatorTree<N: Idx> {
163-
root: N,
164-
children: IndexVec<N, Vec<N>>,
165-
}
166-
167-
impl<Node: Idx> DominatorTree<Node> {
168-
pub fn children(&self, node: Node) -> &[Node] {
169-
&self.children[node]
170-
}
171-
}
172-
173-
impl<Node: Idx> fmt::Debug for DominatorTree<Node> {
174-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
175-
fmt::Debug::fmt(
176-
&DominatorTreeNode {
177-
tree: self,
178-
node: self.root,
179-
},
180-
fmt,
181-
)
182-
}
183-
}
184-
185-
struct DominatorTreeNode<'tree, Node: Idx> {
186-
tree: &'tree DominatorTree<Node>,
187-
node: Node,
188-
}
189-
190-
impl<'tree, Node: Idx> fmt::Debug for DominatorTreeNode<'tree, Node> {
191-
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
192-
let subtrees: Vec<_> = self.tree
193-
.children(self.node)
194-
.iter()
195-
.map(|&child| DominatorTreeNode {
196-
tree: self.tree,
197-
node: child,
198-
})
199-
.collect();
200-
fmt.debug_tuple("")
201-
.field(&self.node)
202-
.field(&subtrees)
203-
.finish()
204-
}
205-
}

src/librustc_driver/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ fn usage(verbose: bool, include_unstable_options: bool) {
744744
}
745745
let message = "Usage: rustc [OPTIONS] INPUT";
746746
let nightly_help = if nightly_options::is_nightly_build() {
747-
"\n -Z help Print internal options for debugging rustc"
747+
"\n -Z help Print unstable compiler options"
748748
} else {
749749
""
750750
};
@@ -892,7 +892,7 @@ Available lint options:
892892
}
893893

894894
fn describe_debug_flags() {
895-
println!("\nAvailable debug options:\n");
895+
println!("\nAvailable options:\n");
896896
print_flag_list("-Z", config::DB_OPTIONS);
897897
}
898898

src/librustc_mir/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2307,10 +2307,10 @@ let q = *p;
23072307
```
23082308
23092309
Here, the expression `&foo()` is borrowing the expression
2310-
`foo()`. As `foo()` is call to a function, and not the name of
2310+
`foo()`. As `foo()` is a call to a function, and not the name of
23112311
a variable, this creates a **temporary** -- that temporary stores
23122312
the return value from `foo()` so that it can be borrowed.
2313-
So you might imagine that `let p = bar(&foo())` is equivalent
2313+
You could imagine that `let p = bar(&foo());` is equivalent
23142314
to this:
23152315
23162316
```compile_fail,E0597

src/librustc_save_analysis/lib.rs

+4-20
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use rustc::middle::cstore::ExternCrate;
2323
use rustc::session::config::{CrateType, Input, OutputType};
2424
use rustc::ty::{self, DefIdTree, TyCtxt};
2525
use rustc::{bug, span_bug};
26-
use rustc_typeck::hir_ty_to_ty;
2726
use rustc_codegen_utils::link::{filename_for_metadata, out_filename};
2827
use rustc_data_structures::sync::Lrc;
2928

@@ -648,6 +647,10 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
648647
Node::Pat(&hir::Pat {
649648
node: hir::PatKind::TupleStruct(ref qpath, ..),
650649
..
650+
}) |
651+
Node::Ty(&hir::Ty {
652+
node: hir::TyKind::Path(ref qpath),
653+
..
651654
}) => {
652655
let hir_id = self.tcx.hir().node_to_hir_id(id);
653656
self.tables.qpath_def(qpath, hir_id)
@@ -658,25 +661,6 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
658661
..
659662
}) => HirDef::Local(self.tcx.hir().hir_to_node_id(canonical_id)),
660663

661-
Node::Ty(ty) => if let hir::Ty {
662-
node: hir::TyKind::Path(ref qpath),
663-
..
664-
} = *ty
665-
{
666-
match *qpath {
667-
hir::QPath::Resolved(_, ref path) => path.def,
668-
hir::QPath::TypeRelative(..) => {
669-
let ty = hir_ty_to_ty(self.tcx, ty);
670-
if let ty::Projection(proj) = ty.sty {
671-
return HirDef::AssociatedTy(proj.item_def_id);
672-
}
673-
HirDef::Err
674-
}
675-
}
676-
} else {
677-
HirDef::Err
678-
},
679-
680664
_ => HirDef::Err,
681665
}
682666
}

src/librustc_typeck/astconv.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -1362,27 +1362,32 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
13621362
let msg = format!("expected type, found variant `{}`", assoc_ident);
13631363
tcx.sess.span_err(span, &msg);
13641364
} else if qself_ty.is_enum() {
1365-
// Report as incorrect enum variant rather than ambiguous type.
13661365
let mut err = tcx.sess.struct_span_err(
1367-
span,
1368-
&format!("no variant `{}` on enum `{}`", &assoc_ident.as_str(), qself_ty),
1366+
assoc_ident.span,
1367+
&format!("no variant `{}` in enum `{}`", assoc_ident, qself_ty),
13691368
);
1370-
// Check if it was a typo.
1369+
13711370
let adt_def = qself_ty.ty_adt_def().expect("enum is not an ADT");
13721371
if let Some(suggested_name) = find_best_match_for_name(
13731372
adt_def.variants.iter().map(|variant| &variant.ident.name),
13741373
&assoc_ident.as_str(),
13751374
None,
13761375
) {
13771376
err.span_suggestion(
1378-
span,
1379-
"did you mean",
1380-
format!("{}::{}", qself_ty, suggested_name),
1377+
assoc_ident.span,
1378+
"there is a variant with a similar name",
1379+
suggested_name.to_string(),
13811380
Applicability::MaybeIncorrect,
13821381
);
13831382
} else {
1384-
err.span_label(span, "unknown variant");
1383+
err.span_label(span, format!("variant not found in `{}`", qself_ty));
13851384
}
1385+
1386+
if let Some(sp) = tcx.hir().span_if_local(adt_def.did) {
1387+
let sp = tcx.sess.source_map().def_span(sp);
1388+
err.span_label(sp, format!("variant `{}` not found here", assoc_ident));
1389+
}
1390+
13861391
err.emit();
13871392
} else if !qself_ty.references_error() {
13881393
// Don't print `TyErr` to the user.

0 commit comments

Comments
 (0)