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 #78759

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4af560e
Move zero-sized-vec-push test
poliorcetics Sep 14, 2020
85afbd8
Rebase conflicts
poliorcetics Oct 17, 2020
4fd06b9
Move vec-macro-repeat test
poliorcetics Oct 3, 2020
42271a5
Move vec swap test
poliorcetics Oct 3, 2020
1bdee96
Move subslice pattern tests to alloc/tests/slice.rs
poliorcetics Oct 3, 2020
20e032e
Make it more clear when complaining about async fn's return types
guswynn Sep 15, 2020
251f6da
(rustdoc) fix test for trait impl display
liketechnik Oct 25, 2020
e4d1096
Change as_str → to_string in proc_macro::Ident::span() docs
est31 Oct 28, 2020
300362e
Close the theme picker when Escape is pressed
notriddle Oct 30, 2020
ac3a434
Allow the theme picker to work with arrow keys
notriddle Oct 30, 2020
6918a17
Add aria roles for theme picker menu
notriddle Oct 30, 2020
90c7c63
Add comment describing the Escape key weirdness
notriddle Oct 30, 2020
17b8ca9
Pull theme picker keyboard code into main.js
notriddle Oct 30, 2020
5801109
Move Copy and Clone into the list of traits implemented for all sizes
est31 Nov 4, 2020
93fa023
Fix outdated comment next to array_impl_default
est31 Nov 4, 2020
bcd2f2d
fix a couple of clippy warnings:
matthiaskrgr Nov 4, 2020
69e5729
Simplify the implementation of `get_mut` (no unsafe)
danielhenrymantilla Nov 4, 2020
232b9ba
Move range in ui test to ops test in library/core
sasurau4 Nov 4, 2020
308dbdd
ci: bump actions/checkout to version 2
pietroalbini Nov 4, 2020
d8afe98
Clean up docs for 'as' keyword
camelid Oct 19, 2020
3084a55
Don't use `crate` in link text
camelid Nov 5, 2020
bbdb1f0
Clean up some intra-doc links
camelid Nov 5, 2020
677b2ac
Add missing comma
camelid Nov 5, 2020
873ebcb
Fixed typo in comment
eltociear Nov 5, 2020
30bb1f9
Rollup merge of #76718 - poliorcetics:vec-ui-to-unit-test, r=jyn514
JohnTitor Nov 5, 2020
dea29bd
Rollup merge of #76765 - guswynn:async_return, r=tmandry
JohnTitor Nov 5, 2020
d44e165
Rollup merge of #78093 - camelid:as-cleanup, r=jyn514
JohnTitor Nov 5, 2020
c961d75
Rollup merge of #78465 - est31:proc_macro_to_string, r=jyn514
JohnTitor Nov 5, 2020
82ba395
Rollup merge of #78584 - notriddle:master, r=GuillaumeGomez
JohnTitor Nov 5, 2020
c0318b6
Rollup merge of #78716 - est31:array_traits, r=Dylan-DPC
JohnTitor Nov 5, 2020
0878abd
Rollup merge of #78727 - liketechnik:issue-55201, r=GuillaumeGomez
JohnTitor Nov 5, 2020
08e60c6
Rollup merge of #78733 - matthiaskrgr:cl11ppy, r=jyn514
JohnTitor Nov 5, 2020
41d11a1
Rollup merge of #78735 - danielhenrymantilla:simplify-unsafecell-getm…
JohnTitor Nov 5, 2020
2d63234
Rollup merge of #78738 - sasurau4:test/move-range-test-to-library-cor…
JohnTitor Nov 5, 2020
b0d2f97
Rollup merge of #78754 - pietroalbini:checkout-v2, r=Mark-Simulacrum
JohnTitor Nov 5, 2020
a1e8894
Rollup merge of #78757 - camelid:crate-link-text, r=jyn514
JohnTitor Nov 5, 2020
652aea0
Rollup merge of #78758 - eltociear:patch-1, r=jyn514
JohnTitor Nov 5, 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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: disable git crlf conversion
run: git config --global core.autocrlf false
- name: checkout the source code
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: configure the PR in which the error message will be posted
Expand Down Expand Up @@ -427,7 +427,7 @@ jobs:
- name: disable git crlf conversion
run: git config --global core.autocrlf false
- name: checkout the source code
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: configure the PR in which the error message will be posted
Expand Down Expand Up @@ -537,7 +537,7 @@ jobs:
- name: disable git crlf conversion
run: git config --global core.autocrlf false
- name: checkout the source code
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: configure the PR in which the error message will be posted
Expand Down Expand Up @@ -644,7 +644,7 @@ jobs:
- name: disable git crlf conversion
run: git config --global core.autocrlf false
- name: checkout the source code
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: configure the PR in which the error message will be posted
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ pub fn list_contains_name(items: &[NestedMetaItem], name: Symbol) -> bool {
impl MetaItem {
fn token_trees_and_spacings(&self) -> Vec<TreeAndSpacing> {
let mut idents = vec![];
let mut last_pos = BytePos(0 as u32);
let mut last_pos = BytePos(0_u32);
for (i, segment) in self.path.segments.iter().enumerate() {
let is_first = i == 0;
if !is_first {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
"cannot infer {} {} {} `{}`{}",
kind_str, preposition, descr, type_name, parent_desc
)
.into()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,43 +102,89 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
None => String::new(),
};

let (span_1, span_2, main_label, span_label) = match (sup_is_ret_type, sub_is_ret_type) {
(None, None) => {
let (main_label_1, span_label_1) = if ty_sup.hir_id == ty_sub.hir_id {
let (span_1, span_2, main_label, span_label, future_return_type) =
match (sup_is_ret_type, sub_is_ret_type) {
(None, None) => {
let (main_label_1, span_label_1) = if ty_sup.hir_id == ty_sub.hir_id {
(
"this type is declared with multiple lifetimes...".to_owned(),
"...but data with one lifetime flows into the other here".to_owned(),
)
} else {
(
"these two types are declared with different lifetimes...".to_owned(),
format!("...but data{} flows{} here", span_label_var1, span_label_var2),
)
};
(ty_sup.span, ty_sub.span, main_label_1, span_label_1, None)
}

(Some(ret_span), _) => {
let sup_future = self.future_return_type(scope_def_id_sup);
let (return_type, action) = if let Some(_) = sup_future {
("returned future", "held across an await point")
} else {
("return type", "returned")
};

(
"this type is declared with multiple lifetimes...".to_owned(),
"...but data with one lifetime flows into the other here".to_owned(),
ty_sub.span,
ret_span,
format!(
"this parameter and the {} are declared with different lifetimes...",
return_type
),
format!("...but data{} is {} here", span_label_var1, action),
sup_future,
)
} else {
}
(_, Some(ret_span)) => {
let sub_future = self.future_return_type(scope_def_id_sub);
let (return_type, action) = if let Some(_) = sub_future {
("returned future", "held across an await point")
} else {
("return type", "returned")
};

(
"these two types are declared with different lifetimes...".to_owned(),
format!("...but data{} flows{} here", span_label_var1, span_label_var2),
ty_sup.span,
ret_span,
format!(
"this parameter and the {} are declared with different lifetimes...",
return_type
),
format!("...but data{} is {} here", span_label_var1, action),
sub_future,
)
};
(ty_sup.span, ty_sub.span, main_label_1, span_label_1)
}

(Some(ret_span), _) => (
ty_sub.span,
ret_span,
"this parameter and the return type are declared with different lifetimes..."
.to_owned(),
format!("...but data{} is returned here", span_label_var1),
),
(_, Some(ret_span)) => (
ty_sup.span,
ret_span,
"this parameter and the return type are declared with different lifetimes..."
.to_owned(),
format!("...but data{} is returned here", span_label_var1),
),
};

struct_span_err!(self.tcx().sess, span, E0623, "lifetime mismatch")
.span_label(span_1, main_label)
.span_label(span_2, String::new())
.span_label(span, span_label)
.emit();
}
};

let mut e = struct_span_err!(self.tcx().sess, span, E0623, "lifetime mismatch");

e.span_label(span_1, main_label);
e.span_label(span_2, String::new());
e.span_label(span, span_label);

if let Some(t) = future_return_type {
let snip = self
.tcx()
.sess
.source_map()
.span_to_snippet(t.span)
.ok()
.and_then(|s| match (&t.kind, s.as_str()) {
(rustc_hir::TyKind::Tup(&[]), "") => Some("()".to_string()),
(_, "") => None,
_ => Some(s),
})
.unwrap_or("{unnamed_type}".to_string());

e.span_label(
t.span,
&format!("this `async fn` implicitly returns an `impl Future<Output = {}>`", snip),
);
}
e.emit();
Some(ErrorReported)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,60 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
})
}

pub(super) fn future_return_type(
&self,
local_def_id: LocalDefId,
) -> Option<&rustc_hir::Ty<'_>> {
if let Some(hir::IsAsync::Async) = self.asyncness(local_def_id) {
if let rustc_middle::ty::Opaque(def_id, _) =
self.tcx().type_of(local_def_id).fn_sig(self.tcx()).output().skip_binder().kind()
{
match self.tcx().hir().get_if_local(*def_id) {
Some(hir::Node::Item(hir::Item {
kind:
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
bounds,
origin: hir::OpaqueTyOrigin::AsyncFn,
..
}),
..
})) => {
for b in bounds.iter() {
if let hir::GenericBound::LangItemTrait(
hir::LangItem::Future,
_span,
_hir_id,
generic_args,
) = b
{
for type_binding in generic_args.bindings.iter() {
if type_binding.ident.name == rustc_span::sym::Output {
if let hir::TypeBindingKind::Equality { ty } =
type_binding.kind
{
return Some(ty);
}
}
}
}
}
}
_ => {}
}
}
}
None
}

pub(super) fn asyncness(&self, local_def_id: LocalDefId) -> Option<hir::IsAsync> {
// similar to the asyncness fn in rustc_ty::ty
let hir_id = self.tcx().hir().local_def_id_to_hir_id(local_def_id);
let node = self.tcx().hir().get(hir_id);
let fn_like = rustc_middle::hir::map::blocks::FnLikeNode::from_node(node)?;

Some(fn_like.asyncness())
}

// Here, we check for the case where the anonymous region
// is in the return type.
// FIXME(#42703) - Need to handle certain cases here.
Expand Down
9 changes: 4 additions & 5 deletions compiler/rustc_interface/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ pub fn get_codegen_backend(sopts: &config::Options) -> Box<dyn CodegenBackend> {

INIT.call_once(|| {
#[cfg(feature = "llvm")]
const DEFAULT_CODEGEN_BACKEND: &'static str = "llvm";
const DEFAULT_CODEGEN_BACKEND: &str = "llvm";

#[cfg(not(feature = "llvm"))]
const DEFAULT_CODEGEN_BACKEND: &'static str = "cranelift";
const DEFAULT_CODEGEN_BACKEND: &str = "cranelift";

let codegen_name = sopts
.debugging_opts
Expand Down Expand Up @@ -414,11 +414,10 @@ pub fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box<dyn CodegenBackend
let libdir = filesearch::relative_target_lib_path(&sysroot, &target);
sysroot.join(libdir).with_file_name("codegen-backends")
})
.filter(|f| {
.find(|f| {
info!("codegen backend candidate: {}", f.display());
f.exists()
})
.next();
});
let sysroot = sysroot.unwrap_or_else(|| {
let candidates = sysroot_candidates
.iter()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ impl<'tcx> TyCtxt<'tcx> {
def_id: DefId,
id: Option<HirId>,
span: Span,
unmarked: impl FnOnce(Span, DefId) -> (),
unmarked: impl FnOnce(Span, DefId),
) {
let soft_handler = |lint, span, msg: &_| {
self.struct_span_lint_hir(lint, id.unwrap_or(hir::CRATE_HIR_ID), span, |lint| {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl SwitchTargets {
pub fn new(targets: impl Iterator<Item = (u128, BasicBlock)>, otherwise: BasicBlock) -> Self {
let (values, mut targets): (SmallVec<_>, SmallVec<_>) = targets.unzip();
targets.push(otherwise);
Self { values: values.into(), targets }
Self { values, targets }
}

/// Builds a switch targets definition that jumps to `then` if the tested value equals `value`,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,7 @@ pub type PlaceholderConst = Placeholder<BoundVar>;
#[derive(Hash, HashStable)]
pub struct WithOptConstParam<T> {
pub did: T,
/// The `DefId` of the corresponding generic paramter in case `did` is
/// The `DefId` of the corresponding generic parameter in case `did` is
/// a const argument.
///
/// Note that even if `did` is a const argument, this may still be `None`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let move_out = self.move_data.moves[(*move_site).moi];
let moved_place = &self.move_data.move_paths[move_out.path].place;
// `*(_1)` where `_1` is a `Box` is actually a move out.
let is_box_move = moved_place.as_ref().projection == &[ProjectionElem::Deref]
let is_box_move = moved_place.as_ref().projection == [ProjectionElem::Deref]
&& self.body.local_decls[moved_place.local].ty.is_box();

!is_box_move
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/transform/match_branches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
};

// Check that destinations are identical, and if not, then don't optimize this block
if &bbs[first].terminator().kind != &bbs[second].terminator().kind {
if bbs[first].terminator().kind != bbs[second].terminator().kind {
continue;
}

Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1886,9 +1886,8 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
if snippet.starts_with('&') && !snippet.starts_with("&'") {
introduce_suggestion
.push((param.span, format!("&'a {}", &snippet[1..])));
} else if snippet.starts_with("&'_ ") {
introduce_suggestion
.push((param.span, format!("&'a {}", &snippet[4..])));
} else if let Some(stripped) = snippet.strip_prefix("&'_ ") {
introduce_suggestion.push((param.span, format!("&'a {}", &stripped)));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ fn normalize_src(src: &mut String, start_pos: BytePos) -> Vec<NormalizedPos> {

/// Removes UTF-8 BOM, if any.
fn remove_bom(src: &mut String, normalized_pos: &mut Vec<NormalizedPos>) {
if src.starts_with("\u{feff}") {
if src.starts_with('\u{feff}') {
src.drain(..3);
normalized_pos.push(NormalizedPos { pos: BytePos(0), diff: 3 });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1388,11 +1388,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
trait_ref: &ty::PolyTraitRef<'tcx>,
) {
let get_trait_impl = |trait_def_id| {
self.tcx.find_map_relevant_impl(
trait_def_id,
trait_ref.skip_binder().self_ty(),
|impl_def_id| Some(impl_def_id),
)
self.tcx.find_map_relevant_impl(trait_def_id, trait_ref.skip_binder().self_ty(), Some)
};
let required_trait_path = self.tcx.def_path_str(trait_ref.def_id());
let all_traits = self.tcx.all_traits(LOCAL_CRATE);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
Err(ErrorHandled::TooGeneric) => {
pending_obligation.stalled_on = substs
.iter()
.filter_map(|ty| TyOrConstInferVar::maybe_from_generic_arg(ty))
.filter_map(TyOrConstInferVar::maybe_from_generic_arg)
.collect();
ProcessResult::Unchanged
}
Expand Down
Loading