Skip to content

Commit 8a9f786

Browse files
committed
Auto merge of rust-lang#82393 - JohnTitor:rollup-5c8jryl, r=JohnTitor
Rollup of 9 pull requests Successful merges: - rust-lang#82098 (Add internal `collect_into_array[_unchecked]` to remove duplicate code) - rust-lang#82228 (Provide NonZero_c_* integers) - rust-lang#82287 (Make "missing field" error message more natural) - rust-lang#82351 (Use the first paragraph, instead of cookie-cutter text, for rustdoc descriptions) - rust-lang#82353 (rustdoc: Remove unnecessary `Cell` around `param_env`) - rust-lang#82367 (remove redundant option/result wrapping of return values) - rust-lang#82372 (improve UnsafeCell docs) - rust-lang#82379 (Fix sizes of repr(C) enums on hexagon) - rust-lang#82382 (rustdoc: Remove `fake_def_ids` RefCell) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 352238d + 86940be commit 8a9f786

File tree

33 files changed

+767
-212
lines changed

33 files changed

+767
-212
lines changed

compiler/rustc_attr/src/builtin.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1035,22 +1035,22 @@ pub fn find_transparency(
10351035
pub fn allow_internal_unstable<'a>(
10361036
sess: &'a Session,
10371037
attrs: &'a [Attribute],
1038-
) -> Option<impl Iterator<Item = Symbol> + 'a> {
1038+
) -> impl Iterator<Item = Symbol> + 'a {
10391039
allow_unstable(sess, attrs, sym::allow_internal_unstable)
10401040
}
10411041

10421042
pub fn rustc_allow_const_fn_unstable<'a>(
10431043
sess: &'a Session,
10441044
attrs: &'a [Attribute],
1045-
) -> Option<impl Iterator<Item = Symbol> + 'a> {
1045+
) -> impl Iterator<Item = Symbol> + 'a {
10461046
allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable)
10471047
}
10481048

10491049
fn allow_unstable<'a>(
10501050
sess: &'a Session,
10511051
attrs: &'a [Attribute],
10521052
symbol: Symbol,
1053-
) -> Option<impl Iterator<Item = Symbol> + 'a> {
1053+
) -> impl Iterator<Item = Symbol> + 'a {
10541054
let attrs = sess.filter_by_name(attrs, symbol);
10551055
let list = attrs
10561056
.filter_map(move |attr| {
@@ -1064,7 +1064,7 @@ fn allow_unstable<'a>(
10641064
})
10651065
.flatten();
10661066

1067-
Some(list.into_iter().filter_map(move |it| {
1067+
list.into_iter().filter_map(move |it| {
10681068
let name = it.ident().map(|ident| ident.name);
10691069
if name.is_none() {
10701070
sess.diagnostic().span_err(
@@ -1073,5 +1073,5 @@ fn allow_unstable<'a>(
10731073
);
10741074
}
10751075
name
1076-
}))
1076+
})
10771077
}

compiler/rustc_codegen_ssa/src/back/write.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ fn execute_work_item<B: ExtraBackendMethods>(
735735
match work_item {
736736
WorkItem::Optimize(module) => execute_optimize_work_item(cgcx, module, module_config),
737737
WorkItem::CopyPostLtoArtifacts(module) => {
738-
execute_copy_from_cache_work_item(cgcx, module, module_config)
738+
Ok(execute_copy_from_cache_work_item(cgcx, module, module_config))
739739
}
740740
WorkItem::LTO(module) => execute_lto_work_item(cgcx, module, module_config),
741741
}
@@ -844,7 +844,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
844844
cgcx: &CodegenContext<B>,
845845
module: CachedModuleCodegen,
846846
module_config: &ModuleConfig,
847-
) -> Result<WorkItemResult<B>, FatalError> {
847+
) -> WorkItemResult<B> {
848848
let incr_comp_session_dir = cgcx.incr_comp_session_dir.as_ref().unwrap();
849849
let mut object = None;
850850
if let Some(saved_file) = module.source.saved_file {
@@ -870,13 +870,13 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
870870

871871
assert_eq!(object.is_some(), module_config.emit_obj != EmitObj::None);
872872

873-
Ok(WorkItemResult::Compiled(CompiledModule {
873+
WorkItemResult::Compiled(CompiledModule {
874874
name: module.name,
875875
kind: ModuleKind::Regular,
876876
object,
877877
dwarf_object: None,
878878
bytecode: None,
879-
}))
879+
})
880880
}
881881

882882
fn execute_lto_work_item<B: ExtraBackendMethods>(

compiler/rustc_expand/src/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,8 @@ impl SyntaxExtension {
756756
name: Symbol,
757757
attrs: &[ast::Attribute],
758758
) -> SyntaxExtension {
759-
let allow_internal_unstable = attr::allow_internal_unstable(sess, &attrs)
760-
.map(|features| features.collect::<Vec<Symbol>>().into());
759+
let allow_internal_unstable =
760+
Some(attr::allow_internal_unstable(sess, &attrs).collect::<Vec<Symbol>>().into());
761761

762762
let mut local_inner_macros = false;
763763
if let Some(macro_export) = sess.find_by_name(attrs, sym::macro_export) {

compiler/rustc_middle/src/mir/interpret/allocation.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
266266
let range = self.check_bounds(ptr.offset, size);
267267

268268
self.mark_init(ptr, size, true);
269-
self.clear_relocations(cx, ptr, size)?;
269+
self.clear_relocations(cx, ptr, size);
270270

271271
AllocationExtra::memory_written(self, ptr, size)?;
272272

@@ -484,18 +484,13 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
484484
/// uninitialized. This is a somewhat odd "spooky action at a distance",
485485
/// but it allows strictly more code to run than if we would just error
486486
/// immediately in that case.
487-
fn clear_relocations(
488-
&mut self,
489-
cx: &impl HasDataLayout,
490-
ptr: Pointer<Tag>,
491-
size: Size,
492-
) -> InterpResult<'tcx> {
487+
fn clear_relocations(&mut self, cx: &impl HasDataLayout, ptr: Pointer<Tag>, size: Size) {
493488
// Find the start and end of the given range and its outermost relocations.
494489
let (first, last) = {
495490
// Find all relocations overlapping the given range.
496491
let relocations = self.get_relocations(cx, ptr, size);
497492
if relocations.is_empty() {
498-
return Ok(());
493+
return;
499494
}
500495

501496
(
@@ -517,8 +512,6 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
517512

518513
// Forget all the relocations.
519514
self.relocations.remove_range(first..last);
520-
521-
Ok(())
522515
}
523516

524517
/// Errors if there are relocations overlapping with the edges of the

compiler/rustc_middle/src/ty/layout.rs

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ impl IntegerExt for Integer {
130130

131131
if repr.c() {
132132
match &tcx.sess.target.arch[..] {
133+
"hexagon" => min_from_extern = Some(I8),
133134
// WARNING: the ARM EABI has two variants; the one corresponding
134135
// to `at_least == I32` appears to be used on Linux and NetBSD,
135136
// but some systems may use the variant corresponding to no

compiler/rustc_mir/src/interpret/intrinsics.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ use super::{
2323
mod caller_location;
2424
mod type_name;
2525

26-
fn numeric_intrinsic<'tcx, Tag>(
27-
name: Symbol,
28-
bits: u128,
29-
kind: Primitive,
30-
) -> InterpResult<'tcx, Scalar<Tag>> {
26+
fn numeric_intrinsic<Tag>(name: Symbol, bits: u128, kind: Primitive) -> Scalar<Tag> {
3127
let size = match kind {
3228
Primitive::Int(integer, _) => integer.size(),
3329
_ => bug!("invalid `{}` argument: {:?}", name, bits),
@@ -41,7 +37,7 @@ fn numeric_intrinsic<'tcx, Tag>(
4137
sym::bitreverse => (bits << extra).reverse_bits(),
4238
_ => bug!("not a numeric intrinsic: {}", name),
4339
};
44-
Ok(Scalar::from_uint(bits_out, size))
40+
Scalar::from_uint(bits_out, size)
4541
}
4642

4743
/// The logic for all nullary intrinsics is implemented here. These intrinsics don't get evaluated
@@ -208,7 +204,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
208204
if nonzero && bits == 0 {
209205
throw_ub_format!("`{}_nonzero` called on 0", intrinsic_name);
210206
}
211-
let out_val = numeric_intrinsic(intrinsic_name, bits, kind)?;
207+
let out_val = numeric_intrinsic(intrinsic_name, bits, kind);
212208
self.write_scalar(out_val, dest)?;
213209
}
214210
sym::add_with_overflow | sym::sub_with_overflow | sym::mul_with_overflow => {

compiler/rustc_mir/src/transform/check_consts/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ pub fn rustc_allow_const_fn_unstable(
8585
feature_gate: Symbol,
8686
) -> bool {
8787
let attrs = tcx.get_attrs(def_id);
88-
attr::rustc_allow_const_fn_unstable(&tcx.sess, attrs)
89-
.map_or(false, |mut features| features.any(|name| name == feature_gate))
88+
attr::rustc_allow_const_fn_unstable(&tcx.sess, attrs).any(|name| name == feature_gate)
9089
}
9190

9291
// Returns `true` if the given `const fn` is "const-stable".

compiler/rustc_parse/src/parser/expr.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl<'a> Parser<'a> {
426426
let span = self.mk_expr_sp(&lhs, lhs.span, rhs_span);
427427
let limits =
428428
if op == AssocOp::DotDot { RangeLimits::HalfOpen } else { RangeLimits::Closed };
429-
Ok(self.mk_expr(span, self.mk_range(Some(lhs), rhs, limits)?, AttrVec::new()))
429+
Ok(self.mk_expr(span, self.mk_range(Some(lhs), rhs, limits), AttrVec::new()))
430430
}
431431

432432
fn is_at_start_of_range_notation_rhs(&self) -> bool {
@@ -474,7 +474,7 @@ impl<'a> Parser<'a> {
474474
} else {
475475
(lo, None)
476476
};
477-
Ok(this.mk_expr(span, this.mk_range(None, opt_end, limits)?, attrs.into()))
477+
Ok(this.mk_expr(span, this.mk_range(None, opt_end, limits), attrs.into()))
478478
})
479479
}
480480

@@ -1041,7 +1041,7 @@ impl<'a> Parser<'a> {
10411041
/// Assuming we have just parsed `.`, continue parsing into an expression.
10421042
fn parse_dot_suffix(&mut self, self_arg: P<Expr>, lo: Span) -> PResult<'a, P<Expr>> {
10431043
if self.token.uninterpolated_span().rust_2018() && self.eat_keyword(kw::Await) {
1044-
return self.mk_await_expr(self_arg, lo);
1044+
return Ok(self.mk_await_expr(self_arg, lo));
10451045
}
10461046

10471047
let fn_span_lo = self.token.span;
@@ -2396,12 +2396,12 @@ impl<'a> Parser<'a> {
23962396
start: Option<P<Expr>>,
23972397
end: Option<P<Expr>>,
23982398
limits: RangeLimits,
2399-
) -> PResult<'a, ExprKind> {
2399+
) -> ExprKind {
24002400
if end.is_none() && limits == RangeLimits::Closed {
24012401
self.error_inclusive_range_with_no_end(self.prev_token.span);
2402-
Ok(ExprKind::Err)
2402+
ExprKind::Err
24032403
} else {
2404-
Ok(ExprKind::Range(start, end, limits))
2404+
ExprKind::Range(start, end, limits)
24052405
}
24062406
}
24072407

@@ -2421,11 +2421,11 @@ impl<'a> Parser<'a> {
24212421
ExprKind::Call(f, args)
24222422
}
24232423

2424-
fn mk_await_expr(&mut self, self_arg: P<Expr>, lo: Span) -> PResult<'a, P<Expr>> {
2424+
fn mk_await_expr(&mut self, self_arg: P<Expr>, lo: Span) -> P<Expr> {
24252425
let span = lo.to(self.prev_token.span);
24262426
let await_expr = self.mk_expr(span, ExprKind::Await(self_arg), AttrVec::new());
24272427
self.recover_from_await_method_call();
2428-
Ok(await_expr)
2428+
await_expr
24292429
}
24302430

24312431
crate fn mk_expr(&self, span: Span, kind: ExprKind, attrs: AttrVec) -> P<Expr> {

compiler/rustc_parse/src/parser/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ impl<'a> Parser<'a> {
16791679
let constness = self.parse_constness();
16801680
let asyncness = self.parse_asyncness();
16811681
let unsafety = self.parse_unsafety();
1682-
let ext = self.parse_extern()?;
1682+
let ext = self.parse_extern();
16831683

16841684
if let Async::Yes { span, .. } = asyncness {
16851685
self.ban_async_in_2015(span);

compiler/rustc_parse/src/parser/mod.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1202,12 +1202,8 @@ impl<'a> Parser<'a> {
12021202
}
12031203

12041204
/// Parses `extern string_literal?`.
1205-
fn parse_extern(&mut self) -> PResult<'a, Extern> {
1206-
Ok(if self.eat_keyword(kw::Extern) {
1207-
Extern::from_abi(self.parse_abi())
1208-
} else {
1209-
Extern::None
1210-
})
1205+
fn parse_extern(&mut self) -> Extern {
1206+
if self.eat_keyword(kw::Extern) { Extern::from_abi(self.parse_abi()) } else { Extern::None }
12111207
}
12121208

12131209
/// Parses a string literal as an ABI spec.

compiler/rustc_passes/src/check_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<'tcx> CheckConstVisitor<'tcx> {
106106
// However, we cannot allow stable `const fn`s to use unstable features without an explicit
107107
// opt-in via `rustc_allow_const_fn_unstable`.
108108
attr::rustc_allow_const_fn_unstable(&tcx.sess, &tcx.get_attrs(def_id))
109-
.map_or(false, |mut features| features.any(|name| name == feature_gate))
109+
.any(|name| name == feature_gate)
110110
};
111111

112112
match required_gates {

compiler/rustc_typeck/src/check/expr.rs

+17-14
Original file line numberDiff line numberDiff line change
@@ -1348,33 +1348,36 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13481348
span: Span,
13491349
remaining_fields: FxHashMap<Ident, (usize, &ty::FieldDef)>,
13501350
) {
1351-
let tcx = self.tcx;
13521351
let len = remaining_fields.len();
13531352

13541353
let mut displayable_field_names =
13551354
remaining_fields.keys().map(|ident| ident.as_str()).collect::<Vec<_>>();
13561355

13571356
displayable_field_names.sort();
13581357

1359-
let truncated_fields_error = if len <= 3 {
1360-
String::new()
1361-
} else {
1362-
format!(" and {} other field{}", (len - 3), if len - 3 == 1 { "" } else { "s" })
1358+
let mut truncated_fields_error = String::new();
1359+
let remaining_fields_names = match &displayable_field_names[..] {
1360+
[field1] => format!("`{}`", field1),
1361+
[field1, field2] => format!("`{}` and `{}`", field1, field2),
1362+
[field1, field2, field3] => format!("`{}`, `{}` and `{}`", field1, field2, field3),
1363+
_ => {
1364+
truncated_fields_error =
1365+
format!(" and {} other field{}", len - 3, pluralize!(len - 3));
1366+
displayable_field_names
1367+
.iter()
1368+
.take(3)
1369+
.map(|n| format!("`{}`", n))
1370+
.collect::<Vec<_>>()
1371+
.join(", ")
1372+
}
13631373
};
13641374

1365-
let remaining_fields_names = displayable_field_names
1366-
.iter()
1367-
.take(3)
1368-
.map(|n| format!("`{}`", n))
1369-
.collect::<Vec<_>>()
1370-
.join(", ");
1371-
13721375
struct_span_err!(
1373-
tcx.sess,
1376+
self.tcx.sess,
13741377
span,
13751378
E0063,
13761379
"missing field{} {}{} in initializer of `{}`",
1377-
pluralize!(remaining_fields.len()),
1380+
pluralize!(len),
13781381
remaining_fields_names,
13791382
truncated_fields_error,
13801383
adt_ty

0 commit comments

Comments
 (0)