Skip to content

Commit a143517

Browse files
committed
Auto merge of rust-lang#82192 - GuillaumeGomez:rollup-gi1639b, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - rust-lang#82145 (Fix ES5 errors (IE11)) - rust-lang#82160 (Fix typo in rustc_infer::infer::UndoLog) - rust-lang#82161 (Add long explanation for E0545) - rust-lang#82163 (avoid full-slicing slices) - rust-lang#82175 (validation: fix invalid-fn-ptr error message) - rust-lang#82184 ([Minor] Update discriminant_value docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9d3deed + 9502e5c commit a143517

File tree

30 files changed

+127
-62
lines changed

30 files changed

+127
-62
lines changed

Diff for: compiler/rustc_ast_lowering/src/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
135135

136136
let parent_generics = match self.items.get(&parent_hir_id).unwrap().kind {
137137
hir::ItemKind::Impl(hir::Impl { ref generics, .. })
138-
| hir::ItemKind::Trait(_, _, ref generics, ..) => &generics.params[..],
138+
| hir::ItemKind::Trait(_, _, ref generics, ..) => generics.params,
139139
_ => &[],
140140
};
141141
let lt_def_names = parent_generics.iter().filter_map(|param| match param.kind {

Diff for: compiler/rustc_ast_pretty/src/pprust/state.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,7 @@ impl<'a> State<'a> {
16811681
self.ibox(INDENT_UNIT);
16821682
self.s.word("[");
16831683
self.print_inner_attributes_inline(attrs);
1684-
self.commasep_exprs(Inconsistent, &exprs[..]);
1684+
self.commasep_exprs(Inconsistent, exprs);
16851685
self.s.word("]");
16861686
self.end();
16871687
}
@@ -1722,7 +1722,7 @@ impl<'a> State<'a> {
17221722
self.print_inner_attributes_inline(attrs);
17231723
self.commasep_cmnt(
17241724
Consistent,
1725-
&fields[..],
1725+
fields,
17261726
|s, field| {
17271727
s.print_outer_attributes(&field.attrs);
17281728
s.ibox(INDENT_UNIT);
@@ -1757,7 +1757,7 @@ impl<'a> State<'a> {
17571757
fn print_expr_tup(&mut self, exprs: &[P<ast::Expr>], attrs: &[ast::Attribute]) {
17581758
self.popen();
17591759
self.print_inner_attributes_inline(attrs);
1760-
self.commasep_exprs(Inconsistent, &exprs[..]);
1760+
self.commasep_exprs(Inconsistent, exprs);
17611761
if exprs.len() == 1 {
17621762
self.s.word(",");
17631763
}

Diff for: compiler/rustc_builtin_macros/src/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl<'a, 'b> Context<'a, 'b> {
270270
parse::ArgumentNamed(s) => Named(s),
271271
};
272272

273-
let ty = Placeholder(match &arg.format.ty[..] {
273+
let ty = Placeholder(match arg.format.ty {
274274
"" => "Display",
275275
"?" => "Debug",
276276
"e" => "LowerExp",

Diff for: compiler/rustc_builtin_macros/src/format_foreign.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ pub mod printf {
312312
return Some((Substitution::Escape, &s[start + 2..]));
313313
}
314314

315-
Cur::new_at(&s[..], start)
315+
Cur::new_at(s, start)
316316
};
317317

318318
// This is meant to be a translation of the following regex:
@@ -673,7 +673,7 @@ pub mod shell {
673673
_ => { /* fall-through */ }
674674
}
675675

676-
Cur::new_at(&s[..], start)
676+
Cur::new_at(s, start)
677677
};
678678

679679
let at = at.at_next_cp()?;

Diff for: compiler/rustc_codegen_ssa/src/mir/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
709709
let (tup, args) = args.split_last().unwrap();
710710
(args, Some(tup))
711711
} else {
712-
(&args[..], None)
712+
(args, None)
713713
};
714714

715715
'make_args: for (i, arg) in first_args.iter().enumerate() {

Diff for: compiler/rustc_error_codes/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ E0538: include_str!("./error_codes/E0538.md"),
286286
E0539: include_str!("./error_codes/E0539.md"),
287287
E0541: include_str!("./error_codes/E0541.md"),
288288
E0542: include_str!("./error_codes/E0542.md"),
289+
E0545: include_str!("./error_codes/E0545.md"),
289290
E0546: include_str!("./error_codes/E0546.md"),
290291
E0547: include_str!("./error_codes/E0547.md"),
291292
E0550: include_str!("./error_codes/E0550.md"),
@@ -606,7 +607,6 @@ E0781: include_str!("./error_codes/E0781.md"),
606607
// E0540, // multiple rustc_deprecated attributes
607608
E0543, // missing 'reason'
608609
E0544, // multiple stability levels
609-
E0545, // incorrect 'issue'
610610
// E0548, // replaced with a generic attribute input check
611611
// rustc_deprecated attribute must be paired with either stable or unstable
612612
// attribute

Diff for: compiler/rustc_error_codes/src/error_codes/E0545.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
The `issue` value is incorrect in a stability attribute.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0545
6+
#![feature(staged_api)]
7+
#![stable(since = "1.0.0", feature = "test")]
8+
9+
#[unstable(feature = "_unstable_fn", issue = "0")] // invalid
10+
fn _unstable_fn() {}
11+
12+
#[rustc_const_unstable(feature = "_unstable_const_fn", issue = "0")] // invalid
13+
fn _unstable_const_fn() {}
14+
```
15+
16+
To fix this issue, you need to provide a correct value in the `issue` field.
17+
Example:
18+
19+
```
20+
#![feature(staged_api)]
21+
#![stable(since = "1.0.0", feature = "test")]
22+
23+
#[unstable(feature = "_unstable_fn", issue = "none")] // ok!
24+
fn _unstable_fn() {}
25+
26+
#[rustc_const_unstable(feature = "_unstable_const_fn", issue = "1")] // ok!
27+
fn _unstable_const_fn() {}
28+
```
29+
30+
See the [How Rust is Made and “Nightly Rust”][how-rust-made-nightly] appendix
31+
of the Book and the [Stability attributes][stability-attributes] section of the
32+
Rustc Dev Guide for more details.
33+
34+
[how-rust-made-nightly]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
35+
[stability-attributes]: https://rustc-dev-guide.rust-lang.org/stability.html

Diff for: compiler/rustc_hir_pretty/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl<'a> State<'a> {
392392
&f.decl,
393393
None,
394394
&f.generic_params,
395-
&f.param_names[..],
395+
f.param_names,
396396
);
397397
}
398398
hir::TyKind::OpaqueDef(..) => self.s.word("/*impl Trait*/"),
@@ -1200,7 +1200,7 @@ impl<'a> State<'a> {
12001200
self.s.word("{");
12011201
self.commasep_cmnt(
12021202
Consistent,
1203-
&fields[..],
1203+
fields,
12041204
|s, field| {
12051205
s.ibox(INDENT_UNIT);
12061206
if !field.is_shorthand {

Diff for: compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
671671
if !impl_candidates.is_empty() && e.span.contains(span) {
672672
if let Some(expr) = exprs.first() {
673673
if let ExprKind::Path(hir::QPath::Resolved(_, path)) = expr.kind {
674-
if let [path_segment] = &path.segments[..] {
674+
if let [path_segment] = path.segments {
675675
let candidate_len = impl_candidates.len();
676676
let suggestions = impl_candidates.iter().map(|candidate| {
677677
format!(

Diff for: compiler/rustc_infer/src/infer/undo_log.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct Snapshot<'tcx> {
1515
_marker: PhantomData<&'tcx ()>,
1616
}
1717

18-
/// Records the 'undo' data fora single operation that affects some form of inference variable.
18+
/// Records the "undo" data for a single operation that affects some form of inference variable.
1919
pub(crate) enum UndoLog<'tcx> {
2020
TypeVariables(type_variable::UndoLog<'tcx>),
2121
ConstUnificationTable(sv::UndoLog<ut::Delegate<ty::ConstVid<'tcx>>>),

Diff for: compiler/rustc_metadata/src/rmeta/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ impl EncodeContext<'a, 'tcx> {
866866

867867
fn encode_variances_of(&mut self, def_id: DefId) {
868868
debug!("EncodeContext::encode_variances_of({:?})", def_id);
869-
record!(self.tables.variances[def_id] <- &self.tcx.variances_of(def_id)[..]);
869+
record!(self.tables.variances[def_id] <- self.tcx.variances_of(def_id));
870870
}
871871

872872
fn encode_item_type(&mut self, def_id: DefId) {

Diff for: compiler/rustc_middle/src/hir/map/mod.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -854,22 +854,22 @@ impl<'hir> Map<'hir> {
854854
/// corresponding to the node-ID.
855855
pub fn attrs(&self, id: HirId) -> &'hir [ast::Attribute] {
856856
self.find_entry(id).map_or(&[], |entry| match entry.node {
857-
Node::Param(a) => &a.attrs[..],
857+
Node::Param(a) => a.attrs,
858858
Node::Local(l) => &l.attrs[..],
859-
Node::Item(i) => &i.attrs[..],
860-
Node::ForeignItem(fi) => &fi.attrs[..],
861-
Node::TraitItem(ref ti) => &ti.attrs[..],
862-
Node::ImplItem(ref ii) => &ii.attrs[..],
863-
Node::Variant(ref v) => &v.attrs[..],
864-
Node::Field(ref f) => &f.attrs[..],
859+
Node::Item(i) => i.attrs,
860+
Node::ForeignItem(fi) => fi.attrs,
861+
Node::TraitItem(ref ti) => ti.attrs,
862+
Node::ImplItem(ref ii) => ii.attrs,
863+
Node::Variant(ref v) => v.attrs,
864+
Node::Field(ref f) => f.attrs,
865865
Node::Expr(ref e) => &*e.attrs,
866866
Node::Stmt(ref s) => s.kind.attrs(|id| self.item(id.id)),
867867
Node::Arm(ref a) => &*a.attrs,
868-
Node::GenericParam(param) => &param.attrs[..],
868+
Node::GenericParam(param) => param.attrs,
869869
// Unit/tuple structs/variants take the attributes straight from
870870
// the struct/variant definition.
871871
Node::Ctor(..) => self.attrs(self.get_parent_item(id)),
872-
Node::Crate(item) => &item.attrs[..],
872+
Node::Crate(item) => item.attrs,
873873
Node::MacroDef(def) => def.attrs,
874874
Node::AnonConst(..)
875875
| Node::PathSegment(..)

Diff for: compiler/rustc_middle/src/ty/query/on_disk_cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ impl<'sess> OnDiskCache<'sess> {
427427

428428
fn sorted_cnums_including_local_crate(tcx: TyCtxt<'_>) -> Vec<CrateNum> {
429429
let mut cnums = vec![LOCAL_CRATE];
430-
cnums.extend_from_slice(&tcx.crates()[..]);
430+
cnums.extend_from_slice(tcx.crates());
431431
cnums.sort_unstable();
432432
// Just to be sure...
433433
cnums.dedup();

Diff for: compiler/rustc_mir/src/interpret/validity.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,11 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
586586
self.path,
587587
err_unsup!(ReadPointerAsBytes) => { "part of a pointer" } expected { "a proper pointer or integer value" },
588588
);
589+
// Make sure we print a `ScalarMaybeUninit` (and not an `ImmTy`) in the error
590+
// message below.
591+
let value = value.to_scalar_or_uninit();
589592
let _fn = try_validation!(
590-
value.to_scalar().and_then(|ptr| self.ecx.memory.get_fn(ptr)),
593+
value.check_init().and_then(|ptr| self.ecx.memory.get_fn(ptr)),
591594
self.path,
592595
err_ub!(DanglingIntPointer(..)) |
593596
err_ub!(InvalidFunctionPointer(..)) |

Diff for: compiler/rustc_resolve/src/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
11051105
}
11061106

11071107
if let Some(items) = self.diagnostic_metadata.current_trait_assoc_items {
1108-
for assoc_item in &items[..] {
1108+
for assoc_item in items {
11091109
if assoc_item.ident == ident {
11101110
return Some(match &assoc_item.kind {
11111111
ast::AssocItemKind::Const(..) => AssocSuggestion::AssocConst,

Diff for: compiler/rustc_target/src/spec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@ impl Target {
14921492
} );
14931493
($key_name:ident = $json_name:expr, optional) => ( {
14941494
let name = $json_name;
1495-
if let Some(o) = obj.find(&name[..]) {
1495+
if let Some(o) = obj.find(name) {
14961496
base.$key_name = o
14971497
.as_string()
14981498
.map(|s| s.to_string() );

Diff for: compiler/rustc_typeck/src/astconv/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
237237
}
238238
}
239239
if let ([], [bound]) = (&potential_assoc_types[..], &trait_bounds) {
240-
match &bound.trait_ref.path.segments[..] {
240+
match bound.trait_ref.path.segments {
241241
// FIXME: `trait_ref.path.span` can point to a full path with multiple
242242
// segments, even though `trait_ref.path.segments` is of length `1`. Work
243243
// around that bug here, even though it should be fixed elsewhere.

Diff for: compiler/rustc_typeck/src/astconv/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2374,7 +2374,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
23742374
crate::collect::placeholder_type_error(
23752375
tcx,
23762376
ident_span.map(|sp| sp.shrink_to_hi()),
2377-
&generics.params[..],
2377+
generics.params,
23782378
visitor.0,
23792379
true,
23802380
hir_ty,

Diff for: compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
897897
return (
898898
path.res,
899899
opt_qself.as_ref().map(|qself| self.to_ty(qself)),
900-
&path.segments[..],
900+
path.segments,
901901
);
902902
}
903903
QPath::TypeRelative(ref qself, ref segment) => (self.to_ty(qself), qself, segment),

Diff for: compiler/rustc_typeck/src/check/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
600600
});
601601
if let Some(hir::Node::Item(hir::Item { kind, .. })) = node {
602602
if let Some(g) = kind.generics() {
603-
let key = match &g.where_clause.predicates[..] {
603+
let key = match g.where_clause.predicates {
604604
[.., pred] => (pred.span().shrink_to_hi(), false),
605605
[] => (
606606
g.where_clause

Diff for: compiler/rustc_typeck/src/collect.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,7 @@ fn reject_placeholder_type_signatures_in_item(tcx: TyCtxt<'tcx>, item: &'tcx hir
229229
let mut visitor = PlaceholderHirTyCollector::default();
230230
visitor.visit_item(item);
231231

232-
placeholder_type_error(
233-
tcx,
234-
Some(generics.span),
235-
&generics.params[..],
236-
visitor.0,
237-
suggest,
238-
None,
239-
);
232+
placeholder_type_error(tcx, Some(generics.span), generics.params, visitor.0, suggest, None);
240233
}
241234

242235
impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
@@ -417,7 +410,7 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> {
417410
| hir::ItemKind::Struct(_, generics)
418411
| hir::ItemKind::Union(_, generics) => {
419412
let lt_name = get_new_lifetime_name(self.tcx, poly_trait_ref, generics);
420-
let (lt_sp, sugg) = match &generics.params[..] {
413+
let (lt_sp, sugg) = match generics.params {
421414
[] => (generics.span, format!("<{}>", lt_name)),
422415
[bound, ..] => {
423416
(bound.span.shrink_to_lo(), format!("{}, ", lt_name))

Diff for: library/core/src/intrinsics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1688,8 +1688,8 @@ extern "rust-intrinsic" {
16881688
#[rustc_const_stable(feature = "const_int_saturating", since = "1.40.0")]
16891689
pub fn saturating_sub<T: Copy>(a: T, b: T) -> T;
16901690

1691-
/// Returns the value of the discriminant for the variant in 'v',
1692-
/// cast to a `u64`; if `T` has no discriminant, returns `0`.
1691+
/// Returns the value of the discriminant for the variant in 'v';
1692+
/// if `T` has no discriminant, returns `0`.
16931693
///
16941694
/// The stabilized version of this intrinsic is [`core::mem::discriminant`](crate::mem::discriminant).
16951695
#[rustc_const_unstable(feature = "const_discriminant", issue = "69821")]

Diff for: src/bootstrap/flags.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
347347
};
348348

349349
// Done specifying what options are possible, so do the getopts parsing
350-
let matches = opts.parse(&args[..]).unwrap_or_else(|e| {
350+
let matches = opts.parse(args).unwrap_or_else(|e| {
351351
// Invalid argument/option format
352352
println!("\n{}\n", e);
353353
usage(1, &opts, false, &subcommand_help);

Diff for: src/librustdoc/clean/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ where
975975
{
976976
fn clean(&self, cx: &DocContext<'_>) -> FnDecl {
977977
FnDecl {
978-
inputs: (&self.0.inputs[..], self.1).clean(cx),
978+
inputs: (self.0.inputs, self.1).clean(cx),
979979
output: self.0.output.clean(cx),
980980
c_variadic: self.0.c_variadic,
981981
attrs: Attributes::default(),
@@ -1939,7 +1939,7 @@ impl Clean<String> for Symbol {
19391939
impl Clean<BareFunctionDecl> for hir::BareFnTy<'_> {
19401940
fn clean(&self, cx: &DocContext<'_>) -> BareFunctionDecl {
19411941
let (generic_params, decl) = enter_impl_trait(cx, || {
1942-
(self.generic_params.clean(cx), (&*self.decl, &self.param_names[..]).clean(cx))
1942+
(self.generic_params.clean(cx), (&*self.decl, self.param_names).clean(cx))
19431943
});
19441944
BareFunctionDecl { unsafety: self.unsafety, abi: self.abi, decl, generic_params }
19451945
}

Diff for: src/librustdoc/html/static/main.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -2908,10 +2908,14 @@ function defocusSearchBar() {
29082908
["&#9166;", "Go to active search result"],
29092909
["+", "Expand all sections"],
29102910
["-", "Collapse all sections"],
2911-
].map(x => "<dt>" +
2912-
x[0].split(" ")
2913-
.map((y, index) => (index & 1) === 0 ? "<kbd>" + y + "</kbd>" : " " + y + " ")
2914-
.join("") + "</dt><dd>" + x[1] + "</dd>").join("");
2911+
].map(function(x) {
2912+
return "<dt>" +
2913+
x[0].split(" ")
2914+
.map(function(y, index) {
2915+
return (index & 1) === 0 ? "<kbd>" + y + "</kbd>" : " " + y + " ";
2916+
})
2917+
.join("") + "</dt><dd>" + x[1] + "</dd>";
2918+
}).join("");
29152919
var div_shortcuts = document.createElement("div");
29162920
addClass(div_shortcuts, "shortcuts");
29172921
div_shortcuts.innerHTML = "<h2>Keyboard Shortcuts</h2><dl>" + shortcuts + "</dl></div>";
@@ -2929,7 +2933,9 @@ function defocusSearchBar() {
29292933
"You can look for items with an exact name by putting double quotes around \
29302934
your request: <code>\"string\"</code>",
29312935
"Look for items inside another one by searching for a path: <code>vec::Vec</code>",
2932-
].map(x => "<p>" + x + "</p>").join("");
2936+
].map(function(x) {
2937+
return "<p>" + x + "</p>";
2938+
}).join("");
29332939
var div_infos = document.createElement("div");
29342940
addClass(div_infos, "infos");
29352941
div_infos.innerHTML = "<h2>Search Tricks</h2>" + infos;

Diff for: src/librustdoc/html/static/storage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ var updateSystemTheme = (function() {
157157
if (!window.matchMedia) {
158158
// fallback to the CSS computed value
159159
return function() {
160-
let cssTheme = getComputedStyle(document.documentElement)
160+
var cssTheme = getComputedStyle(document.documentElement)
161161
.getPropertyValue('content');
162162

163163
switchTheme(

0 commit comments

Comments
 (0)