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 13 pull requests #73876

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0c88dd6
Update Box::from_raw example to generalize better
Keno Jun 24, 2020
2bbc2b3
Document the static keyword
poliorcetics Jun 25, 2020
00ef461
Merge pull request #2 from rust-lang/master
TyPR124 Jun 26, 2020
b71a3e1
Map ERROR_INVALID_PARAMETER to InvalidInput
TyPR124 Jun 26, 2020
79a42e3
linker: Create GNU_EH_FRAME header by default when producing ELFs
petrochenkov Jun 20, 2020
0d0865f
Make `rustc_peek` a safe intrinsic
oli-obk Jun 27, 2020
765bd47
Recover extra trailing angle brackets in struct definition
Aaron1011 Jun 27, 2020
3fc5593
Document the type keyword
poliorcetics Jun 27, 2020
517d361
Use an 'approximate' universal upper bound when reporting region errors
Aaron1011 Jun 27, 2020
7055c23
ast_pretty: Pass some token streams and trees by reference
petrochenkov Jun 24, 2020
c321c06
stop taking references in Relate
lcnr Jun 24, 2020
a9ece00
change `skip_binder` to use T by value
lcnr Jun 24, 2020
acd4818
remove unused `TypeError::ProjectionBoundsLength`
lcnr Jun 24, 2020
14d0370
Remove defunct `-Z print-region-graph`
tmiasko Jun 28, 2020
7231e57
Fix wording for anonymous parameter name help
nop Jun 28, 2020
e611a3f
Apply suggestions from code review
poliorcetics Jun 28, 2020
e8f5785
Split and expand nonstandard-style lints unicode unit test.
crlf0710 Jun 28, 2020
dfd454b
Apply suggestions, reformulating some paragraphs and improving some e…
poliorcetics Jun 28, 2020
824b2bb
Match on `Symbol` instead of `&str` for type-checking intrinsics.
oli-obk Jun 28, 2020
4224313
Fix small nits
poliorcetics Jun 28, 2020
24bdb3d
Rollup merge of #73564 - petrochenkov:ehdr, r=Amanieu
Manishearth Jun 29, 2020
63621db
Rollup merge of #73678 - Keno:patch-1, r=LukasKalbertodt
Manishearth Jun 29, 2020
39cf207
Rollup merge of #73705 - lcnr:skip_binder, r=nikomatsakis
Manishearth Jun 29, 2020
c3cdcd2
Rollup merge of #73716 - poliorcetics:static-keyword, r=LukasKalbertodt
Manishearth Jun 29, 2020
d011911
Rollup merge of #73752 - TyPR124:invalid-parameter-error, r=LukasKalb…
Manishearth Jun 29, 2020
6ad5e42
Rollup merge of #73803 - Aaron1011:feature/angle-field-recovery, r=ma…
Manishearth Jun 29, 2020
bafef77
Rollup merge of #73805 - poliorcetics:type-keyword, r=kennytm
Manishearth Jun 29, 2020
00ccc67
Rollup merge of #73806 - Aaron1011:feature/approx-universal-upper, r=…
Manishearth Jun 29, 2020
33e8c5b
Rollup merge of #73812 - petrochenkov:prettyref, r=varkor
Manishearth Jun 29, 2020
7e34995
Rollup merge of #73828 - nop:fix/parameter-name-help, r=estebank
Manishearth Jun 29, 2020
27f0c97
Rollup merge of #73834 - oli-obk:safe_intrinsics, r=ecstatic-morse
Manishearth Jun 29, 2020
87bf66f
Rollup merge of #73839 - crlf0710:snapshot_the_reality, r=Manishearth
Manishearth Jun 29, 2020
89bc5a4
Rollup merge of #73841 - tmiasko:print-region-graph, r=Mark-Simulacrum
Manishearth Jun 29, 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
5 changes: 4 additions & 1 deletion src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,10 @@ impl<T: ?Sized> Box<T> {
///
/// unsafe {
/// let ptr = alloc(Layout::new::<i32>()) as *mut i32;
/// *ptr = 5;
/// // In general .write is required to avoid attempting to destruct
/// // the (uninitialized) previous contents of `ptr`, though for this
/// // simple example `*ptr = 5` would have worked as well.
/// ptr.write(5);
/// let x = Box::from_raw(ptr);
/// }
/// ```
Expand Down
38 changes: 19 additions & 19 deletions src/librustc_ast_pretty/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_ast::attr;
use rustc_ast::ptr::P;
use rustc_ast::token::{self, BinOpToken, DelimToken, Nonterminal, Token, TokenKind};
use rustc_ast::tokenstream::{self, TokenStream, TokenTree};
use rustc_ast::tokenstream::{TokenStream, TokenTree};
use rustc_ast::util::parser::{self, AssocOp, Fixity};
use rustc_ast::util::{classify, comments};
use rustc_span::edition::Edition;
Expand Down Expand Up @@ -293,7 +293,7 @@ pub fn nonterminal_to_string(nt: &Nonterminal) -> String {
token::NtIdent(e, is_raw) => IdentPrinter::for_ast_ident(e, is_raw).to_string(),
token::NtLifetime(e) => e.to_string(),
token::NtLiteral(ref e) => expr_to_string(e),
token::NtTT(ref tree) => tt_to_string(tree.clone()),
token::NtTT(ref tree) => tt_to_string(tree),
token::NtVis(ref e) => vis_to_string(e),
}
}
Expand All @@ -314,11 +314,11 @@ pub fn expr_to_string(e: &ast::Expr) -> String {
to_string(|s| s.print_expr(e))
}

pub fn tt_to_string(tt: tokenstream::TokenTree) -> String {
pub fn tt_to_string(tt: &TokenTree) -> String {
to_string(|s| s.print_tt(tt, false))
}

pub fn tts_to_string(tokens: TokenStream) -> String {
pub fn tts_to_string(tokens: &TokenStream) -> String {
to_string(|s| s.print_tts(tokens, false))
}

Expand Down Expand Up @@ -585,7 +585,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
false,
None,
delim.to_token(),
tokens.clone(),
tokens,
true,
span,
),
Expand All @@ -594,7 +594,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
if let MacArgs::Eq(_, tokens) = &item.args {
self.space();
self.word_space("=");
self.print_tts(tokens.clone(), true);
self.print_tts(tokens, true);
}
}
}
Expand Down Expand Up @@ -635,9 +635,9 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
/// appropriate macro, transcribe back into the grammar we just parsed from,
/// and then pretty-print the resulting AST nodes (so, e.g., we print
/// expression arguments as expressions). It can be done! I think.
fn print_tt(&mut self, tt: tokenstream::TokenTree, convert_dollar_crate: bool) {
fn print_tt(&mut self, tt: &TokenTree, convert_dollar_crate: bool) {
match tt {
TokenTree::Token(ref token) => {
TokenTree::Token(token) => {
self.word(token_to_string_ext(&token, convert_dollar_crate));
if let token::DocComment(..) = token.kind {
self.hardbreak()
Expand All @@ -648,7 +648,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
None,
false,
None,
delim,
*delim,
tts,
convert_dollar_crate,
dspan.entire(),
Expand All @@ -657,14 +657,14 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
}
}

fn print_tts(&mut self, tts: tokenstream::TokenStream, convert_dollar_crate: bool) {
let mut iter = tts.into_trees().peekable();
fn print_tts(&mut self, tts: &TokenStream, convert_dollar_crate: bool) {
let mut iter = tts.trees().peekable();
while let Some(tt) = iter.next() {
let show_space =
if let Some(next) = iter.peek() { tt_prepend_space(next, &tt) } else { false };
self.print_tt(tt, convert_dollar_crate);
if show_space {
self.space();
self.print_tt(&tt, convert_dollar_crate);
if let Some(next) = iter.peek() {
if tt_prepend_space(next, &tt) {
self.space();
}
}
}
}
Expand All @@ -675,7 +675,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
has_bang: bool,
ident: Option<Ident>,
delim: DelimToken,
tts: TokenStream,
tts: &TokenStream,
convert_dollar_crate: bool,
span: Span,
) {
Expand Down Expand Up @@ -1253,7 +1253,7 @@ impl<'a> State<'a> {
has_bang,
Some(item.ident),
macro_def.body.delim(),
macro_def.body.inner_tokens(),
&macro_def.body.inner_tokens(),
true,
item.span,
);
Expand Down Expand Up @@ -1577,7 +1577,7 @@ impl<'a> State<'a> {
true,
None,
m.args.delim(),
m.args.inner_tokens(),
&m.args.inner_tokens(),
true,
m.span(),
);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_builtin_macros/log_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub fn expand_log_syntax<'cx>(
sp: rustc_span::Span,
tts: TokenStream,
) -> Box<dyn base::MacResult + 'cx> {
println!("{}", pprust::tts_to_string(tts));
println!("{}", pprust::tts_to_string(&tts));

// any so that `log_syntax` can be invoked as an expression and item.
base::DummyResult::any_valid(sp)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_builtin_macros/source_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn expand_stringify(
tts: TokenStream,
) -> Box<dyn base::MacResult + 'static> {
let sp = cx.with_def_site_ctxt(sp);
let s = pprust::tts_to_string(tts);
let s = pprust::tts_to_string(&tts);
base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&s)))
}

Expand Down
3 changes: 3 additions & 0 deletions src/librustc_codegen_ssa/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,9 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
cmd.arg(format!("--dynamic-linker={}ld.so.1", prefix));
}

// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
cmd.add_eh_frame_header();

// NO-OPT-OUT, OBJECT-FILES-NO
if crt_objects_fallback {
cmd.no_crt_objects();
Expand Down
14 changes: 14 additions & 0 deletions src/librustc_codegen_ssa/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ pub trait Linker {
fn group_start(&mut self);
fn group_end(&mut self);
fn linker_plugin_lto(&mut self);
fn add_eh_frame_header(&mut self) {}
fn finalize(&mut self);
}

Expand Down Expand Up @@ -615,6 +616,19 @@ impl<'a> Linker for GccLinker<'a> {
}
}
}

// Add the `GNU_EH_FRAME` program header which is required to locate unwinding information.
// Some versions of `gcc` add it implicitly, some (e.g. `musl-gcc`) don't,
// so we just always add it.
fn add_eh_frame_header(&mut self) {
// The condition here is "uses ELF" basically.
if !self.sess.target.target.options.is_like_osx
&& !self.sess.target.target.options.is_like_windows
&& self.sess.target.target.target_os != "uefi"
{
self.linker_arg("--eh-frame-hdr");
}
}
}

pub struct MsvcLinker<'a> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_expand/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ fn generic_extension<'cx>(
let sess = cx.parse_sess;

if cx.trace_macros() {
let msg = format!("expanding `{}! {{ {} }}`", name, pprust::tts_to_string(arg.clone()));
let msg = format!("expanding `{}! {{ {} }}`", name, pprust::tts_to_string(&arg));
trace_macros_note(&mut cx.expansions, sp, msg);
}

Expand Down Expand Up @@ -300,7 +300,7 @@ fn generic_extension<'cx>(
}

if cx.trace_macros() {
let msg = format!("to `{}`", pprust::tts_to_string(tts.clone()));
let msg = format!("to `{}`", pprust::tts_to_string(&tts));
trace_macros_note(&mut cx.expansions, sp, msg);
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_expand/proc_macro_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl server::TokenStream for Rustc<'_> {
)
}
fn to_string(&mut self, stream: &Self::TokenStream) -> String {
pprust::tts_to_string(stream.clone())
pprust::tts_to_string(stream)
}
fn from_token_tree(
&mut self,
Expand Down
18 changes: 9 additions & 9 deletions src/librustc_infer/infer/at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
where
T: ToTrace<'tcx>,
{
self.trace_exp(a_is_expected, a, b).sub(&a, &b)
self.trace_exp(a_is_expected, a, b).sub(a, b)
}

/// Makes `actual <: expected`. For example, if type-checking a
Expand All @@ -109,15 +109,15 @@ impl<'a, 'tcx> At<'a, 'tcx> {
where
T: ToTrace<'tcx>,
{
self.trace_exp(a_is_expected, a, b).eq(&a, &b)
self.trace_exp(a_is_expected, a, b).eq(a, b)
}

/// Makes `expected <: actual`.
pub fn eq<T>(self, expected: T, actual: T) -> InferResult<'tcx, ()>
where
T: ToTrace<'tcx>,
{
self.trace(expected, actual).eq(&expected, &actual)
self.trace(expected, actual).eq(expected, actual)
}

pub fn relate<T>(self, expected: T, variance: ty::Variance, actual: T) -> InferResult<'tcx, ()>
Expand Down Expand Up @@ -147,7 +147,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
where
T: ToTrace<'tcx>,
{
self.trace(expected, actual).lub(&expected, &actual)
self.trace(expected, actual).lub(expected, actual)
}

/// Computes the greatest-lower-bound, or mutual subtype, of two
Expand All @@ -157,7 +157,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
where
T: ToTrace<'tcx>,
{
self.trace(expected, actual).glb(&expected, &actual)
self.trace(expected, actual).glb(expected, actual)
}

/// Sets the "trace" values that will be used for
Expand Down Expand Up @@ -186,7 +186,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
impl<'a, 'tcx> Trace<'a, 'tcx> {
/// Makes `a <: b` where `a` may or may not be expected (if
/// `a_is_expected` is true, then `a` is expected).
pub fn sub<T>(self, a: &T, b: &T) -> InferResult<'tcx, ()>
pub fn sub<T>(self, a: T, b: T) -> InferResult<'tcx, ()>
where
T: Relate<'tcx>,
{
Expand All @@ -203,7 +203,7 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {

/// Makes `a == b`; the expectation is set by the call to
/// `trace()`.
pub fn eq<T>(self, a: &T, b: &T) -> InferResult<'tcx, ()>
pub fn eq<T>(self, a: T, b: T) -> InferResult<'tcx, ()>
where
T: Relate<'tcx>,
{
Expand All @@ -218,7 +218,7 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
})
}

pub fn lub<T>(self, a: &T, b: &T) -> InferResult<'tcx, T>
pub fn lub<T>(self, a: T, b: T) -> InferResult<'tcx, T>
where
T: Relate<'tcx>,
{
Expand All @@ -233,7 +233,7 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
})
}

pub fn glb<T>(self, a: &T, b: &T) -> InferResult<'tcx, T>
pub fn glb<T>(self, a: T, b: T) -> InferResult<'tcx, T>
where
T: Relate<'tcx>,
{
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_infer/infer/canonical/query_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
},
ty::Variance::Invariant,
)
.relate(&v1, &v2)?;
.relate(v1, v2)?;
}

(GenericArgKind::Const(v1), GenericArgKind::Const(v2)) => {
Expand All @@ -285,7 +285,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
},
ty::Variance::Invariant,
)
.relate(&v1, &v2)?;
.relate(v1, v2)?;
}

_ => {
Expand All @@ -302,7 +302,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
// Screen out `'a: 'a` cases -- we skip the binder here but
// only compare the inner values to one another, so they are still at
// consistent binding levels.
let &ty::OutlivesPredicate(k1, r2) = r_c.skip_binder();
let ty::OutlivesPredicate(k1, r2) = r_c.skip_binder();
if k1 != r2.into() { Some(r_c) } else { None }
}),
);
Expand Down Expand Up @@ -526,7 +526,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a + Captures<'tcx> {
unsubstituted_region_constraints.iter().map(move |constraint| {
let constraint = substitute_value(self.tcx, result_subst, constraint);
let &ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below
let ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below

Obligation::new(
cause.clone(),
Expand Down
20 changes: 10 additions & 10 deletions src/librustc_infer/infer/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,10 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
// to associate causes/spans with each of the relations in
// the stack to get this right.
match dir {
EqTo => self.equate(a_is_expected).relate(&a_ty, &b_ty),
SubtypeOf => self.sub(a_is_expected).relate(&a_ty, &b_ty),
EqTo => self.equate(a_is_expected).relate(a_ty, b_ty),
SubtypeOf => self.sub(a_is_expected).relate(a_ty, b_ty),
SupertypeOf => {
self.sub(a_is_expected).relate_with_variance(ty::Contravariant, &a_ty, &b_ty)
self.sub(a_is_expected).relate_with_variance(ty::Contravariant, a_ty, b_ty)
}
}?;

Expand Down Expand Up @@ -379,7 +379,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
param_env: self.param_env,
};

let ty = match generalize.relate(&ty, &ty) {
let ty = match generalize.relate(ty, ty) {
Ok(ty) => ty,
Err(e) => {
debug!("generalize: failure {:?}", e);
Expand Down Expand Up @@ -490,8 +490,8 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {

fn binders<T>(
&mut self,
a: &ty::Binder<T>,
b: &ty::Binder<T>,
a: ty::Binder<T>,
b: ty::Binder<T>,
) -> RelateResult<'tcx, ty::Binder<T>>
where
T: Relate<'tcx>,
Expand Down Expand Up @@ -519,8 +519,8 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
fn relate_with_variance<T: Relate<'tcx>>(
&mut self,
variance: ty::Variance,
a: &T,
b: &T,
a: T,
b: T,
) -> RelateResult<'tcx, T> {
let old_ambient_variance = self.ambient_variance;
self.ambient_variance = self.ambient_variance.xform(variance);
Expand Down Expand Up @@ -552,7 +552,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
match probe {
TypeVariableValue::Known { value: u } => {
debug!("generalize: known value {:?}", u);
self.relate(&u, &u)
self.relate(u, u)
}
TypeVariableValue::Unknown { universe } => {
match self.ambient_variance {
Expand Down Expand Up @@ -655,7 +655,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
let variable_table = &mut inner.const_unification_table();
let var_value = variable_table.probe_value(vid);
match var_value.val {
ConstVariableValue::Known { value: u } => self.relate(&u, &u),
ConstVariableValue::Known { value: u } => self.relate(u, u),
ConstVariableValue::Unknown { universe } => {
if self.for_universe.can_name(universe) {
Ok(c)
Expand Down
Loading