Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #82393

Merged
merged 34 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c675af8
Add internal `collect_into_array[_unchecked]` to remove duplicate code
LukasKalbertodt Feb 14, 2021
d6b9d9a
std::src::os::raw: Refactor, introducing macro type_alias!
ijackson Feb 17, 2021
e78b501
Provide NonZero_c_* integers
ijackson Feb 17, 2021
447ce27
Make "missing field" error message more natural
wooster0 Feb 20, 2021
5538528
Use the first paragraph, instead of cookie-cutter text, for rustdoc d…
notriddle Feb 20, 2021
1bedd4d
Cut off plain text descriptions after headers
notriddle Feb 20, 2021
bcef5e7
Revert changes to all.html
notriddle Feb 21, 2021
8b3b1c9
Add rustdoc UI tests for new description behaviour
notriddle Feb 21, 2021
dcf4991
Fix formatting for description rustdoc UI tests
notriddle Feb 21, 2021
fd5a710
Use has for non-regexes
notriddle Feb 21, 2021
6a85719
rustdoc: Remove unnecessary `Cell` around `param_env`
camelid Feb 21, 2021
60a9dcc
update tracking issue for raw_os_nonzero
KodrAus Feb 21, 2021
4cb649b
remove unneccessary wrapping of return value of allow_unstable(), it …
matthiaskrgr Feb 21, 2021
12080dc
rustc_parse: remove unneccessary wrapping of return value in fn mk_ra…
matthiaskrgr Feb 21, 2021
00bc134
remove unneccessary wrapping of return value in mk_await_expr()
matthiaskrgr Feb 21, 2021
85bd00f
parser: remove unneccessary wrapping of return value in parse_extern()
matthiaskrgr Feb 21, 2021
393878b
remove redundant return value Ok(()) of clear_relocations()
matthiaskrgr Feb 21, 2021
76b9b16
rustc_codegen_ssa: remove unneeded wrapping of return type of execute…
matthiaskrgr Feb 21, 2021
a9b90c0
rustc_mir: remove redundant wrapping of return type in numeric_intrin…
matthiaskrgr Feb 21, 2021
1260883
improve UnsafeCell docs
RalfJung Feb 21, 2021
a6b85fb
Update src/test/rustdoc/description.rs
notriddle Feb 21, 2021
575c75b
Update src/test/rustdoc/description.rs
notriddle Feb 21, 2021
da9a588
remove redundant wrapping of return types of allow_internal_unstable(…
matthiaskrgr Feb 21, 2021
7130e46
Fix sizes of repr(C) enums on hexagon
nagisa Feb 21, 2021
45673e2
rustdoc: Remove `fake_def_ids` RefCell
camelid Feb 22, 2021
3cf201f
Rollup merge of #82098 - LukasKalbertodt:add-collect-into-array, r=dt…
JohnTitor Feb 22, 2021
a5f6668
Rollup merge of #82228 - ijackson:nonzero-cint, r=KodrAus
JohnTitor Feb 22, 2021
20c1fa1
Rollup merge of #82287 - r00ster91:field_name_and, r=petrochenkov
JohnTitor Feb 22, 2021
1dba8ce
Rollup merge of #82351 - notriddle:docs-meta-description, r=jyn514
JohnTitor Feb 22, 2021
4dfe69a
Rollup merge of #82353 - camelid:no-more-param_env-cell, r=jyn514
JohnTitor Feb 22, 2021
1870b3b
Rollup merge of #82367 - matthiaskrgr:wraps, r=petrochenkov
JohnTitor Feb 22, 2021
7958166
Rollup merge of #82372 - RalfJung:unsafe-cell, r=KodrAus
JohnTitor Feb 22, 2021
50a2de2
Rollup merge of #82379 - nagisa:nagisa/hexagon-enums, r=estebank
JohnTitor Feb 22, 2021
86940be
Rollup merge of #82382 - camelid:remove-fake_def_ids-refcell, r=jyn514
JohnTitor Feb 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,22 +1035,22 @@ pub fn find_transparency(
pub fn allow_internal_unstable<'a>(
sess: &'a Session,
attrs: &'a [Attribute],
) -> Option<impl Iterator<Item = Symbol> + 'a> {
) -> impl Iterator<Item = Symbol> + 'a {
allow_unstable(sess, attrs, sym::allow_internal_unstable)
}

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

fn allow_unstable<'a>(
sess: &'a Session,
attrs: &'a [Attribute],
symbol: Symbol,
) -> Option<impl Iterator<Item = Symbol> + 'a> {
) -> impl Iterator<Item = Symbol> + 'a {
let attrs = sess.filter_by_name(attrs, symbol);
let list = attrs
.filter_map(move |attr| {
Expand All @@ -1064,7 +1064,7 @@ fn allow_unstable<'a>(
})
.flatten();

Some(list.into_iter().filter_map(move |it| {
list.into_iter().filter_map(move |it| {
let name = it.ident().map(|ident| ident.name);
if name.is_none() {
sess.diagnostic().span_err(
Expand All @@ -1073,5 +1073,5 @@ fn allow_unstable<'a>(
);
}
name
}))
})
}
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ fn execute_work_item<B: ExtraBackendMethods>(
match work_item {
WorkItem::Optimize(module) => execute_optimize_work_item(cgcx, module, module_config),
WorkItem::CopyPostLtoArtifacts(module) => {
execute_copy_from_cache_work_item(cgcx, module, module_config)
Ok(execute_copy_from_cache_work_item(cgcx, module, module_config))
}
WorkItem::LTO(module) => execute_lto_work_item(cgcx, module, module_config),
}
Expand Down Expand Up @@ -844,7 +844,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
cgcx: &CodegenContext<B>,
module: CachedModuleCodegen,
module_config: &ModuleConfig,
) -> Result<WorkItemResult<B>, FatalError> {
) -> WorkItemResult<B> {
let incr_comp_session_dir = cgcx.incr_comp_session_dir.as_ref().unwrap();
let mut object = None;
if let Some(saved_file) = module.source.saved_file {
Expand All @@ -870,13 +870,13 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(

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

Ok(WorkItemResult::Compiled(CompiledModule {
WorkItemResult::Compiled(CompiledModule {
name: module.name,
kind: ModuleKind::Regular,
object,
dwarf_object: None,
bytecode: None,
}))
})
}

fn execute_lto_work_item<B: ExtraBackendMethods>(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,8 @@ impl SyntaxExtension {
name: Symbol,
attrs: &[ast::Attribute],
) -> SyntaxExtension {
let allow_internal_unstable = attr::allow_internal_unstable(sess, &attrs)
.map(|features| features.collect::<Vec<Symbol>>().into());
let allow_internal_unstable =
Some(attr::allow_internal_unstable(sess, &attrs).collect::<Vec<Symbol>>().into());

let mut local_inner_macros = false;
if let Some(macro_export) = sess.find_by_name(attrs, sym::macro_export) {
Expand Down
13 changes: 3 additions & 10 deletions compiler/rustc_middle/src/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
let range = self.check_bounds(ptr.offset, size);

self.mark_init(ptr, size, true);
self.clear_relocations(cx, ptr, size)?;
self.clear_relocations(cx, ptr, size);

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

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

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

// Forget all the relocations.
self.relocations.remove_range(first..last);

Ok(())
}

/// Errors if there are relocations overlapping with the edges of the
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl IntegerExt for Integer {

if repr.c() {
match &tcx.sess.target.arch[..] {
"hexagon" => min_from_extern = Some(I8),
// WARNING: the ARM EABI has two variants; the one corresponding
// to `at_least == I32` appears to be used on Linux and NetBSD,
// but some systems may use the variant corresponding to no
Expand Down
10 changes: 3 additions & 7 deletions compiler/rustc_mir/src/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ use super::{
mod caller_location;
mod type_name;

fn numeric_intrinsic<'tcx, Tag>(
name: Symbol,
bits: u128,
kind: Primitive,
) -> InterpResult<'tcx, Scalar<Tag>> {
fn numeric_intrinsic<Tag>(name: Symbol, bits: u128, kind: Primitive) -> Scalar<Tag> {
let size = match kind {
Primitive::Int(integer, _) => integer.size(),
_ => bug!("invalid `{}` argument: {:?}", name, bits),
Expand All @@ -41,7 +37,7 @@ fn numeric_intrinsic<'tcx, Tag>(
sym::bitreverse => (bits << extra).reverse_bits(),
_ => bug!("not a numeric intrinsic: {}", name),
};
Ok(Scalar::from_uint(bits_out, size))
Scalar::from_uint(bits_out, size)
}

/// The logic for all nullary intrinsics is implemented here. These intrinsics don't get evaluated
Expand Down Expand Up @@ -208,7 +204,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
if nonzero && bits == 0 {
throw_ub_format!("`{}_nonzero` called on 0", intrinsic_name);
}
let out_val = numeric_intrinsic(intrinsic_name, bits, kind)?;
let out_val = numeric_intrinsic(intrinsic_name, bits, kind);
self.write_scalar(out_val, dest)?;
}
sym::add_with_overflow | sym::sub_with_overflow | sym::mul_with_overflow => {
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir/src/transform/check_consts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ pub fn rustc_allow_const_fn_unstable(
feature_gate: Symbol,
) -> bool {
let attrs = tcx.get_attrs(def_id);
attr::rustc_allow_const_fn_unstable(&tcx.sess, attrs)
.map_or(false, |mut features| features.any(|name| name == feature_gate))
attr::rustc_allow_const_fn_unstable(&tcx.sess, attrs).any(|name| name == feature_gate)
}

// Returns `true` if the given `const fn` is "const-stable".
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ impl<'a> Parser<'a> {
let span = self.mk_expr_sp(&lhs, lhs.span, rhs_span);
let limits =
if op == AssocOp::DotDot { RangeLimits::HalfOpen } else { RangeLimits::Closed };
Ok(self.mk_expr(span, self.mk_range(Some(lhs), rhs, limits)?, AttrVec::new()))
Ok(self.mk_expr(span, self.mk_range(Some(lhs), rhs, limits), AttrVec::new()))
}

fn is_at_start_of_range_notation_rhs(&self) -> bool {
Expand Down Expand Up @@ -474,7 +474,7 @@ impl<'a> Parser<'a> {
} else {
(lo, None)
};
Ok(this.mk_expr(span, this.mk_range(None, opt_end, limits)?, attrs.into()))
Ok(this.mk_expr(span, this.mk_range(None, opt_end, limits), attrs.into()))
})
}

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

let fn_span_lo = self.token.span;
Expand Down Expand Up @@ -2396,12 +2396,12 @@ impl<'a> Parser<'a> {
start: Option<P<Expr>>,
end: Option<P<Expr>>,
limits: RangeLimits,
) -> PResult<'a, ExprKind> {
) -> ExprKind {
if end.is_none() && limits == RangeLimits::Closed {
self.error_inclusive_range_with_no_end(self.prev_token.span);
Ok(ExprKind::Err)
ExprKind::Err
} else {
Ok(ExprKind::Range(start, end, limits))
ExprKind::Range(start, end, limits)
}
}

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

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

crate fn mk_expr(&self, span: Span, kind: ExprKind, attrs: AttrVec) -> P<Expr> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,7 @@ impl<'a> Parser<'a> {
let constness = self.parse_constness();
let asyncness = self.parse_asyncness();
let unsafety = self.parse_unsafety();
let ext = self.parse_extern()?;
let ext = self.parse_extern();

if let Async::Yes { span, .. } = asyncness {
self.ban_async_in_2015(span);
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1202,12 +1202,8 @@ impl<'a> Parser<'a> {
}

/// Parses `extern string_literal?`.
fn parse_extern(&mut self) -> PResult<'a, Extern> {
Ok(if self.eat_keyword(kw::Extern) {
Extern::from_abi(self.parse_abi())
} else {
Extern::None
})
fn parse_extern(&mut self) -> Extern {
if self.eat_keyword(kw::Extern) { Extern::from_abi(self.parse_abi()) } else { Extern::None }
}

/// Parses a string literal as an ABI spec.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<'tcx> CheckConstVisitor<'tcx> {
// However, we cannot allow stable `const fn`s to use unstable features without an explicit
// opt-in via `rustc_allow_const_fn_unstable`.
attr::rustc_allow_const_fn_unstable(&tcx.sess, &tcx.get_attrs(def_id))
.map_or(false, |mut features| features.any(|name| name == feature_gate))
.any(|name| name == feature_gate)
};

match required_gates {
Expand Down
31 changes: 17 additions & 14 deletions compiler/rustc_typeck/src/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,33 +1348,36 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
span: Span,
remaining_fields: FxHashMap<Ident, (usize, &ty::FieldDef)>,
) {
let tcx = self.tcx;
let len = remaining_fields.len();

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

displayable_field_names.sort();

let truncated_fields_error = if len <= 3 {
String::new()
} else {
format!(" and {} other field{}", (len - 3), if len - 3 == 1 { "" } else { "s" })
let mut truncated_fields_error = String::new();
let remaining_fields_names = match &displayable_field_names[..] {
[field1] => format!("`{}`", field1),
[field1, field2] => format!("`{}` and `{}`", field1, field2),
[field1, field2, field3] => format!("`{}`, `{}` and `{}`", field1, field2, field3),
_ => {
truncated_fields_error =
format!(" and {} other field{}", len - 3, pluralize!(len - 3));
displayable_field_names
.iter()
.take(3)
.map(|n| format!("`{}`", n))
.collect::<Vec<_>>()
.join(", ")
}
};

let remaining_fields_names = displayable_field_names
.iter()
.take(3)
.map(|n| format!("`{}`", n))
.collect::<Vec<_>>()
.join(", ");

struct_span_err!(
tcx.sess,
self.tcx.sess,
span,
E0063,
"missing field{} {}{} in initializer of `{}`",
pluralize!(remaining_fields.len()),
pluralize!(len),
remaining_fields_names,
truncated_fields_error,
adt_ty
Expand Down
Loading