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 37 pull requests #59226

Merged
merged 95 commits into from
Mar 16, 2019
Merged
Changes from 1 commit
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
6da206b
Add back in MSVC version check for LLVM
alexcrichton Mar 1, 2019
02b0085
appveyor: Use VS2017 for all our images
alexcrichton Nov 13, 2018
e969de8
Fix "Auto-hide item methods documentation" setting
GuillaumeGomez Mar 2, 2019
c82a42c
Change `std::fs::copy` to use `copyfile` on MacOS and iOS
ebarnard Mar 3, 2019
0a991e4
Add test for the behaviour of `fs::copy` when `to` is a symlink
ebarnard Mar 4, 2019
124ab2a
Fix typo
ebarnard Mar 4, 2019
2b49ec0
Move alloc::prelude::* to alloc::prelude::v1, make alloc a subset of std
SimonSapin Mar 5, 2019
1243859
core: ensure VaList passes improper_ctypes lint
dlrobertson Mar 5, 2019
5d1022a
Rename the feature gate for alloc::prelude
SimonSapin Mar 5, 2019
72958ac
std: Spin for a global malloc lock on wasm32
alexcrichton Mar 1, 2019
710988a
MIPS: add r6 support
wzssyqa Mar 5, 2019
67eabc6
SGX target: Expose thread id function in os module
Mar 5, 2019
876258b
Default to integrated `rust-lld` linker for UEFI targets
phil-opp Mar 6, 2019
ec91f26
Fix SGX implementations of read/write_vectored.
sfackler Mar 8, 2019
ab8e1d2
Always call read/write from default vectored io methods
sfackler Mar 8, 2019
90ae874
add release notes for PR #56243
asomers Mar 6, 2019
a4ea084
Avoid some common false positives in intra doc link checking
Manishearth Mar 9, 2019
3a83cb2
Fix ICE in MIR pretty printing
dlrobertson Mar 9, 2019
4888b1f
we can now skip should_panic tests with the libtest harness
RalfJung Mar 10, 2019
52d9fa8
enabled too many tests
RalfJung Mar 10, 2019
8629fd3
Improvements to comments in libstd, libcore, liballoc.
alexreg Feb 9, 2019
e25df32
consistent naming for duration_float methods and additional f32 methods
newpavlov Mar 11, 2019
35c19c5
move MAX_NANOS_F64/32 to methods
newpavlov Mar 11, 2019
d4b2071
Resolved nits raised in review.
alexreg Mar 11, 2019
980871a
fix tests
newpavlov Mar 11, 2019
197efb0
fix test
newpavlov Mar 11, 2019
78b248d
fix typo
newpavlov Mar 12, 2019
5074489
Unregress using scalar unions in constants.
oli-obk Mar 12, 2019
df05fbf
rustc: fix ICE when trait alias has bare Self
seanmonstar Mar 11, 2019
795d307
Suggest return lifetime when there's only one named lifetime
estebank Mar 12, 2019
f923476
review comments
estebank Mar 12, 2019
adbd0a6
Make std time tests more robust for platform differences
Mar 12, 2019
0ea9b58
Suggest adding lifetime to struct field
estebank Mar 13, 2019
266ca31
Stabilize Range*::contains.
smmalis37 Mar 13, 2019
9d938f6
Add test for #55809.
davidtwco Mar 13, 2019
311025e
Fix generic argument lookup for Self
Mar 7, 2019
c37dab7
Revert "Don't generate minification variable if minification disabled"
Manishearth Mar 13, 2019
5abd6d9
add suggestions to invalid macro item error
euclio Mar 11, 2019
e7b7c41
bootstrap: Default to a sensible llvm-suffix.
emilio Mar 14, 2019
88d43a0
Don't run test launching `echo` since that doesn't exist on Windows
Zoxc Mar 14, 2019
41cdf07
Run RustdocUi earlier
Zoxc Mar 14, 2019
ab19e58
Use try blocks in rustc_codegen_ssa
taiki-e Mar 14, 2019
d1fcd86
Update sources.rs
lukaslueg Mar 14, 2019
fa8fd3d
Add support for comma-separated option lists
tmandry Mar 14, 2019
7c59ce9
Add `-Z allow_features=...` flag
tmandry Mar 13, 2019
bcf1a17
Output diagnostic information for rustdoc.
o01eg Mar 15, 2019
9445f2b
Improved test output for liballoc/str
ohsayan Mar 15, 2019
6d73a8f
Improved test output for libcore/cell
ohsayan Mar 15, 2019
8ff2198
Improved test output for libcore/ops
ohsayan Mar 15, 2019
2f52388
Improved test output for libcore/num/int_macros
ohsayan Mar 15, 2019
e9e5a75
Improved test output for estr-slice
ohsayan Mar 15, 2019
12e3e84
reduced a code repetition related to bit operation.
kenta7777 Mar 15, 2019
5303c1b
Remove restriction on isize/usize in repr(simd)
lambda Mar 15, 2019
9c7bf76
Add x86_64 musl host to the manifest
mati865 Mar 15, 2019
50af62d
removed some unnecessary comments.
kenta7777 Mar 15, 2019
a8fa1a1
a simple refactoring and removing comment.
kenta7777 Mar 15, 2019
9a61580
Option and Result: Add references to documentation of as_ref and as_mut
czipperz Mar 15, 2019
bc3bef8
Rollup merge of #58854 - alexcrichton:update-windows, r=Mark-Simulacrum
kennytm Mar 16, 2019
2318274
Rollup merge of #58855 - alexcrichton:wasm-multithreaded-alloc, r=fit…
kennytm Mar 16, 2019
d869a7b
Rollup merge of #58873 - GuillaumeGomez:fix-auto-hide-method-doc, r=Q…
kennytm Mar 16, 2019
ccbf754
Rollup merge of #58901 - ebarnard:just-copying, r=sfackler
kennytm Mar 16, 2019
382dfea
Rollup merge of #58933 - SimonSapin:alloc-prelude-v1, r=Amanieu
kennytm Mar 16, 2019
5e232b3
Rollup merge of #58938 - dlrobertson:fix_58280, r=joshtriplett
kennytm Mar 16, 2019
9859b81
Rollup merge of #58941 - wzssyqa:master, r=alexcrichton
kennytm Mar 16, 2019
152ed37
Rollup merge of #58949 - jethrogb:jb/sgx-thread-id, r=joshtriplett
kennytm Mar 16, 2019
e2fdf62
Rollup merge of #58976 - phil-opp:patch-2, r=alexcrichton
kennytm Mar 16, 2019
08f264d
Stabilize Option::copied
matklad Mar 16, 2019
d3f30c3
Rollup merge of #59009 - sfackler:fix-sgx-vectors, r=alexcrichton
kennytm Mar 16, 2019
9d74503
Rollup merge of #59025 - aoikonomopoulos:issue-57924, r=varkor
kennytm Mar 16, 2019
db93c9b
Rollup merge of #59036 - dlrobertson:fix_59021, r=estebank
kennytm Mar 16, 2019
7674984
Rollup merge of #59037 - Manishearth:intra-doc-false, r=QuietMisdreavus
kennytm Mar 16, 2019
0e57b72
Rollup merge of #59072 - RalfJung:miri-alloc-tests, r=kennytm
kennytm Mar 16, 2019
6fbd553
Rollup merge of #59079 - euclio:macro-semi, r=estebank
kennytm Mar 16, 2019
d174472
Rollup merge of #59082 - alexreg:cosmetic-2-doc-comments, r=Centril
kennytm Mar 16, 2019
c6569ec
Rollup merge of #59102 - newpavlov:duration_float, r=alexcrichton
kennytm Mar 16, 2019
464478f
Rollup merge of #59118 - seanmonstar:alias-where-self-ice, r=alexreg
kennytm Mar 16, 2019
3bf4398
Rollup merge of #59139 - oli-obk:unions_are_a_good_thing, r=RalfJung
kennytm Mar 16, 2019
bbe5f3d
Rollup merge of #59146 - estebank:suggest-return-lt, r=varkor
kennytm Mar 16, 2019
d84e063
Rollup merge of #59147 - jethrogb:jb/time-tests, r=sfackler
kennytm Mar 16, 2019
6241fb5
Rollup merge of #59152 - smmalis37:range_contains, r=SimonSapin
kennytm Mar 16, 2019
ce9efb1
Rollup merge of #59156 - davidtwco:issue-55809, r=nikomatsakis
kennytm Mar 16, 2019
25e4366
Rollup merge of #59158 - Manishearth:fix-minification, r=GuillaumeGomez
kennytm Mar 16, 2019
8601c79
Rollup merge of #59169 - tmandry:allow-features-flag, r=cramertj
kennytm Mar 16, 2019
6ffcf97
Rollup merge of #59173 - emilio:llvm-suffix, r=Mark-Simulacrum
kennytm Mar 16, 2019
0895931
Rollup merge of #59175 - Zoxc:fix-process-test, r=alexcrichton
kennytm Mar 16, 2019
10fe829
Rollup merge of #59180 - taiki-e:try_blocks, r=scottmcm
kennytm Mar 16, 2019
0b2c348
Rollup merge of #59185 - lukaslueg:patch-2, r=cramertj
kennytm Mar 16, 2019
524a7af
Rollup merge of #59201 - lambda:remove-repr-simd-isize-usize-restrict…
kennytm Mar 16, 2019
2e1104f
Rollup merge of #59204 - o01eg:diag-rustdoc, r=alexcrichton
kennytm Mar 16, 2019
6d4b7fa
Rollup merge of #59206 - sntdevco:master, r=dtolnay
kennytm Mar 16, 2019
6779b7f
Rollup merge of #59208 - kenta7777:reduce-code-repetition, r=oli-obk
kennytm Mar 16, 2019
f336043
Rollup merge of #59212 - mati865:musl_toolchain, r=alexcrichton
kennytm Mar 16, 2019
7f81a29
Rollup merge of #59221 - czipperz:as_ref_documentation, r=Centril
kennytm Mar 16, 2019
40d277e
Rollup merge of #58959 - asomers:issue_58907, r=Mark-Simulacrum
kennytm Mar 16, 2019
7c009a4
Rollup merge of #59231 - matklad:copied, r=Centril
kennytm Mar 16, 2019
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
Prev Previous commit
Next Next commit
Fix generic argument lookup for Self
Rewrite the SelfCtor early and use the replacement Def when
calculating the path_segs.

Note that this also changes which def is seen by the code that
computes user_self_ty and is_alias_variant_ctor; I don't see a
immediate issue with that, but I'm not 100% clear on the
implications.

Fixes #57924
Angelos Oikonomopoulos committed Mar 13, 2019
commit 311025e6a5aad80d028f0771970c43cb4ed025a8
119 changes: 60 additions & 59 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
@@ -5302,6 +5302,53 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
Some(original_span.with_lo(original_span.hi() - BytePos(1)))
}

// Rewrite `SelfCtor` to `StructCtor`
pub fn rewrite_self_ctor(&self, def: Def, span: Span) -> (Def, DefId, Ty<'tcx>) {
let tcx = self.tcx;
if let Def::SelfCtor(impl_def_id) = def {
let ty = self.impl_self_ty(span, impl_def_id).ty;
let adt_def = ty.ty_adt_def();

match adt_def {
Some(adt_def) if adt_def.has_ctor() => {
let variant = adt_def.non_enum_variant();
let def = Def::StructCtor(variant.did, variant.ctor_kind);
(def, variant.did, tcx.type_of(variant.did))
}
_ => {
let mut err = tcx.sess.struct_span_err(span,
"the `Self` constructor can only be used with tuple or unit structs");
if let Some(adt_def) = adt_def {
match adt_def.adt_kind() {
AdtKind::Enum => {
err.help("did you mean to use one of the enum's variants?");
},
AdtKind::Struct |
AdtKind::Union => {
err.span_suggestion(
span,
"use curly brackets",
String::from("Self { /* fields */ }"),
Applicability::HasPlaceholders,
);
}
}
}
err.emit();

(def, impl_def_id, tcx.types.err)
}
}
} else {
let def_id = def.def_id();

// The things we are substituting into the type should not contain
// escaping late-bound regions, and nor should the base type scheme.
let ty = tcx.type_of(def_id);
(def, def_id, ty)
}
}

// Instantiates the given path, which must refer to an item with the given
// number of type parameters and type.
pub fn instantiate_value_path(&self,
@@ -5321,6 +5368,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {

let tcx = self.tcx;

match def {
Def::Local(nid) | Def::Upvar(nid, ..) => {
let hid = self.tcx.hir().node_to_hir_id(nid);
let ty = self.local_ty(span, hid).decl_ty;
let ty = self.normalize_associated_types_in(span, &ty);
self.write_ty(hir_id, ty);
return (ty, def);
}
_ => {}
}

let (def, def_id, ty) = self.rewrite_self_ctor(def, span);
let path_segs = AstConv::def_ids_for_path_segments(self, segments, self_ty, def);

let mut user_self_ty = None;
@@ -5382,17 +5441,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
user_self_ty = None;
}

match def {
Def::Local(nid) | Def::Upvar(nid, ..) => {
let hid = self.tcx.hir().node_to_hir_id(nid);
let ty = self.local_ty(span, hid).decl_ty;
let ty = self.normalize_associated_types_in(span, &ty);
self.write_ty(hir_id, ty);
return (ty, def);
}
_ => {}
}

// Now we have to compare the types that the user *actually*
// provided against the types that were *expected*. If the user
// did not provide any types, then we want to substitute inference
@@ -5425,53 +5473,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
tcx.generics_of(*def_id).has_self
}).unwrap_or(false);

let mut new_def = def;
let (def_id, ty) = match def {
Def::SelfCtor(impl_def_id) => {
let ty = self.impl_self_ty(span, impl_def_id).ty;
let adt_def = ty.ty_adt_def();

match adt_def {
Some(adt_def) if adt_def.has_ctor() => {
let variant = adt_def.non_enum_variant();
new_def = Def::StructCtor(variant.did, variant.ctor_kind);
(variant.did, tcx.type_of(variant.did))
}
_ => {
let mut err = tcx.sess.struct_span_err(span,
"the `Self` constructor can only be used with tuple or unit structs");
if let Some(adt_def) = adt_def {
match adt_def.adt_kind() {
AdtKind::Enum => {
err.help("did you mean to use one of the enum's variants?");
},
AdtKind::Struct |
AdtKind::Union => {
err.span_suggestion(
span,
"use curly brackets",
String::from("Self { /* fields */ }"),
Applicability::HasPlaceholders,
);
}
}
}
err.emit();

(impl_def_id, tcx.types.err)
}
}
}
_ => {
let def_id = def.def_id();

// The things we are substituting into the type should not contain
// escaping late-bound regions, and nor should the base type scheme.
let ty = tcx.type_of(def_id);
(def_id, ty)
}
};

let substs = AstConv::create_substs_for_generic_args(
tcx,
def_id,
@@ -5587,7 +5588,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
ty_substituted);
self.write_substs(hir_id, substs);

(ty_substituted, new_def)
(ty_substituted, def)
}

fn check_rustc_args_require_const(&self,
9 changes: 9 additions & 0 deletions src/test/run-pass/issues/issue-57924.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pub struct Gcm<E>(E);

impl<E> Gcm<E> {
pub fn crash(e: E) -> Self {
Self::<E>(e)
}
}

fn main() {}