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 14 pull requests #81780

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a072ecb
Don't build remote-test-server with the stage0 toolchain
Jan 20, 2021
b5482a8
Preserve existing LD_LIBRARY_PATH in remote-test-server
Jan 20, 2021
a2f5c72
Fix has_body for trait methods
CraftSpider Jan 24, 2021
1c60d27
Remove leading newline
CraftSpider Jan 24, 2021
3106de5
Remove struct_type from union output and bump format
CraftSpider Jan 24, 2021
c34faad
rustdoc: Move `display_fn` struct inside `display_fn`
camelid Jan 29, 2021
5882cce
Expose correct symlink API on WASI
RReverser Jan 30, 2021
6e6608d
Add additional benchmarks to bit_set
JulianKnodt Feb 2, 2021
1578f2e
Keep old symlink; expose new symlink_path
RReverser Feb 3, 2021
f4b1bef
Restore comment as it was
RReverser Feb 3, 2021
82914a5
Add more information to the error code for 'crate not found'
jyn514 Feb 2, 2021
3b5d018
Handle `Span`s for byte and raw strings and add more detail
estebank Jan 23, 2021
50e394a
relax adt unsizing requirements
lcnr Jan 5, 2021
031cce8
add `relaxed_struct_unsize` feature gate
lcnr Feb 3, 2021
d06384a
make Allocator object-safe
RustyYato Feb 3, 2021
fdaf603
add generic args to hir::TypeBinding
b-naber Nov 30, 2020
16af7bf
hir pretty printing
b-naber Nov 30, 2020
760a665
lowering of generic args in AssocTyConstraint
b-naber Nov 30, 2020
da2cf9b
substitutions in trait predicates
b-naber Nov 30, 2020
6a68966
use generic arguments of associated item in trait_ref method
b-naber Nov 30, 2020
9e92015
remove subst_supertrait call
b-naber Nov 30, 2020
b080d1c
Cleanup rustdoc pass descriptions a bit
camelid Feb 4, 2021
12d411f
add tests
b-naber Nov 30, 2020
0c3a7d8
Update LayoutError/LayoutErr stability attributes
Feb 5, 2021
4253919
Indicate change in RSS from start to end of pass in time-passes output
tgnottingham Feb 5, 2021
9096865
Rollup merge of #79554 - b-naber:generic-associated-types-in-trait-pa…
m-ou-se Feb 5, 2021
e210a80
Rollup merge of #80726 - lcnr:unsize-query, r=oli-obk
m-ou-se Feb 5, 2021
e9fec38
Rollup merge of #81307 - estebank:invalid-byte-str-span, r=petrochenkov
m-ou-se Feb 5, 2021
d71f741
Rollup merge of #81318 - CraftSpider:json-trait-fix, r=jyn514
m-ou-se Feb 5, 2021
f0cd2e6
Rollup merge of #81456 - Amanieu:remote-test-server, r=Amanieu
m-ou-se Feb 5, 2021
0cc179f
Rollup merge of #81497 - camelid:rustdoc-display_fn-remove-cell, r=jy…
m-ou-se Feb 5, 2021
ea7274b
Rollup merge of #81500 - CraftSpider:union-kind, r=jyn514
m-ou-se Feb 5, 2021
a32b798
Rollup merge of #81542 - RReverser:wasi-symlink, r=alexcrichton
m-ou-se Feb 5, 2021
92b99a2
Rollup merge of #81676 - jyn514:crate-not-found, r=oli-obk
m-ou-se Feb 5, 2021
033bbea
Rollup merge of #81682 - JulianKnodt:bit_set_iter_benchmarks, r=oli-obk
m-ou-se Feb 5, 2021
becf861
Rollup merge of #81730 - RustyYato:object-safe-allocator, r=Amanieu
m-ou-se Feb 5, 2021
9f6f4ac
Rollup merge of #81763 - camelid:rustdoc-passes-desc-up, r=GuillaumeG…
m-ou-se Feb 5, 2021
539a386
Rollup merge of #81767 - exrook:layout-error-stability, r=Mark-Simula…
m-ou-se Feb 5, 2021
64f8920
Rollup merge of #81771 - tgnottingham:time-passes-rss-delta, r=oli-obk
m-ou-se Feb 5, 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
39 changes: 32 additions & 7 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,16 +1076,40 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
fn lower_assoc_ty_constraint(
&mut self,
constraint: &AssocTyConstraint,
itctx: ImplTraitContext<'_, 'hir>,
mut itctx: ImplTraitContext<'_, 'hir>,
) -> hir::TypeBinding<'hir> {
debug!("lower_assoc_ty_constraint(constraint={:?}, itctx={:?})", constraint, itctx);

if let Some(ref gen_args) = constraint.gen_args {
self.sess.span_fatal(
gen_args.span(),
"generic associated types in trait paths are currently not implemented",
);
}
// lower generic arguments of identifier in constraint
let gen_args = if let Some(ref gen_args) = constraint.gen_args {
let gen_args_ctor = match gen_args {
GenericArgs::AngleBracketed(ref data) => {
self.lower_angle_bracketed_parameter_data(
data,
ParamMode::Explicit,
itctx.reborrow(),
)
.0
}
GenericArgs::Parenthesized(ref data) => {
let mut err = self.sess.struct_span_err(
gen_args.span(),
"parenthesized generic arguments cannot be used in associated type constraints"
);
// FIXME: try to write a suggestion here
err.emit();
self.lower_angle_bracketed_parameter_data(
&data.as_angle_bracketed_args(),
ParamMode::Explicit,
itctx.reborrow(),
)
.0
}
};
self.arena.alloc(gen_args_ctor.into_generic_args(&self.arena))
} else {
self.arena.alloc(hir::GenericArgs::none())
};

let kind = match constraint.kind {
AssocTyConstraintKind::Equality { ref ty } => {
Expand Down Expand Up @@ -1182,6 +1206,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
hir::TypeBinding {
hir_id: self.lower_node_id(constraint.id),
ident: constraint.ident,
gen_args,
kind,
span: constraint.span,
}
Expand Down
7 changes: 5 additions & 2 deletions compiler/rustc_ast_lowering/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}

fn lower_angle_bracketed_parameter_data(
pub(crate) fn lower_angle_bracketed_parameter_data(
&mut self,
data: &AngleBracketedArgs,
param_mode: ParamMode,
Expand Down Expand Up @@ -426,6 +426,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
) -> hir::TypeBinding<'hir> {
let ident = Ident::with_dummy_span(hir::FN_OUTPUT_NAME);
let kind = hir::TypeBindingKind::Equality { ty };
hir::TypeBinding { hir_id: self.next_id(), span, ident, kind }
let args = arena_vec![self;];
let bindings = arena_vec![self;];
let gen_args = self.arena.alloc(hir::GenericArgs { args, bindings, parenthesized: false });
hir::TypeBinding { hir_id: self.next_id(), gen_args, span, ident, kind }
}
}
25 changes: 11 additions & 14 deletions compiler/rustc_data_structures/src/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,24 +590,21 @@ pub fn print_time_passes_entry(
end_rss: Option<usize>,
) {
let rss_to_mb = |rss| (rss as f64 / 1_000_000.0).round() as usize;
let rss_change_to_mb = |rss| (rss as f64 / 1_000_000.0).round() as i128;

let mem_string = match (start_rss, end_rss) {
(Some(start_rss), Some(end_rss)) => {
// It's tempting to add the change in RSS from start to end, but its somewhat confusing
// and misleading when looking at time-passes output. Consider two adjacent entries:
//
// time: 10.000; rss start: 1000MB, end: 1000MB, change: 0MB pass1
// time: 5.000; rss start: 2000MB, end: 2000MB, change: 0MB pass2
//
// If you're looking for jumps in RSS based on the change column, you miss the fact
// that a 1GB jump happened between pass1 and pass2 (supposing pass1 and pass2 actually
// occur sequentially and pass1 isn't just nested within pass2). It's easy to imagine
// someone missing this or being confused by the fact that the change is zero.

format!("; rss: {:>5}MB -> {:>5}MB", rss_to_mb(start_rss), rss_to_mb(end_rss))
let change_rss = end_rss as i128 - start_rss as i128;

format!(
"; rss: {:>4}MB -> {:>4}MB ({:>+5}MB)",
rss_to_mb(start_rss),
rss_to_mb(end_rss),
rss_change_to_mb(change_rss),
)
}
(Some(start_rss), None) => format!("; rss start: {:>5}MB", rss_to_mb(start_rss)),
(None, Some(end_rss)) => format!("; rss end: {:5>}MB", rss_to_mb(end_rss)),
(Some(start_rss), None) => format!("; rss start: {:>4}MB", rss_to_mb(start_rss)),
(None, Some(end_rss)) => format!("; rss end: {:>4}MB", rss_to_mb(end_rss)),
(None, None) => String::new(),
};

Expand Down
21 changes: 21 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0463.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,24 @@ extern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie`
You need to link your code to the relevant crate in order to be able to use it
(through Cargo or the `-L` option of rustc example). Plugins are crates as
well, and you link to them the same way.

## Common causes

- The crate is not present at all. If using Cargo, add it to `[dependencies]`
in Cargo.toml.
- The crate is present, but under a different name. If using Cargo, look for
`package = ` under `[dependencies]` in Cargo.toml.

## Common causes for missing `std` or `core`

- You are cross-compiling for a target which doesn't have `std` prepackaged.
Consider one of the following:
+ Adding a pre-compiled version of std with `rustup target add`
+ Building std from source with `cargo build -Z build-std`
+ Using `#![no_std]` at the crate root, so you won't need `std` in the first
place.
- You are developing the compiler itself and haven't built libstd from source.
You can usually build it with `x.py build library/std`. More information
about x.py is available in the [rustc-dev-guide].

[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#building-the-compiler
3 changes: 3 additions & 0 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,9 @@ declare_features! (

/// Allows `extern "C-cmse-nonsecure-call" fn()`.
(active, abi_c_cmse_nonsecure_call, "1.51.0", Some(81391), None),

/// Lessens the requirements for structs to implement `Unsize`.
(active, relaxed_struct_unsize, "1.51.0", Some(1), None),
// -------------------------------------------------------------------------
// feature-group-end: actual feature gates
// -------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,7 @@ pub struct TypeBinding<'hir> {
pub hir_id: HirId,
#[stable_hasher(project(name))]
pub ident: Ident,
pub gen_args: &'hir GenericArgs<'hir>,
pub kind: TypeBindingKind<'hir>,
pub span: Span,
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir/src/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(
) {
visitor.visit_id(type_binding.hir_id);
visitor.visit_ident(type_binding.ident);
visitor.visit_generic_args(type_binding.span, type_binding.gen_args);
match type_binding.kind {
TypeBindingKind::Equality { ref ty } => {
visitor.visit_ty(ty);
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1840,6 +1840,7 @@ impl<'a> State<'a> {
for binding in generic_args.bindings.iter() {
start_or_comma(self);
self.print_ident(binding.ident);
self.print_generic_args(binding.gen_args, false, false);
self.s.space();
match generic_args.bindings[0].kind {
hir::TypeBindingKind::Equality { ref ty } => {
Expand Down
12 changes: 12 additions & 0 deletions compiler/rustc_index/src/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,18 @@ impl<T: Idx> GrowableBitSet<T> {
self.bit_set.insert(elem)
}

/// Returns `true` if the set has changed.
#[inline]
pub fn remove(&mut self, elem: T) -> bool {
self.ensure(elem.index() + 1);
self.bit_set.remove(elem)
}

#[inline]
pub fn is_empty(&self) -> bool {
self.bit_set.is_empty()
}

#[inline]
pub fn contains(&self, elem: T) -> bool {
let (word_index, mask) = word_index_and_mask(elem);
Expand Down
34 changes: 34 additions & 0 deletions compiler/rustc_index/src/bit_set/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::*;

extern crate test;
use std::hint::black_box;
use test::Bencher;

#[test]
Expand Down Expand Up @@ -364,3 +365,36 @@ fn union_hybrid_sparse_full_small_domain(b: &mut Bencher) {
sparse.union(&dense);
})
}

#[bench]
fn bench_insert(b: &mut Bencher) {
let mut bs = BitSet::new_filled(99999usize);
b.iter(|| {
black_box(bs.insert(black_box(100u32)));
});
}

#[bench]
fn bench_remove(b: &mut Bencher) {
let mut bs = BitSet::new_filled(99999usize);
b.iter(|| {
black_box(bs.remove(black_box(100u32)));
});
}

#[bench]
fn bench_iter(b: &mut Bencher) {
let bs = BitSet::new_filled(99999usize);
b.iter(|| {
bs.iter().map(|b: usize| black_box(b)).for_each(drop);
});
}

#[bench]
fn bench_intersect(b: &mut Bencher) {
let mut ba: BitSet<u32> = BitSet::new_filled(99999usize);
let bb = BitSet::new_filled(99999usize);
b.iter(|| {
ba.intersect(black_box(&bb));
});
}
10 changes: 9 additions & 1 deletion compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,8 +1132,16 @@ impl<'tcx> ProjectionTy<'tcx> {
/// For example, if this is a projection of `<T as Iterator>::Item`,
/// then this function would return a `T: Iterator` trait reference.
pub fn trait_ref(&self, tcx: TyCtxt<'tcx>) -> ty::TraitRef<'tcx> {
// FIXME: This method probably shouldn't exist at all, since it's not
// clear what this method really intends to do. Be careful when
// using this method since the resulting TraitRef additionally
// contains the substs for the assoc_item, which strictly speaking
// is not correct
let def_id = tcx.associated_item(self.item_def_id).container.id();
ty::TraitRef { def_id, substs: self.substs.truncate_to(tcx, tcx.generics_of(def_id)) }
// Include substitutions for generic arguments of associated types
let assoc_item = tcx.associated_item(self.item_def_id);
let substs_assoc_item = self.substs.truncate_to(tcx, tcx.generics_of(assoc_item.def_id));
ty::TraitRef { def_id, substs: substs_assoc_item }
}

pub fn self_ty(&self) -> Ty<'tcx> {
Expand Down
30 changes: 20 additions & 10 deletions compiler/rustc_parse/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mod tokentrees;
mod unescape_error_reporting;
mod unicode_chars;

use unescape_error_reporting::{emit_unescape_error, push_escaped_char};
use unescape_error_reporting::{emit_unescape_error, escaped_char};

#[derive(Clone, Debug)]
pub struct UnmatchedBrace {
Expand Down Expand Up @@ -122,11 +122,9 @@ impl<'a> StringReader<'a> {
m: &str,
c: char,
) -> DiagnosticBuilder<'a> {
let mut m = m.to_string();
m.push_str(": ");
push_escaped_char(&mut m, c);

self.sess.span_diagnostic.struct_span_fatal(self.mk_sp(from_pos, to_pos), &m[..])
self.sess
.span_diagnostic
.struct_span_fatal(self.mk_sp(from_pos, to_pos), &format!("{}: {}", m, escaped_char(c)))
}

/// Turns simple `rustc_lexer::TokenKind` enum into a rich
Expand Down Expand Up @@ -421,7 +419,7 @@ impl<'a> StringReader<'a> {
let content_start = start + BytePos(prefix_len);
let content_end = suffix_start - BytePos(postfix_len);
let id = self.symbol_from_to(content_start, content_end);
self.validate_literal_escape(mode, content_start, content_end);
self.validate_literal_escape(mode, content_start, content_end, prefix_len, postfix_len);
(lit_kind, id)
}

Expand Down Expand Up @@ -525,17 +523,29 @@ impl<'a> StringReader<'a> {
.raise();
}

fn validate_literal_escape(&self, mode: Mode, content_start: BytePos, content_end: BytePos) {
fn validate_literal_escape(
&self,
mode: Mode,
content_start: BytePos,
content_end: BytePos,
prefix_len: u32,
postfix_len: u32,
) {
let lit_content = self.str_from_to(content_start, content_end);
unescape::unescape_literal(lit_content, mode, &mut |range, result| {
// Here we only check for errors. The actual unescaping is done later.
if let Err(err) = result {
let span_with_quotes =
self.mk_sp(content_start - BytePos(1), content_end + BytePos(1));
let span_with_quotes = self
.mk_sp(content_start - BytePos(prefix_len), content_end + BytePos(postfix_len));
let (start, end) = (range.start as u32, range.end as u32);
let lo = content_start + BytePos(start);
let hi = lo + BytePos(end - start);
let span = self.mk_sp(lo, hi);
emit_unescape_error(
&self.sess.span_diagnostic,
lit_content,
span_with_quotes,
span,
mode,
range,
err,
Expand Down
Loading