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 17 pull requests #73475

Closed
wants to merge 77 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
d4fe955
Implement partial error recovery for `let` with `BinOpEq`
mibac138 May 7, 2020
48ff12a
Expand partial error recovery for `let` with `BinOpEq`
mibac138 May 7, 2020
05d6531
Error recovery for `let` with `+=`
mibac138 May 7, 2020
6ad24ba
Adjust according to estebank's review comments
mibac138 May 7, 2020
98532a3
Adjust according to petrochenkov's review comments
mibac138 May 20, 2020
591584e
Add tests for 'impl Default for [T; N]'
MikailBag May 26, 2020
3313bf6
Skip leak test on targets without panic=unwind
MikailBag May 28, 2020
358dc1d
Added io forwarding methods to the stdio structs
Lucretiel May 28, 2020
f7d745f
tag/niche terminology cleanup
RalfJung May 23, 2020
7a6d03c
miri errors: rename InvalidDiscriminant -> InvalidTag
RalfJung May 30, 2020
1bc4e45
Only highlight results via mouseover if mouse has moved
carols10cents Jun 2, 2020
724dfba
Clean up some weird command strings
GuillaumeGomez Jun 13, 2020
4606168
Make new type param suggestion more targetted
estebank Jun 13, 2020
afbbd38
Note numeric literals that can never fit in an expected type
ayazhafiz Jun 13, 2020
2b936bb
fixup! Note numeric literals that can never fit in an expected type
ayazhafiz Jun 14, 2020
e32db84
Add rust features to print target features
aszenz Jun 14, 2020
f62903b
Export `#[inline] #[no_mangle]` fns in cdylibs and staticlibs
doctorn Jun 5, 2020
6b7cacb
Export all fns with extern indicator
doctorn Jun 8, 2020
d23bedd
Fix whitespace
doctorn Jun 8, 2020
ee810a7
Fix exports with `#[inline(always)]`
doctorn Jun 9, 2020
11b56fb
Fix whitespace
doctorn Jun 9, 2020
babda94
Fix sanitizer test
doctorn Jun 15, 2020
e8e0a0e
Update sanitizer test
doctorn Jun 15, 2020
9e51008
Complete the std::time documentation to warn about the inconsistencie…
poliorcetics Jun 15, 2020
81c9094
Suggest substituting `'static` lifetime in impl/dyn `Trait + 'static`…
estebank May 29, 2020
4e90f17
When `'static` is explicit, suggest constraining argument with it
estebank May 30, 2020
921f35f
Reduce verbosity of suggestion message and mention lifetime in label
estebank May 30, 2020
e755889
Move overlapping span to a note
estebank May 30, 2020
bc15790
Tweak output for overlapping required/captured spans
estebank May 30, 2020
539e978
Tweak wording and add error code
estebank May 30, 2020
31ea589
review comments: wording
estebank Jun 1, 2020
10d9bf1
Use note for requirement source span
estebank Jun 2, 2020
34d8692
Register new eror code
estebank Jun 2, 2020
e31367d
small tweaks
estebank Jun 2, 2020
f7a1f97
Change E0758 to E0759 to avoid conflict with #72912
estebank Jun 3, 2020
bfe1434
fix rebase
estebank Jun 15, 2020
10c8d2a
add FIXME to EnumTagInfo
RalfJung Jun 15, 2020
96f5584
Expand "recursive opaque type" diagnostic
estebank Apr 19, 2020
8f12485
review comments
estebank Jun 15, 2020
268decb
make all uses of ty::Error or ConstKind::Error delay a span bug
mark-i-m May 6, 2020
e855b90
track caller for delay_span_bug
mark-i-m May 26, 2020
0bcefd9
remove visit_terminator_kind from MIR visitor
RalfJung May 31, 2020
302fb50
get rid of an unused 'span' field
RalfJung May 31, 2020
046165a
rename location field of Drop terminators to place
RalfJung Jun 10, 2020
6c5345f
fmt; make visit_terminator arg names consistent with the rest
RalfJung Jun 10, 2020
827ccf7
add probably accidentally missing super_* calls
RalfJung Jun 10, 2020
f0d3689
fixup! Note numeric literals that can never fit in an expected type
ayazhafiz Jun 16, 2020
cfdbbb5
format derives
mark-i-m Jun 16, 2020
4506a35
add header for rust specific feature
aszenz Jun 16, 2020
9f50f84
break long line for formatting
aszenz Jun 16, 2020
457acbd
trim whitespace
aszenz Jun 16, 2020
af45d8a
Suggest new type param on single char ident
estebank Jun 13, 2020
d7277df
fixup! Note numeric literals that can never fit in an expected type
ayazhafiz Jun 17, 2020
caffb28
add blank line bw sections
aszenz Jun 17, 2020
7a89a33
fixup! Note numeric literals that can never fit in an expected type
ayazhafiz Jun 17, 2020
b60cefe
Removed write_fmt forwarding, to fix recursive borrow issues
Lucretiel Jun 17, 2020
8d1a380
review comments
estebank Jun 17, 2020
14d385b
Restore some write_fmts
Lucretiel Jun 17, 2020
e5c5df8
Add specialization of `ToString for char`
tesuji Jun 18, 2020
d134870
Document format correction
qy3u Jun 18, 2020
d176448
Rollup merge of #70551 - mark-i-m:ty-err-2, r=varkor
Manishearth Jun 18, 2020
2e9e434
Rollup merge of #71338 - estebank:recursive-impl-trait, r=nikomatsakis
Manishearth Jun 18, 2020
09ca6a4
Rollup merge of #71976 - mibac138:let-recovery, r=estebank
Manishearth Jun 18, 2020
0a9ad17
Rollup merge of #72497 - RalfJung:tag-term, r=oli-obk
Manishearth Jun 18, 2020
538671b
Rollup merge of #72628 - MikailBag:array-default-tests, r=shepmaster
Manishearth Jun 18, 2020
90a2403
Rollup merge of #72705 - Lucretiel:stdio-forwarding, r=Amanieu
Manishearth Jun 18, 2020
32b4084
Rollup merge of #72804 - estebank:opaque-missing-lts-in-fn-2, r=nikom…
Manishearth Jun 18, 2020
be8fe77
Rollup merge of #72814 - RalfJung:mir-visir-terminator, r=oli-obk
Manishearth Jun 18, 2020
f419606
Rollup merge of #72836 - poliorcetics:std-time-os-specificities, r=sh…
Manishearth Jun 18, 2020
4641943
Rollup merge of #72968 - integer32llc:docs-arrow-keys, r=GuillaumeGomez
Manishearth Jun 18, 2020
89825e2
Rollup merge of #73034 - doctorn:nomangle-inline-linkage, r=matthewja…
Manishearth Jun 18, 2020
d315db4
Rollup merge of #73315 - GuillaumeGomez:clean-up-config-strs, r=kinnison
Manishearth Jun 18, 2020
6717409
Rollup merge of #73320 - estebank:type-param-sugg-more, r=davidtwco
Manishearth Jun 18, 2020
a2125e5
Rollup merge of #73334 - ayazhafiz:err/num-type-cannot-fit, r=estebank
Manishearth Jun 18, 2020
8fa2f09
Rollup merge of #73346 - aszenz:patch-1, r=cuviper
Manishearth Jun 18, 2020
d8f6804
Rollup merge of #73464 - qy3u:fs-document-format-correction, r=jonas-…
Manishearth Jun 18, 2020
67d5f65
Rollup merge of #73465 - lzutao:spec-char-tostring, r=sfackler
Manishearth Jun 18, 2020
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
8 changes: 8 additions & 0 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,14 @@ impl<T: fmt::Display + ?Sized> ToString for T {
}
}

#[stable(feature = "char_to_string_specialization", since = "1.46.0")]
impl ToString for char {
#[inline]
fn to_string(&self) -> String {
String::from(self.encode_utf8(&mut [0; 4]))
}
}

#[stable(feature = "str_to_string_specialization", since = "1.9.0")]
impl ToString for str {
#[inline]
Expand Down
49 changes: 49 additions & 0 deletions src/libcore/tests/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,52 @@ fn iterator_drops() {
}
assert_eq!(i.get(), 5);
}

// This test does not work on targets without panic=unwind support.
// To work around this problem, test is marked is should_panic, so it will
// be automagically skipped on unsuitable targets, such as
// wasm32-unknown-unkown.
//
// It means that we use panic for indicating success.
#[test]
#[should_panic(expected = "test succeeded")]
fn array_default_impl_avoids_leaks_on_panic() {
use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
static COUNTER: AtomicUsize = AtomicUsize::new(0);
#[derive(Debug)]
struct Bomb(usize);

impl Default for Bomb {
fn default() -> Bomb {
if COUNTER.load(Relaxed) == 3 {
panic!("bomb limit exceeded");
}

COUNTER.fetch_add(1, Relaxed);
Bomb(COUNTER.load(Relaxed))
}
}

impl Drop for Bomb {
fn drop(&mut self) {
COUNTER.fetch_sub(1, Relaxed);
}
}

let res = std::panic::catch_unwind(|| <[Bomb; 5]>::default());
let panic_msg = match res {
Ok(_) => unreachable!(),
Err(p) => p.downcast::<&'static str>().unwrap(),
};
assert_eq!(*panic_msg, "bomb limit exceeded");
// check that all bombs are successfully dropped
assert_eq!(COUNTER.load(Relaxed), 0);
panic!("test succeeded")
}

#[test]
fn empty_array_is_always_default() {
struct DoesNotImplDefault;

let _arr = <[DoesNotImplDefault; 0]>::default();
}
108 changes: 53 additions & 55 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use self::EnumDiscriminantInfo::*;
use self::EnumTagInfo::*;
use self::MemberDescriptionFactory::*;
use self::RecursiveTypeDescription::*;

Expand Down Expand Up @@ -40,7 +40,7 @@ use rustc_middle::{bug, span_bug};
use rustc_session::config::{self, DebugInfo};
use rustc_span::symbol::{Interner, Symbol};
use rustc_span::{self, SourceFile, SourceFileHash, Span};
use rustc_target::abi::{Abi, Align, DiscriminantKind, HasDataLayout, Integer, LayoutOf};
use rustc_target::abi::{Abi, Align, HasDataLayout, Integer, LayoutOf, TagEncoding};
use rustc_target::abi::{Int, Pointer, F32, F64};
use rustc_target::abi::{Primitive, Size, VariantIdx, Variants};

Expand Down Expand Up @@ -1335,7 +1335,7 @@ fn generator_layout_and_saved_local_names(
struct EnumMemberDescriptionFactory<'ll, 'tcx> {
enum_type: Ty<'tcx>,
layout: TyAndLayout<'tcx>,
discriminant_type_metadata: Option<&'ll DIType>,
tag_type_metadata: Option<&'ll DIType>,
containing_scope: &'ll DIScope,
span: Span,
}
Expand Down Expand Up @@ -1385,7 +1385,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
cx,
self.layout,
variant_info,
NoDiscriminant,
NoTag,
self_metadata,
self.span,
);
Expand All @@ -1409,19 +1409,19 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
}]
}
Variants::Multiple {
discr_kind: DiscriminantKind::Tag,
discr_index,
tag_encoding: TagEncoding::Direct,
tag_field,
ref variants,
..
} => {
let discriminant_info = if fallback {
RegularDiscriminant {
discr_field: Field::from(discr_index),
discr_type_metadata: self.discriminant_type_metadata.unwrap(),
let tag_info = if fallback {
RegularTag {
tag_field: Field::from(tag_field),
tag_type_metadata: self.tag_type_metadata.unwrap(),
}
} else {
// This doesn't matter in this case.
NoDiscriminant
NoTag
};
variants
.iter_enumerated()
Expand All @@ -1432,7 +1432,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
cx,
variant,
variant_info,
discriminant_info,
tag_info,
self_metadata,
self.span,
);
Expand Down Expand Up @@ -1467,11 +1467,11 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
.collect()
}
Variants::Multiple {
discr_kind:
DiscriminantKind::Niche { ref niche_variants, niche_start, dataful_variant },
ref discr,
tag_encoding:
TagEncoding::Niche { ref niche_variants, niche_start, dataful_variant },
ref tag,
ref variants,
discr_index,
tag_field,
} => {
if fallback {
let variant = self.layout.for_variant(cx, dataful_variant);
Expand All @@ -1480,7 +1480,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
cx,
variant,
variant_info_for(dataful_variant),
OptimizedDiscriminant,
OptimizedTag,
self.containing_scope,
self.span,
);
Expand Down Expand Up @@ -1524,8 +1524,8 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
cx,
&mut name,
self.layout,
self.layout.fields.offset(discr_index),
self.layout.field(cx, discr_index).size,
self.layout.fields.offset(tag_field),
self.layout.field(cx, tag_field).size,
);
variant_info_for(*niche_variants.start()).map_struct_name(|variant_name| {
name.push_str(variant_name);
Expand All @@ -1552,7 +1552,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
cx,
variant,
variant_info,
OptimizedDiscriminant,
OptimizedTag,
self_metadata,
self.span,
);
Expand All @@ -1573,7 +1573,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
let value = (i.as_u32() as u128)
.wrapping_sub(niche_variants.start().as_u32() as u128)
.wrapping_add(niche_start);
let value = truncate(value, discr.value.size(cx));
let value = truncate(value, tag.value.size(cx));
// NOTE(eddyb) do *NOT* remove this assert, until
// we pass the full 128-bit value to LLVM, otherwise
// truncation will be silent and remain undetected.
Expand Down Expand Up @@ -1603,7 +1603,7 @@ struct VariantMemberDescriptionFactory<'ll, 'tcx> {
/// Cloned from the `layout::Struct` describing the variant.
offsets: Vec<Size>,
args: Vec<(String, Ty<'tcx>)>,
discriminant_type_metadata: Option<&'ll DIType>,
tag_type_metadata: Option<&'ll DIType>,
span: Span,
}

Expand All @@ -1617,7 +1617,7 @@ impl VariantMemberDescriptionFactory<'ll, 'tcx> {
MemberDescription {
name: name.to_string(),
type_metadata: if use_enum_fallback(cx) {
match self.discriminant_type_metadata {
match self.tag_type_metadata {
// Discriminant is always the first field of our variant
// when using the enum fallback.
Some(metadata) if i == 0 => metadata,
Expand All @@ -1637,11 +1637,14 @@ impl VariantMemberDescriptionFactory<'ll, 'tcx> {
}
}

// FIXME: terminology here should be aligned with `abi::TagEncoding`.
// `OptimizedTag` is `TagEncoding::Niche`, `RegularTag` is `TagEncoding::Direct`.
// `NoTag` should be removed; users should use `Option<EnumTagInfo>` instead.
#[derive(Copy, Clone)]
enum EnumDiscriminantInfo<'ll> {
RegularDiscriminant { discr_field: Field, discr_type_metadata: &'ll DIType },
OptimizedDiscriminant,
NoDiscriminant,
enum EnumTagInfo<'ll> {
RegularTag { tag_field: Field, tag_type_metadata: &'ll DIType },
OptimizedTag,
NoTag,
}

#[derive(Copy, Clone)]
Expand Down Expand Up @@ -1706,7 +1709,7 @@ fn describe_enum_variant(
cx: &CodegenCx<'ll, 'tcx>,
layout: layout::TyAndLayout<'tcx>,
variant: VariantInfo<'_, 'tcx>,
discriminant_info: EnumDiscriminantInfo<'ll>,
discriminant_info: EnumTagInfo<'ll>,
containing_scope: &'ll DIScope,
span: Span,
) -> (&'ll DICompositeType, MemberDescriptionFactory<'ll, 'tcx>) {
Expand All @@ -1722,12 +1725,12 @@ fn describe_enum_variant(
let (offsets, args) = if use_enum_fallback(cx) {
// If this is not a univariant enum, there is also the discriminant field.
let (discr_offset, discr_arg) = match discriminant_info {
RegularDiscriminant { discr_field, .. } => {
RegularTag { tag_field, .. } => {
// We have the layout of an enum variant, we need the layout of the outer enum
let enum_layout = cx.layout_of(layout.ty);
let offset = enum_layout.fields.offset(discr_field.as_usize());
let offset = enum_layout.fields.offset(tag_field.as_usize());
let args =
("RUST$ENUM$DISR".to_owned(), enum_layout.field(cx, discr_field.as_usize()).ty);
("RUST$ENUM$DISR".to_owned(), enum_layout.field(cx, tag_field.as_usize()).ty);
(Some(offset), Some(args))
}
_ => (None, None),
Expand Down Expand Up @@ -1757,8 +1760,8 @@ fn describe_enum_variant(
let member_description_factory = VariantMDF(VariantMemberDescriptionFactory {
offsets,
args,
discriminant_type_metadata: match discriminant_info {
RegularDiscriminant { discr_type_metadata, .. } => Some(discr_type_metadata),
tag_type_metadata: match discriminant_info {
RegularTag { tag_type_metadata, .. } => Some(tag_type_metadata),
_ => None,
},
span,
Expand Down Expand Up @@ -1880,18 +1883,18 @@ fn prepare_enum_metadata(

if let (
&Abi::Scalar(_),
&Variants::Multiple { discr_kind: DiscriminantKind::Tag, ref discr, .. },
&Variants::Multiple { tag_encoding: TagEncoding::Direct, ref tag, .. },
) = (&layout.abi, &layout.variants)
{
return FinalMetadata(discriminant_type_metadata(discr.value));
return FinalMetadata(discriminant_type_metadata(tag.value));
}

if use_enum_fallback(cx) {
let discriminant_type_metadata = match layout.variants {
Variants::Single { .. }
| Variants::Multiple { discr_kind: DiscriminantKind::Niche { .. }, .. } => None,
Variants::Multiple { discr_kind: DiscriminantKind::Tag, ref discr, .. } => {
Some(discriminant_type_metadata(discr.value))
| Variants::Multiple { tag_encoding: TagEncoding::Niche { .. }, .. } => None,
Variants::Multiple { tag_encoding: TagEncoding::Direct, ref tag, .. } => {
Some(discriminant_type_metadata(tag.value))
}
};

Expand Down Expand Up @@ -1927,7 +1930,7 @@ fn prepare_enum_metadata(
EnumMDF(EnumMemberDescriptionFactory {
enum_type,
layout,
discriminant_type_metadata,
tag_type_metadata: discriminant_type_metadata,
containing_scope,
span,
}),
Expand All @@ -1943,24 +1946,21 @@ fn prepare_enum_metadata(
Variants::Single { .. } => None,

Variants::Multiple {
discr_kind: DiscriminantKind::Niche { .. },
ref discr,
discr_index,
..
tag_encoding: TagEncoding::Niche { .. }, ref tag, tag_field, ..
} => {
// Find the integer type of the correct size.
let size = discr.value.size(cx);
let align = discr.value.align(cx);
let size = tag.value.size(cx);
let align = tag.value.align(cx);

let discr_type = match discr.value {
let tag_type = match tag.value {
Int(t, _) => t,
F32 => Integer::I32,
F64 => Integer::I64,
Pointer => cx.data_layout().ptr_sized_integer(),
}
.to_ty(cx.tcx, false);

let discr_metadata = basic_type_metadata(cx, discr_type);
let tag_metadata = basic_type_metadata(cx, tag_type);
unsafe {
Some(llvm::LLVMRustDIBuilderCreateMemberType(
DIB(cx),
Expand All @@ -1971,17 +1971,15 @@ fn prepare_enum_metadata(
UNKNOWN_LINE_NUMBER,
size.bits(),
align.abi.bits() as u32,
layout.fields.offset(discr_index).bits(),
layout.fields.offset(tag_field).bits(),
DIFlags::FlagArtificial,
discr_metadata,
tag_metadata,
))
}
}

Variants::Multiple {
discr_kind: DiscriminantKind::Tag, ref discr, discr_index, ..
} => {
let discr_type = discr.value.to_ty(cx.tcx);
Variants::Multiple { tag_encoding: TagEncoding::Direct, ref tag, tag_field, .. } => {
let discr_type = tag.value.to_ty(cx.tcx);
let (size, align) = cx.size_and_align_of(discr_type);

let discr_metadata = basic_type_metadata(cx, discr_type);
Expand All @@ -1995,7 +1993,7 @@ fn prepare_enum_metadata(
UNKNOWN_LINE_NUMBER,
size.bits(),
align.bits() as u32,
layout.fields.offset(discr_index).bits(),
layout.fields.offset(tag_field).bits(),
DIFlags::FlagArtificial,
discr_metadata,
))
Expand Down Expand Up @@ -2081,7 +2079,7 @@ fn prepare_enum_metadata(
EnumMDF(EnumMemberDescriptionFactory {
enum_type,
layout,
discriminant_type_metadata: None,
tag_type_metadata: None,
containing_scope,
span,
}),
Expand Down
10 changes: 6 additions & 4 deletions src/librustc_codegen_ssa/back/symbol_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, cnum: CrateNum) -> DefIdMap<
| Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }) => {
let def_id = tcx.hir().local_def_id(hir_id);
let generics = tcx.generics_of(def_id);
if !generics.requires_monomorphization(tcx) &&
// Functions marked with #[inline] are only ever codegened
// with "internal" linkage and are never exported.
!Instance::mono(tcx, def_id.to_def_id()).def.generates_cgu_internal_copy(tcx)
if !generics.requires_monomorphization(tcx)
// Functions marked with #[inline] are codegened with "internal"
// linkage and are not exported unless marked with an extern
// inidicator
&& (!Instance::mono(tcx, def_id.to_def_id()).def.generates_cgu_internal_copy(tcx)
|| tcx.codegen_fn_attrs(def_id.to_def_id()).contains_extern_indicator())
{
Some(def_id)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/debuginfo/type_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub fn push_debuginfo_type_name<'tcx>(
tcx.def_key(def_id).disambiguated_data.disambiguator
));
}
ty::Error
ty::Error(_)
| ty::Infer(_)
| ty::Placeholder(..)
| ty::Projection(..)
Expand Down
Loading