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 11 pull requests #88854

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
07988bb
Reword description of automatic impls of `Unsize`.
kpreid Aug 10, 2021
2884a74
Fix non-capturing closure return type coercion
FabianWolff Aug 18, 2021
4d6bfde
Improve error message when _ is used for in/inout asm operands
Amanieu Aug 21, 2021
bbe3be9
Add explanatory comment
FabianWolff Aug 31, 2021
cd75af2
Change more x64 size checks to not apply to x32.
hvdijk Sep 5, 2021
04db063
Don't build the library and standard library before documenting them
jyn514 Sep 5, 2021
e2d01ed
Simplify std::os module reexports to fix rustdoc linking issues
GuillaumeGomez Sep 3, 2021
2987f4b
WIP state
BoxyUwU Sep 6, 2021
9b29138
as casts and block exprs
BoxyUwU Sep 6, 2021
4483c2b
dont support blocks
BoxyUwU Sep 6, 2021
47b16f4
bless stderr
BoxyUwU Sep 6, 2021
c170dcf
tidy
BoxyUwU Sep 6, 2021
08e8644
move thir visitor to rustc_middle
BoxyUwU Sep 6, 2021
fc63e9a
dont build abstract const for monomorphic consts
BoxyUwU Sep 6, 2021
4cbcb09
handle `ExprKind::NeverToAny`
BoxyUwU Sep 6, 2021
1f57f8b
remove `WorkNode`
BoxyUwU Sep 6, 2021
15101c8
remove debug stmts
BoxyUwU Sep 7, 2021
406d2ab
rename mir -> thir around abstract consts
BoxyUwU Sep 7, 2021
79be080
remove comment
BoxyUwU Sep 7, 2021
955e2b2
nits
BoxyUwU Sep 7, 2021
8c7954d
add a `CastKind` to `Node::Cast`
BoxyUwU Sep 7, 2021
3212734
resolve `from_hir_call` FIXME
BoxyUwU Sep 7, 2021
cd2915e
fmt
BoxyUwU Sep 7, 2021
fd9bb30
CI please
BoxyUwU Sep 7, 2021
dc02b51
Use more accurate spans for "unused delimiter" lint
estebank Sep 9, 2021
8295e4a
add test for builtin types N + N unifying with fn call
BoxyUwU Sep 9, 2021
64354a9
Remove usage of cfg_if in std/src/os/mod.rs
GuillaumeGomez Sep 3, 2021
88d5aa6
Move fortanix module position in std::os reexports for alpha sort
GuillaumeGomez Sep 7, 2021
c9a56cd
Add help for E0463
GuillaumeGomez Sep 10, 2021
294510e
rustc: Remove local variable IDs from `Export`s
petrochenkov Sep 5, 2021
c1e9608
don't clone types that are Copy (clippy::clone_on_copy)
matthiaskrgr Sep 11, 2021
fd389b5
Rollup merge of #87904 - kpreid:unsize, r=jyn514
GuillaumeGomez Sep 11, 2021
1cf99f5
Rollup merge of #88147 - FabianWolff:issue-88097, r=jackh726
GuillaumeGomez Sep 11, 2021
24fed97
Rollup merge of #88209 - Amanieu:asm_in_underscore, r=nagisa
GuillaumeGomez Sep 11, 2021
f064ad7
Rollup merge of #88619 - GuillaumeGomez:simplify-std-os-reexports, r=…
GuillaumeGomez Sep 11, 2021
a21eaa4
Rollup merge of #88668 - hvdijk:x32, r=joshtriplett
GuillaumeGomez Sep 11, 2021
0235d0b
Rollup merge of #88675 - jyn514:faster-doc, r=Mark-Simulacrum
GuillaumeGomez Sep 11, 2021
78b5acc
Rollup merge of #88677 - petrochenkov:exportid, r=davidtwco
GuillaumeGomez Sep 11, 2021
abb31d6
Rollup merge of #88709 - BoxyUwU:thir-abstract-const, r=lcnr
GuillaumeGomez Sep 11, 2021
9f98345
Rollup merge of #88779 - estebank:unused-delims, r=davidtwco
GuillaumeGomez Sep 11, 2021
9c7edef
Rollup merge of #88830 - GuillaumeGomez:help-e0463, r=estebank
GuillaumeGomez Sep 11, 2021
35b66f8
Rollup merge of #88849 - matthiaskrgr:clony_on_copy, r=petrochenkov
GuillaumeGomez Sep 11, 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
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
category: constraint.category,
from_closure: false,
span,
variance_info: constraint.variance_info.clone(),
variance_info: constraint.variance_info,
};
}
Locations::Single(loc) => loc,
Expand All @@ -1752,13 +1752,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
category,
from_closure: true,
span: span,
variance_info: constraint.variance_info.clone(),
variance_info: constraint.variance_info,
})
.unwrap_or(BlameConstraint {
category: constraint.category,
from_closure: false,
span: body.source_info(loc).span,
variance_info: constraint.variance_info.clone(),
variance_info: constraint.variance_info,
})
}

Expand Down Expand Up @@ -2001,7 +2001,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
category: constraint.category,
from_closure: false,
span: constraint.locations.span(body),
variance_info: constraint.variance_info.clone(),
variance_info: constraint.variance_info,
}
}
})
Expand Down
12 changes: 12 additions & 0 deletions compiler/rustc_builtin_macros/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ fn parse_args<'a>(
let mut explicit_reg = false;
let op = if !is_global_asm && p.eat_keyword(kw::In) {
let reg = parse_reg(&mut p, &mut explicit_reg)?;
if p.eat_keyword(kw::Underscore) {
let err = ecx.struct_span_err(p.token.span, "_ cannot be used for input operands");
return Err(err);
}
let expr = p.parse_expr()?;
ast::InlineAsmOperand::In { reg, expr }
} else if !is_global_asm && p.eat_keyword(sym::out) {
Expand All @@ -129,6 +133,10 @@ fn parse_args<'a>(
ast::InlineAsmOperand::Out { reg, expr, late: true }
} else if !is_global_asm && p.eat_keyword(sym::inout) {
let reg = parse_reg(&mut p, &mut explicit_reg)?;
if p.eat_keyword(kw::Underscore) {
let err = ecx.struct_span_err(p.token.span, "_ cannot be used for input operands");
return Err(err);
}
let expr = p.parse_expr()?;
if p.eat(&token::FatArrow) {
let out_expr =
Expand All @@ -139,6 +147,10 @@ fn parse_args<'a>(
}
} else if !is_global_asm && p.eat_keyword(sym::inlateout) {
let reg = parse_reg(&mut p, &mut explicit_reg)?;
if p.eat_keyword(kw::Underscore) {
let err = ecx.struct_span_err(p.token.span, "_ cannot be used for input operands");
return Err(err);
}
let expr = p.parse_expr()?;
if p.eat(&token::FatArrow) {
let out_expr =
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#![feature(iter_map_while)]
#![feature(maybe_uninit_uninit_array)]
#![feature(min_specialization)]
#![feature(never_type)]
#![feature(type_alias_impl_trait)]
#![feature(new_uninit)]
#![feature(nll)]
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_data_structures/src/stable_hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ impl_stable_hash_via_hash!(i128);
impl_stable_hash_via_hash!(char);
impl_stable_hash_via_hash!(());

impl<CTX> HashStable<CTX> for ! {
fn hash_stable(&self, _ctx: &mut CTX, _hasher: &mut StableHasher) {
unreachable!()
}
}

impl<CTX> HashStable<CTX> for ::std::num::NonZeroU32 {
fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
self.get().hash_stable(ctx, hasher)
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_hir/src/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,11 @@ impl<Id> Res<Id> {
}
}

#[track_caller]
pub fn expect_non_local<OtherId>(self) -> Res<OtherId> {
self.map_id(|_| panic!("unexpected `Res::Local`"))
}

pub fn macro_kind(self) -> Option<MacroKind> {
match self {
Res::Def(DefKind::Macro(kind), _) => Some(kind),
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_infer/src/infer/nll_relate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ where

let old_ambient_variance = self.ambient_variance;
self.ambient_variance = self.ambient_variance.xform(variance);
self.ambient_variance_info = self.ambient_variance_info.clone().xform(info);
self.ambient_variance_info = self.ambient_variance_info.xform(info);

debug!("relate_with_variance: ambient_variance = {:?}", self.ambient_variance);

Expand Down Expand Up @@ -597,12 +597,12 @@ where

if self.ambient_covariance() {
// Covariance: a <= b. Hence, `b: a`.
self.push_outlives(v_b, v_a, self.ambient_variance_info.clone());
self.push_outlives(v_b, v_a, self.ambient_variance_info);
}

if self.ambient_contravariance() {
// Contravariant: b <= a. Hence, `a: b`.
self.push_outlives(v_a, v_b, self.ambient_variance_info.clone());
self.push_outlives(v_a, v_b, self.ambient_variance_info);
}

Ok(a)
Expand Down
120 changes: 52 additions & 68 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}
use rustc_ast as ast;
use rustc_ast::util::{classify, parser};
use rustc_ast::{ExprKind, StmtKind};
use rustc_ast_pretty::pprust;
use rustc_errors::{pluralize, Applicability};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
Expand All @@ -12,7 +11,7 @@ use rustc_middle::ty::adjustment;
use rustc_middle::ty::{self, Ty};
use rustc_span::symbol::Symbol;
use rustc_span::symbol::{kw, sym};
use rustc_span::{BytePos, Span, DUMMY_SP};
use rustc_span::{BytePos, MultiSpan, Span, DUMMY_SP};

declare_lint! {
/// The `unused_must_use` lint detects unused result of a type flagged as
Expand Down Expand Up @@ -491,77 +490,60 @@ trait UnusedDelimLint {
left_pos: Option<BytePos>,
right_pos: Option<BytePos>,
) {
let expr_text = if let Ok(snippet) = cx.sess().source_map().span_to_snippet(value.span) {
snippet
} else {
pprust::expr_to_string(value)
let spans = match value.kind {
ast::ExprKind::Block(ref block, None) if block.stmts.len() > 0 => {
let start = block.stmts[0].span;
let end = block.stmts[block.stmts.len() - 1].span;
if value.span.from_expansion() || start.from_expansion() || end.from_expansion() {
(
value.span.with_hi(value.span.lo() + BytePos(1)),
value.span.with_lo(value.span.hi() - BytePos(1)),
)
} else {
(value.span.with_hi(start.lo()), value.span.with_lo(end.hi()))
}
}
ast::ExprKind::Paren(ref expr) => {
if value.span.from_expansion() || expr.span.from_expansion() {
(
value.span.with_hi(value.span.lo() + BytePos(1)),
value.span.with_lo(value.span.hi() - BytePos(1)),
)
} else {
(value.span.with_hi(expr.span.lo()), value.span.with_lo(expr.span.hi()))
}
}
_ => return,
};
let keep_space = (
left_pos.map_or(false, |s| s >= value.span.lo()),
right_pos.map_or(false, |s| s <= value.span.hi()),
);
self.emit_unused_delims(cx, value.span, &expr_text, ctx.into(), keep_space);
self.emit_unused_delims(cx, spans, ctx.into(), keep_space);
}

fn emit_unused_delims(
&self,
cx: &EarlyContext<'_>,
span: Span,
pattern: &str,
spans: (Span, Span),
msg: &str,
keep_space: (bool, bool),
) {
// FIXME(flip1995): Quick and dirty fix for #70814. This should be fixed in rustdoc
// properly.
if span == DUMMY_SP {
if spans.0 == DUMMY_SP || spans.1 == DUMMY_SP {
return;
}

cx.struct_span_lint(self.lint(), span, |lint| {
cx.struct_span_lint(self.lint(), MultiSpan::from(vec![spans.0, spans.1]), |lint| {
let span_msg = format!("unnecessary {} around {}", Self::DELIM_STR, msg);
let mut err = lint.build(&span_msg);
let mut ate_left_paren = false;
let mut ate_right_paren = false;
let parens_removed = pattern
.trim_matches(|c| match c {
'(' | '{' => {
if ate_left_paren {
false
} else {
ate_left_paren = true;
true
}
}
')' | '}' => {
if ate_right_paren {
false
} else {
ate_right_paren = true;
true
}
}
_ => false,
})
.trim();

let replace = {
let mut replace = if keep_space.0 {
let mut s = String::from(" ");
s.push_str(parens_removed);
s
} else {
String::from(parens_removed)
};

if keep_space.1 {
replace.push(' ');
}
replace
};

let replacement = vec![
(spans.0, if keep_space.0 { " ".into() } else { "".into() }),
(spans.1, if keep_space.1 { " ".into() } else { "".into() }),
];
let suggestion = format!("remove these {}", Self::DELIM_STR);

err.span_suggestion_short(span, &suggestion, replace, Applicability::MachineApplicable);
err.multipart_suggestion(&suggestion, replacement, Applicability::MachineApplicable);
err.emit();
});
}
Expand Down Expand Up @@ -770,14 +752,15 @@ impl UnusedParens {
// Otherwise proceed with linting.
_ => {}
}

let pattern_text =
if let Ok(snippet) = cx.sess().source_map().span_to_snippet(value.span) {
snippet
} else {
pprust::pat_to_string(value)
};
self.emit_unused_delims(cx, value.span, &pattern_text, "pattern", (false, false));
let spans = if value.span.from_expansion() || inner.span.from_expansion() {
(
value.span.with_hi(value.span.lo() + BytePos(1)),
value.span.with_lo(value.span.hi() - BytePos(1)),
)
} else {
(value.span.with_hi(inner.span.lo()), value.span.with_lo(inner.span.hi()))
};
self.emit_unused_delims(cx, spans, "pattern", (false, false));
}
}
}
Expand Down Expand Up @@ -870,14 +853,15 @@ impl EarlyLintPass for UnusedParens {
);
}
_ => {
let pattern_text =
if let Ok(snippet) = cx.sess().source_map().span_to_snippet(ty.span) {
snippet
} else {
pprust::ty_to_string(ty)
};

self.emit_unused_delims(cx, ty.span, &pattern_text, "type", (false, false));
let spans = if ty.span.from_expansion() || r.span.from_expansion() {
(
ty.span.with_hi(ty.span.lo() + BytePos(1)),
ty.span.with_lo(ty.span.hi() - BytePos(1)),
)
} else {
(ty.span.with_hi(r.span.lo()), ty.span.with_lo(r.span.hi()))
};
self.emit_unused_delims(cx, spans, "type", (false, false));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_macros/src/session_diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
span_idx = Some(syn::Index::from(idx));
} else {
throw_span_err!(
info.span.clone().unwrap(),
info.span.unwrap(),
"type of field annotated with `#[suggestion(...)]` contains more than one Span"
);
}
Expand All @@ -460,7 +460,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
applicability_idx = Some(syn::Index::from(idx));
} else {
throw_span_err!(
info.span.clone().unwrap(),
info.span.unwrap(),
"type of field annotated with `#[suggestion(...)]` contains more than one Applicability"
);
}
Expand All @@ -479,15 +479,15 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
return Ok((span, applicability));
}
throw_span_err!(
info.span.clone().unwrap(),
info.span.unwrap(),
"wrong types for suggestion",
|diag| {
diag.help("#[suggestion(...)] on a tuple field must be applied to fields of type (Span, Applicability)")
}
);
}
_ => throw_span_err!(
info.span.clone().unwrap(),
info.span.unwrap(),
"wrong field type for suggestion",
|diag| {
diag.help("#[suggestion(...)] should be applied to fields of type Span or (Span, Applicability)")
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_metadata/src/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,11 @@ impl CrateError {
== Symbol::intern(&sess.opts.debugging_opts.profiler_runtime)
{
err.note(&"the compiler may have been built without the profiler runtime");
} else if crate_name.as_str().starts_with("rustc_") {
err.help(
"maybe you need to install the missing components with: \
`rustup component add rust-src rustc-dev llvm-tools-preview`",
);
}
err.span_label(span, "can't find crate");
err
Expand Down
14 changes: 6 additions & 8 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use rustc_middle::middle::cstore::{ForeignModule, LinkagePreference, NativeLib};
use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
use rustc_middle::mir::{self, Body, Promoted};
use rustc_middle::thir;
use rustc_middle::ty::codec::TyDecoder;
use rustc_middle::ty::{self, Ty, TyCtxt, Visibility};
use rustc_serialize::{opaque, Decodable, Decoder};
Expand Down Expand Up @@ -540,7 +541,7 @@ impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for Span {
}
}

impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for &'tcx [mir::abstract_const::Node<'tcx>] {
impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for &'tcx [thir::abstract_const::Node<'tcx>] {
fn decode(d: &mut DecodeContext<'a, 'tcx>) -> Result<Self, String> {
ty::codec::RefDecodable::decode(d)
}
Expand Down Expand Up @@ -1019,10 +1020,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
}

/// Iterates over each child of the given item.
fn each_child_of_item<F>(&self, id: DefIndex, mut callback: F, sess: &Session)
where
F: FnMut(Export<hir::HirId>),
{
fn each_child_of_item(&self, id: DefIndex, mut callback: impl FnMut(Export), sess: &Session) {
if let Some(data) = &self.root.proc_macro_data {
/* If we are loading as a proc macro, we want to return the view of this crate
* as a proc macro crate.
Expand Down Expand Up @@ -1198,14 +1196,14 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
.decode((self, tcx))
}

fn get_mir_abstract_const(
fn get_thir_abstract_const(
&self,
tcx: TyCtxt<'tcx>,
id: DefIndex,
) -> Result<Option<&'tcx [mir::abstract_const::Node<'tcx>]>, ErrorReported> {
) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorReported> {
self.root
.tables
.mir_abstract_consts
.thir_abstract_consts
.get(self, id)
.map_or(Ok(None), |v| Ok(Some(v.decode((self, tcx)))))
}
Expand Down
Loading