Skip to content

Commit f9435f4

Browse files
committed
Auto merge of rust-lang#81784 - m-ou-se:rollup-s23fow7, r=m-ou-se
Rollup of 15 pull requests Successful merges: - rust-lang#79554 (Generic associated types in trait paths) - rust-lang#80726 (relax adt unsizing requirements) - rust-lang#81307 (Handle `Span`s for byte and raw strings and add more detail ) - rust-lang#81318 (rustdoc-json: Fix has_body) - rust-lang#81456 (Make remote-test-server easier to use with new targets) - rust-lang#81497 (rustdoc: Move `display_fn` struct inside `display_fn`) - rust-lang#81500 (Remove struct_type from union output) - rust-lang#81542 (Expose correct symlink API on WASI) - rust-lang#81676 (Add more information to the error code for 'crate not found') - rust-lang#81682 (Add additional bitset benchmarks) - rust-lang#81730 (Make `Allocator` object-safe) - rust-lang#81763 (Cleanup rustdoc pass descriptions a bit) - rust-lang#81767 (Update LayoutError/LayoutErr stability attributes) - rust-lang#81771 (Indicate change in RSS from start to end of pass in time-passes output) - rust-lang#81781 (Fix `install-awscli.sh` error in CI) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 730d6df + 2383cd4 commit f9435f4

File tree

106 files changed

+1599
-385
lines changed

Some content is hidden

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

106 files changed

+1599
-385
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+32-7
Original file line numberDiff line numberDiff line change
@@ -1076,16 +1076,40 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10761076
fn lower_assoc_ty_constraint(
10771077
&mut self,
10781078
constraint: &AssocTyConstraint,
1079-
itctx: ImplTraitContext<'_, 'hir>,
1079+
mut itctx: ImplTraitContext<'_, 'hir>,
10801080
) -> hir::TypeBinding<'hir> {
10811081
debug!("lower_assoc_ty_constraint(constraint={:?}, itctx={:?})", constraint, itctx);
10821082

1083-
if let Some(ref gen_args) = constraint.gen_args {
1084-
self.sess.span_fatal(
1085-
gen_args.span(),
1086-
"generic associated types in trait paths are currently not implemented",
1087-
);
1088-
}
1083+
// lower generic arguments of identifier in constraint
1084+
let gen_args = if let Some(ref gen_args) = constraint.gen_args {
1085+
let gen_args_ctor = match gen_args {
1086+
GenericArgs::AngleBracketed(ref data) => {
1087+
self.lower_angle_bracketed_parameter_data(
1088+
data,
1089+
ParamMode::Explicit,
1090+
itctx.reborrow(),
1091+
)
1092+
.0
1093+
}
1094+
GenericArgs::Parenthesized(ref data) => {
1095+
let mut err = self.sess.struct_span_err(
1096+
gen_args.span(),
1097+
"parenthesized generic arguments cannot be used in associated type constraints"
1098+
);
1099+
// FIXME: try to write a suggestion here
1100+
err.emit();
1101+
self.lower_angle_bracketed_parameter_data(
1102+
&data.as_angle_bracketed_args(),
1103+
ParamMode::Explicit,
1104+
itctx.reborrow(),
1105+
)
1106+
.0
1107+
}
1108+
};
1109+
self.arena.alloc(gen_args_ctor.into_generic_args(&self.arena))
1110+
} else {
1111+
self.arena.alloc(hir::GenericArgs::none())
1112+
};
10891113

10901114
let kind = match constraint.kind {
10911115
AssocTyConstraintKind::Equality { ref ty } => {
@@ -1182,6 +1206,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11821206
hir::TypeBinding {
11831207
hir_id: self.lower_node_id(constraint.id),
11841208
ident: constraint.ident,
1209+
gen_args,
11851210
kind,
11861211
span: constraint.span,
11871212
}

compiler/rustc_ast_lowering/src/path.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
362362
}
363363
}
364364

365-
fn lower_angle_bracketed_parameter_data(
365+
pub(crate) fn lower_angle_bracketed_parameter_data(
366366
&mut self,
367367
data: &AngleBracketedArgs,
368368
param_mode: ParamMode,
@@ -426,6 +426,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
426426
) -> hir::TypeBinding<'hir> {
427427
let ident = Ident::with_dummy_span(hir::FN_OUTPUT_NAME);
428428
let kind = hir::TypeBindingKind::Equality { ty };
429-
hir::TypeBinding { hir_id: self.next_id(), span, ident, kind }
429+
let args = arena_vec![self;];
430+
let bindings = arena_vec![self;];
431+
let gen_args = self.arena.alloc(hir::GenericArgs { args, bindings, parenthesized: false });
432+
hir::TypeBinding { hir_id: self.next_id(), gen_args, span, ident, kind }
430433
}
431434
}

compiler/rustc_data_structures/src/profiling.rs

+11-14
Original file line numberDiff line numberDiff line change
@@ -590,24 +590,21 @@ pub fn print_time_passes_entry(
590590
end_rss: Option<usize>,
591591
) {
592592
let rss_to_mb = |rss| (rss as f64 / 1_000_000.0).round() as usize;
593+
let rss_change_to_mb = |rss| (rss as f64 / 1_000_000.0).round() as i128;
593594

594595
let mem_string = match (start_rss, end_rss) {
595596
(Some(start_rss), Some(end_rss)) => {
596-
// It's tempting to add the change in RSS from start to end, but its somewhat confusing
597-
// and misleading when looking at time-passes output. Consider two adjacent entries:
598-
//
599-
// time: 10.000; rss start: 1000MB, end: 1000MB, change: 0MB pass1
600-
// time: 5.000; rss start: 2000MB, end: 2000MB, change: 0MB pass2
601-
//
602-
// If you're looking for jumps in RSS based on the change column, you miss the fact
603-
// that a 1GB jump happened between pass1 and pass2 (supposing pass1 and pass2 actually
604-
// occur sequentially and pass1 isn't just nested within pass2). It's easy to imagine
605-
// someone missing this or being confused by the fact that the change is zero.
606-
607-
format!("; rss: {:>5}MB -> {:>5}MB", rss_to_mb(start_rss), rss_to_mb(end_rss))
597+
let change_rss = end_rss as i128 - start_rss as i128;
598+
599+
format!(
600+
"; rss: {:>4}MB -> {:>4}MB ({:>+5}MB)",
601+
rss_to_mb(start_rss),
602+
rss_to_mb(end_rss),
603+
rss_change_to_mb(change_rss),
604+
)
608605
}
609-
(Some(start_rss), None) => format!("; rss start: {:>5}MB", rss_to_mb(start_rss)),
610-
(None, Some(end_rss)) => format!("; rss end: {:5>}MB", rss_to_mb(end_rss)),
606+
(Some(start_rss), None) => format!("; rss start: {:>4}MB", rss_to_mb(start_rss)),
607+
(None, Some(end_rss)) => format!("; rss end: {:>4}MB", rss_to_mb(end_rss)),
611608
(None, None) => String::new(),
612609
};
613610

compiler/rustc_error_codes/src/error_codes/E0463.md

+21
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,24 @@ extern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie`
1111
You need to link your code to the relevant crate in order to be able to use it
1212
(through Cargo or the `-L` option of rustc example). Plugins are crates as
1313
well, and you link to them the same way.
14+
15+
## Common causes
16+
17+
- The crate is not present at all. If using Cargo, add it to `[dependencies]`
18+
in Cargo.toml.
19+
- The crate is present, but under a different name. If using Cargo, look for
20+
`package = ` under `[dependencies]` in Cargo.toml.
21+
22+
## Common causes for missing `std` or `core`
23+
24+
- You are cross-compiling for a target which doesn't have `std` prepackaged.
25+
Consider one of the following:
26+
+ Adding a pre-compiled version of std with `rustup target add`
27+
+ Building std from source with `cargo build -Z build-std`
28+
+ Using `#![no_std]` at the crate root, so you won't need `std` in the first
29+
place.
30+
- You are developing the compiler itself and haven't built libstd from source.
31+
You can usually build it with `x.py build library/std`. More information
32+
about x.py is available in the [rustc-dev-guide].
33+
34+
[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#building-the-compiler

compiler/rustc_feature/src/active.rs

+3
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,9 @@ declare_features! (
631631

632632
/// Allows `extern "C-cmse-nonsecure-call" fn()`.
633633
(active, abi_c_cmse_nonsecure_call, "1.51.0", Some(81391), None),
634+
635+
/// Lessens the requirements for structs to implement `Unsize`.
636+
(active, relaxed_struct_unsize, "1.51.0", Some(1), None),
634637
// -------------------------------------------------------------------------
635638
// feature-group-end: actual feature gates
636639
// -------------------------------------------------------------------------

compiler/rustc_hir/src/hir.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2015,6 +2015,7 @@ pub struct TypeBinding<'hir> {
20152015
pub hir_id: HirId,
20162016
#[stable_hasher(project(name))]
20172017
pub ident: Ident,
2018+
pub gen_args: &'hir GenericArgs<'hir>,
20182019
pub kind: TypeBindingKind<'hir>,
20192020
pub span: Span,
20202021
}

compiler/rustc_hir/src/intravisit.rs

+1
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(
781781
) {
782782
visitor.visit_id(type_binding.hir_id);
783783
visitor.visit_ident(type_binding.ident);
784+
visitor.visit_generic_args(type_binding.span, type_binding.gen_args);
784785
match type_binding.kind {
785786
TypeBindingKind::Equality { ref ty } => {
786787
visitor.visit_ty(ty);

compiler/rustc_hir_pretty/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,7 @@ impl<'a> State<'a> {
18401840
for binding in generic_args.bindings.iter() {
18411841
start_or_comma(self);
18421842
self.print_ident(binding.ident);
1843+
self.print_generic_args(binding.gen_args, false, false);
18431844
self.s.space();
18441845
match generic_args.bindings[0].kind {
18451846
hir::TypeBindingKind::Equality { ref ty } => {

compiler/rustc_index/src/bit_set.rs

+12
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,18 @@ impl<T: Idx> GrowableBitSet<T> {
707707
self.bit_set.insert(elem)
708708
}
709709

710+
/// Returns `true` if the set has changed.
711+
#[inline]
712+
pub fn remove(&mut self, elem: T) -> bool {
713+
self.ensure(elem.index() + 1);
714+
self.bit_set.remove(elem)
715+
}
716+
717+
#[inline]
718+
pub fn is_empty(&self) -> bool {
719+
self.bit_set.is_empty()
720+
}
721+
710722
#[inline]
711723
pub fn contains(&self, elem: T) -> bool {
712724
let (word_index, mask) = word_index_and_mask(elem);

compiler/rustc_index/src/bit_set/tests.rs

+34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::*;
22

33
extern crate test;
4+
use std::hint::black_box;
45
use test::Bencher;
56

67
#[test]
@@ -364,3 +365,36 @@ fn union_hybrid_sparse_full_small_domain(b: &mut Bencher) {
364365
sparse.union(&dense);
365366
})
366367
}
368+
369+
#[bench]
370+
fn bench_insert(b: &mut Bencher) {
371+
let mut bs = BitSet::new_filled(99999usize);
372+
b.iter(|| {
373+
black_box(bs.insert(black_box(100u32)));
374+
});
375+
}
376+
377+
#[bench]
378+
fn bench_remove(b: &mut Bencher) {
379+
let mut bs = BitSet::new_filled(99999usize);
380+
b.iter(|| {
381+
black_box(bs.remove(black_box(100u32)));
382+
});
383+
}
384+
385+
#[bench]
386+
fn bench_iter(b: &mut Bencher) {
387+
let bs = BitSet::new_filled(99999usize);
388+
b.iter(|| {
389+
bs.iter().map(|b: usize| black_box(b)).for_each(drop);
390+
});
391+
}
392+
393+
#[bench]
394+
fn bench_intersect(b: &mut Bencher) {
395+
let mut ba: BitSet<u32> = BitSet::new_filled(99999usize);
396+
let bb = BitSet::new_filled(99999usize);
397+
b.iter(|| {
398+
ba.intersect(black_box(&bb));
399+
});
400+
}

compiler/rustc_middle/src/ty/sty.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1132,8 +1132,16 @@ impl<'tcx> ProjectionTy<'tcx> {
11321132
/// For example, if this is a projection of `<T as Iterator>::Item`,
11331133
/// then this function would return a `T: Iterator` trait reference.
11341134
pub fn trait_ref(&self, tcx: TyCtxt<'tcx>) -> ty::TraitRef<'tcx> {
1135+
// FIXME: This method probably shouldn't exist at all, since it's not
1136+
// clear what this method really intends to do. Be careful when
1137+
// using this method since the resulting TraitRef additionally
1138+
// contains the substs for the assoc_item, which strictly speaking
1139+
// is not correct
11351140
let def_id = tcx.associated_item(self.item_def_id).container.id();
1136-
ty::TraitRef { def_id, substs: self.substs.truncate_to(tcx, tcx.generics_of(def_id)) }
1141+
// Include substitutions for generic arguments of associated types
1142+
let assoc_item = tcx.associated_item(self.item_def_id);
1143+
let substs_assoc_item = self.substs.truncate_to(tcx, tcx.generics_of(assoc_item.def_id));
1144+
ty::TraitRef { def_id, substs: substs_assoc_item }
11371145
}
11381146

11391147
pub fn self_ty(&self) -> Ty<'tcx> {

compiler/rustc_parse/src/lexer/mod.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mod tokentrees;
1414
mod unescape_error_reporting;
1515
mod unicode_chars;
1616

17-
use unescape_error_reporting::{emit_unescape_error, push_escaped_char};
17+
use unescape_error_reporting::{emit_unescape_error, escaped_char};
1818

1919
#[derive(Clone, Debug)]
2020
pub struct UnmatchedBrace {
@@ -122,11 +122,9 @@ impl<'a> StringReader<'a> {
122122
m: &str,
123123
c: char,
124124
) -> DiagnosticBuilder<'a> {
125-
let mut m = m.to_string();
126-
m.push_str(": ");
127-
push_escaped_char(&mut m, c);
128-
129-
self.sess.span_diagnostic.struct_span_fatal(self.mk_sp(from_pos, to_pos), &m[..])
125+
self.sess
126+
.span_diagnostic
127+
.struct_span_fatal(self.mk_sp(from_pos, to_pos), &format!("{}: {}", m, escaped_char(c)))
130128
}
131129

132130
/// Turns simple `rustc_lexer::TokenKind` enum into a rich
@@ -421,7 +419,7 @@ impl<'a> StringReader<'a> {
421419
let content_start = start + BytePos(prefix_len);
422420
let content_end = suffix_start - BytePos(postfix_len);
423421
let id = self.symbol_from_to(content_start, content_end);
424-
self.validate_literal_escape(mode, content_start, content_end);
422+
self.validate_literal_escape(mode, content_start, content_end, prefix_len, postfix_len);
425423
(lit_kind, id)
426424
}
427425

@@ -525,17 +523,29 @@ impl<'a> StringReader<'a> {
525523
.raise();
526524
}
527525

528-
fn validate_literal_escape(&self, mode: Mode, content_start: BytePos, content_end: BytePos) {
526+
fn validate_literal_escape(
527+
&self,
528+
mode: Mode,
529+
content_start: BytePos,
530+
content_end: BytePos,
531+
prefix_len: u32,
532+
postfix_len: u32,
533+
) {
529534
let lit_content = self.str_from_to(content_start, content_end);
530535
unescape::unescape_literal(lit_content, mode, &mut |range, result| {
531536
// Here we only check for errors. The actual unescaping is done later.
532537
if let Err(err) = result {
533-
let span_with_quotes =
534-
self.mk_sp(content_start - BytePos(1), content_end + BytePos(1));
538+
let span_with_quotes = self
539+
.mk_sp(content_start - BytePos(prefix_len), content_end + BytePos(postfix_len));
540+
let (start, end) = (range.start as u32, range.end as u32);
541+
let lo = content_start + BytePos(start);
542+
let hi = lo + BytePos(end - start);
543+
let span = self.mk_sp(lo, hi);
535544
emit_unescape_error(
536545
&self.sess.span_diagnostic,
537546
lit_content,
538547
span_with_quotes,
548+
span,
539549
mode,
540550
range,
541551
err,

0 commit comments

Comments
 (0)