Skip to content

Commit 6187684

Browse files
committed
Auto merge of #64172 - Centril:rollup-8i8oh54, r=Centril
Rollup of 11 pull requests Successful merges: - #62848 (Use unicode-xid crate instead of libcore) - #63774 (Fix `window.hashchange is not a function`) - #63930 (Account for doc comments coming from proc macros without spans) - #64003 (place: Passing `align` = `layout.align.abi`, when also passing `layout`) - #64030 (Fix unlock ordering in SGX synchronization primitives) - #64041 (use TokenStream rather than &[TokenTree] for built-in macros) - #64051 (Add x86_64-linux-kernel target) - #64063 (Fix const_err with `-(-0.0)`) - #64083 (Point at appropriate arm on type error on if/else/match with one non-! arm) - #64100 (Fix const eval bug breaking run-pass tests in Miri) - #64157 (Opaque type locations in error message for clarity.) Failed merges: r? @ghost
2 parents 9776723 + afc7e0e commit 6187684

File tree

79 files changed

+1006
-757
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1006
-757
lines changed

Cargo.lock

+13-4
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ dependencies = [
10111011
name = "fmt_macros"
10121012
version = "0.0.0"
10131013
dependencies = [
1014+
"rustc_lexer",
10141015
"syntax_pos",
10151016
]
10161017

@@ -2372,7 +2373,7 @@ version = "0.4.30"
23722373
source = "registry+https://github.com/rust-lang/crates.io-index"
23732374
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
23742375
dependencies = [
2375-
"unicode-xid",
2376+
"unicode-xid 0.1.0",
23762377
]
23772378

23782379
[[package]]
@@ -3290,7 +3291,7 @@ dependencies = [
32903291
name = "rustc_lexer"
32913292
version = "0.1.0"
32923293
dependencies = [
3293-
"unicode-xid",
3294+
"unicode-xid 0.2.0",
32943295
]
32953296

32963297
[[package]]
@@ -3368,6 +3369,7 @@ dependencies = [
33683369
"rustc_apfloat",
33693370
"rustc_data_structures",
33703371
"rustc_errors",
3372+
"rustc_lexer",
33713373
"rustc_target",
33723374
"serialize",
33733375
"smallvec",
@@ -3976,7 +3978,7 @@ checksum = "641e117d55514d6d918490e47102f7e08d096fdde360247e4a10f7a91a8478d3"
39763978
dependencies = [
39773979
"proc-macro2",
39783980
"quote",
3979-
"unicode-xid",
3981+
"unicode-xid 0.1.0",
39803982
]
39813983

39823984
[[package]]
@@ -3988,7 +3990,7 @@ dependencies = [
39883990
"proc-macro2",
39893991
"quote",
39903992
"syn",
3991-
"unicode-xid",
3993+
"unicode-xid 0.1.0",
39923994
]
39933995

39943996
[[package]]
@@ -4017,6 +4019,7 @@ dependencies = [
40174019
"log",
40184020
"rustc_data_structures",
40194021
"rustc_errors",
4022+
"rustc_lexer",
40204023
"rustc_target",
40214024
"smallvec",
40224025
"syntax",
@@ -4532,6 +4535,12 @@ version = "0.1.0"
45324535
source = "registry+https://github.com/rust-lang/crates.io-index"
45334536
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
45344537

4538+
[[package]]
4539+
name = "unicode-xid"
4540+
version = "0.2.0"
4541+
source = "registry+https://github.com/rust-lang/crates.io-index"
4542+
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
4543+
45354544
[[package]]
45364545
name = "unicode_categories"
45374546
version = "0.1.1"

src/doc/unstable-book/src/language-features/plugin.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ extern crate rustc;
5757
extern crate rustc_driver;
5858
5959
use syntax::parse::token::{self, Token};
60-
use syntax::tokenstream::TokenTree;
60+
use syntax::tokenstream::{TokenTree, TokenStream};
6161
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
6262
use syntax_pos::Span;
6363
use rustc_driver::plugin::Registry;
6464
65-
fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
65+
fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: TokenStream)
6666
-> Box<dyn MacResult + 'static> {
6767
6868
static NUMERALS: &'static [(&'static str, usize)] = &[
@@ -78,7 +78,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
7878
return DummyResult::any(sp);
7979
}
8080
81-
let text = match args[0] {
81+
let text = match args.into_trees().next().unwrap() {
8282
TokenTree::Token(Token { kind: token::Ident(s, _), .. }) => s.to_string(),
8383
_ => {
8484
cx.span_err(sp, "argument should be a single identifier");

src/libcore/char/methods.rs

-23
Original file line numberDiff line numberDiff line change
@@ -547,29 +547,6 @@ impl char {
547547
}
548548
}
549549

550-
/// Returns `true` if this `char` satisfies the `XID_Start` Unicode property, and false
551-
/// otherwise.
552-
///
553-
/// `XID_Start` is a Unicode Derived Property specified in
554-
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
555-
/// mostly similar to `ID_Start` but modified for closure under `NFKx`.
556-
#[unstable(feature = "unicode_internals", issue = "0")]
557-
pub fn is_xid_start(self) -> bool {
558-
derived_property::XID_Start(self)
559-
}
560-
561-
/// Returns `true` if this `char` satisfies the `XID_Continue` Unicode property, and false
562-
/// otherwise.
563-
///
564-
/// `XID_Continue` is a Unicode Derived Property specified in
565-
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
566-
/// mostly similar to `ID_Continue` but modified for closure under NFKx.
567-
#[unstable(feature = "unicode_internals", issue = "0")]
568-
#[inline]
569-
pub fn is_xid_continue(self) -> bool {
570-
derived_property::XID_Continue(self)
571-
}
572-
573550
/// Returns `true` if this `char` is lowercase.
574551
///
575552
/// 'Lowercase' is defined according to the terms of the Unicode Derived Core

src/libcore/unicode/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,3 @@ pub mod derived_property {
1313
pub mod conversions {
1414
pub use crate::unicode::tables::conversions::{to_lower, to_upper};
1515
}
16-
17-
// For use in libsyntax
18-
pub mod property {
19-
pub use crate::unicode::tables::property::Pattern_White_Space;
20-
}

src/libcore/unicode/tables.rs

-375
Large diffs are not rendered by default.

src/libcore/unicode/unicode.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ def generate_property_module(mod, grouped_categories, category_subset):
728728

729729
yield "pub(crate) mod %s {\n" % mod
730730
for cat in sorted(category_subset):
731-
if cat in ("Cc", "White_Space", "Pattern_White_Space"):
731+
if cat in ("Cc", "White_Space"):
732732
generator = generate_small_bool_trie("%s_table" % cat, grouped_categories[cat])
733733
else:
734734
generator = generate_bool_trie("%s_table" % cat, grouped_categories[cat])
@@ -841,19 +841,18 @@ def main():
841841
unicode_data = load_unicode_data(get_path(UnicodeFiles.UNICODE_DATA))
842842
load_special_casing(get_path(UnicodeFiles.SPECIAL_CASING), unicode_data)
843843

844-
want_derived = {"XID_Start", "XID_Continue", "Alphabetic", "Lowercase", "Uppercase",
844+
want_derived = {"Alphabetic", "Lowercase", "Uppercase",
845845
"Cased", "Case_Ignorable", "Grapheme_Extend"}
846846
derived = load_properties(get_path(UnicodeFiles.DERIVED_CORE_PROPERTIES), want_derived)
847847

848848
props = load_properties(get_path(UnicodeFiles.PROPS),
849-
{"White_Space", "Join_Control", "Noncharacter_Code_Point",
850-
"Pattern_White_Space"})
849+
{"White_Space", "Join_Control", "Noncharacter_Code_Point"})
851850

852851
# Category tables
853852
for (name, categories, category_subset) in (
854853
("general_category", unicode_data.general_categories, ["N", "Cc"]),
855854
("derived_property", derived, want_derived),
856-
("property", props, ["White_Space", "Pattern_White_Space"])
855+
("property", props, ["White_Space"])
857856
):
858857
for fragment in generate_property_module(name, categories, category_subset):
859858
buf.write(fragment)

src/libfmt_macros/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ path = "lib.rs"
1010

1111
[dependencies]
1212
syntax_pos = { path = "../libsyntax_pos" }
13-
13+
rustc_lexer = { path = "../librustc_lexer" }

src/libfmt_macros/lib.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -597,12 +597,11 @@ impl<'a> Parser<'a> {
597597
}
598598
}
599599

600-
/// Parses a word starting at the current position. A word is considered to
601-
/// be an alphabetic character followed by any number of alphanumeric
602-
/// characters.
600+
/// Parses a word starting at the current position. A word is the same as
601+
/// Rust identifier, except that it can't start with `_` character.
603602
fn word(&mut self) -> &'a str {
604603
let start = match self.cur.peek() {
605-
Some(&(pos, c)) if c.is_xid_start() => {
604+
Some(&(pos, c)) if c != '_' && rustc_lexer::is_id_start(c) => {
606605
self.cur.next();
607606
pos
608607
}
@@ -611,7 +610,7 @@ impl<'a> Parser<'a> {
611610
}
612611
};
613612
while let Some(&(pos, c)) = self.cur.peek() {
614-
if c.is_xid_continue() {
613+
if rustc_lexer::is_id_continue(c) {
615614
self.cur.next();
616615
} else {
617616
return &self.input[start..pos];

src/librustc/infer/error_reporting/mod.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1136,12 +1136,19 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11361136
if let Some((expected, found)) = expected_found {
11371137
match (terr, is_simple_error, expected == found) {
11381138
(&TypeError::Sorts(ref values), false, true) => {
1139+
let sort_string = | a_type: Ty<'tcx> |
1140+
if let ty::Opaque(def_id, _) = a_type.sty {
1141+
format!(" (opaque type at {})", self.tcx.sess.source_map()
1142+
.mk_substr_filename(self.tcx.def_span(def_id)))
1143+
} else {
1144+
format!(" ({})", a_type.sort_string(self.tcx))
1145+
};
11391146
diag.note_expected_found_extra(
11401147
&"type",
11411148
expected,
11421149
found,
1143-
&format!(" ({})", values.expected.sort_string(self.tcx)),
1144-
&format!(" ({})", values.found.sort_string(self.tcx)),
1150+
&sort_string(values.expected),
1151+
&sort_string(values.found),
11451152
);
11461153
}
11471154
(_, false, _) => {

src/librustc_codegen_llvm/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
561561

562562
let align = dest.align.restrict_for_offset(dest.layout.field(self.cx(), 0).size);
563563
cg_elem.val.store(&mut body_bx,
564-
PlaceRef::new_sized(current, cg_elem.layout, align));
564+
PlaceRef::new_sized_aligned(current, cg_elem.layout, align));
565565

566566
let next = body_bx.inbounds_gep(current, &[self.const_usize(1)]);
567567
body_bx.br(header_bx.llbb());

src/librustc_codegen_llvm/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
349349
)};
350350
self.const_bitcast(llval, llty)
351351
};
352-
PlaceRef::new_sized(llval, layout, alloc.align)
352+
PlaceRef::new_sized(llval, layout)
353353
}
354354

355355
fn const_ptrcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value {

src/librustc_codegen_llvm/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
101101
let name = &*tcx.item_name(def_id).as_str();
102102

103103
let llret_ty = self.layout_of(ret_ty).llvm_type(self);
104-
let result = PlaceRef::new_sized(llresult, fn_ty.ret.layout, fn_ty.ret.layout.align.abi);
104+
let result = PlaceRef::new_sized(llresult, fn_ty.ret.layout);
105105

106106
let simple = get_simple_intrinsic(self, name);
107107
let llval = match name {

src/librustc_codegen_ssa/mir/block.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
988988

989989
// Handle both by-ref and immediate tuples.
990990
if let Ref(llval, None, align) = tuple.val {
991-
let tuple_ptr = PlaceRef::new_sized(llval, tuple.layout, align);
991+
let tuple_ptr = PlaceRef::new_sized_aligned(llval, tuple.layout, align);
992992
for i in 0..tuple.layout.fields.count() {
993993
let field_ptr = tuple_ptr.project_field(bx, i);
994994
let field = bx.load_operand(field_ptr);
@@ -1202,7 +1202,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
12021202
let llty = bx.backend_type(src.layout);
12031203
let cast_ptr = bx.pointercast(dst.llval, bx.type_ptr_to(llty));
12041204
let align = src.layout.align.abi.min(dst.align);
1205-
src.val.store(bx, PlaceRef::new_sized(cast_ptr, src.layout, align));
1205+
src.val.store(bx, PlaceRef::new_sized_aligned(cast_ptr, src.layout, align));
12061206
}
12071207

12081208

src/librustc_codegen_ssa/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
289289
if local == mir::RETURN_PLACE && fx.fn_ty.ret.is_indirect() {
290290
debug!("alloc: {:?} (return place) -> place", local);
291291
let llretptr = bx.get_param(0);
292-
LocalRef::Place(PlaceRef::new_sized(llretptr, layout, layout.align.abi))
292+
LocalRef::Place(PlaceRef::new_sized(llretptr, layout))
293293
} else if memory_locals.contains(local) {
294294
debug!("alloc: {:?} -> place", local);
295295
if layout.is_unsized() {
@@ -548,7 +548,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
548548
let llarg = bx.get_param(llarg_idx);
549549
bx.set_value_name(llarg, &name);
550550
llarg_idx += 1;
551-
PlaceRef::new_sized(llarg, arg.layout, arg.layout.align.abi)
551+
PlaceRef::new_sized(llarg, arg.layout)
552552
} else if arg.is_unsized_indirect() {
553553
// As the storage for the indirect argument lives during
554554
// the whole function call, we just copy the fat pointer.

src/librustc_codegen_ssa/mir/operand.rs

-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
485485
bx.load_operand(PlaceRef::new_sized(
486486
bx.cx().const_undef(bx.cx().type_ptr_to(bx.cx().backend_type(layout))),
487487
layout,
488-
layout.align.abi,
489488
))
490489
})
491490
}

src/librustc_codegen_ssa/mir/place.rs

+17-5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
3030
pub fn new_sized(
3131
llval: V,
3232
layout: TyLayout<'tcx>,
33+
) -> PlaceRef<'tcx, V> {
34+
assert!(!layout.is_unsized());
35+
PlaceRef {
36+
llval,
37+
llextra: None,
38+
layout,
39+
align: layout.align.abi
40+
}
41+
}
42+
43+
pub fn new_sized_aligned(
44+
llval: V,
45+
layout: TyLayout<'tcx>,
3346
align: Align,
3447
) -> PlaceRef<'tcx, V> {
3548
assert!(!layout.is_unsized());
@@ -45,14 +58,13 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
4558
bx: &mut Bx,
4659
llval: V,
4760
layout: TyLayout<'tcx>,
48-
align: Align,
4961
) -> PlaceRef<'tcx, V> {
5062
assert!(!bx.cx().type_has_metadata(layout.ty));
5163
PlaceRef {
5264
llval,
5365
llextra: None,
5466
layout,
55-
align
67+
align: layout.align.abi
5668
}
5769
}
5870

@@ -64,7 +76,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
6476
debug!("alloca({:?}: {:?})", name, layout);
6577
assert!(!layout.is_unsized(), "tried to statically allocate unsized place");
6678
let tmp = bx.alloca(bx.cx().backend_type(layout), name, layout.align.abi);
67-
Self::new_sized(tmp, layout, layout.align.abi)
79+
Self::new_sized(tmp, layout)
6880
}
6981

7082
/// Returns a place for an indirect reference to an unsized place.
@@ -482,7 +494,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
482494
let llval = bx.cx().const_undef(
483495
bx.cx().type_ptr_to(bx.cx().backend_type(layout))
484496
);
485-
PlaceRef::new_sized(llval, layout, layout.align.abi)
497+
PlaceRef::new_sized(llval, layout)
486498
}
487499
}
488500
}
@@ -498,7 +510,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
498510
// with a static that is an extern_type.
499511
let layout = cx.layout_of(self.monomorphize(&ty));
500512
let static_ = bx.get_static(*def_id);
501-
PlaceRef::new_thin_place(bx, static_, layout, layout.align.abi)
513+
PlaceRef::new_thin_place(bx, static_, layout)
502514
},
503515
mir::PlaceRef {
504516
base,

src/librustc_codegen_ssa/mir/rvalue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
7171
scratch.storage_dead(&mut bx);
7272
}
7373
OperandValue::Ref(llref, None, align) => {
74-
let source = PlaceRef::new_sized(llref, operand.layout, align);
74+
let source = PlaceRef::new_sized_aligned(llref, operand.layout, align);
7575
base::coerce_unsized_into(&mut bx, source, dest);
7676
}
7777
OperandValue::Ref(_, Some(_), _) => {

src/librustc_lexer/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ name = "rustc_lexer"
44
version = "0.1.0"
55
edition = "2018"
66

7-
# Note that this crate purposefully does not depend on other rustc crates
8-
[dependencies]
9-
unicode-xid = { version = "0.1.0", optional = true }
10-
117
# Note: do not remove this blank `[lib]` section.
128
# This will be used when publishing this crate as `rustc-ap-rustc_lexer`.
139
[lib]
1410
doctest = false
1511
name = "rustc_lexer"
12+
13+
# Note that this crate purposefully does not depend on other rustc crates
14+
[dependencies]
15+
unicode-xid = "0.2.0"

0 commit comments

Comments
 (0)