Skip to content

Commit

Permalink
Merge rustc into rmc - 2021 week 39 (rust-lang#502)
Browse files Browse the repository at this point in the history
Conflicts:
    compiler/rustc_driver/src/lib.rs
    src/llvm-project (sub-module)
    src/tools/cargo (sub-module)
    src/tools/rust-analyzer (sub-module)

Updates required:
    modified:   compiler/rustc_codegen_rmc/src/compiler_interface.rs
    modified:   compiler/rustc_codegen_rmc/src/context/goto_ctx.rs
    modified:   compiler/rustc_codegen_rmc/src/overrides/stubs/rust_stubber.rs
    modified:   compiler/rustc_monomorphize/src/collector.rs
    modified:   src/test/rmc/Enum/result3.rs

Note:

We added a loop unwind option to rmc/Enum/result3.rs test. The merge
uncovered an issue, filed here: rust-lang#540.
  • Loading branch information
celinval authored and tedinski committed Oct 6, 2021
1 parent 0a8aa64 commit 4643e33
Show file tree
Hide file tree
Showing 757 changed files with 20,671 additions and 4,545 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
[submodule "src/llvm-project"]
path = src/llvm-project
url = https://github.com/rust-lang/llvm-project.git
branch = rustc/13.0-2021-08-08
branch = rustc/13.0-2021-09-30
[submodule "src/doc/embedded-book"]
path = src/doc/embedded-book
url = https://github.com/rust-embedded/book.git
Expand Down
77 changes: 48 additions & 29 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ version = "0.1.0"
dependencies = [
"directories",
"rustc-workspace-hack",
"rustc_version",
"rustc_version 0.3.3",
"serde",
"serde_json",
"vergen",
Expand Down Expand Up @@ -1143,19 +1143,6 @@ dependencies = [
"termcolor",
]

[[package]]
name = "env_logger"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54532e3223c5af90a6a757c90b5c5521564b07e5e7a958681bcd2afad421cdcd"
dependencies = [
"atty",
"humantime 2.0.1",
"log",
"regex",
"termcolor",
]

[[package]]
name = "env_logger"
version = "0.9.0"
Expand Down Expand Up @@ -1711,7 +1698,7 @@ checksum = "3ca8957e71f04a205cb162508f9326aea04676c8dfd0711220190d6b83664f3f"
dependencies = [
"bitmaps",
"rand_core 0.5.1",
"rand_xoshiro",
"rand_xoshiro 0.4.0",
"sized-chunks",
"typenum",
"version_check",
Expand Down Expand Up @@ -2301,15 +2288,15 @@ version = "0.1.0"
dependencies = [
"colored",
"compiletest_rs",
"env_logger 0.8.1",
"env_logger 0.9.0",
"getrandom 0.2.0",
"hex 0.4.2",
"libc",
"log",
"measureme",
"rand 0.8.3",
"rand 0.8.4",
"rustc-workspace-hack",
"rustc_version",
"rustc_version 0.4.0",
"shell-escape",
"smallvec",
]
Expand Down Expand Up @@ -2960,9 +2947,9 @@ dependencies = [

[[package]]
name = "rand"
version = "0.8.3"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
dependencies = [
"libc",
"rand_chacha 0.3.0",
Expand Down Expand Up @@ -3053,6 +3040,15 @@ dependencies = [
"rand_core 0.5.1",
]

[[package]]
name = "rand_xoshiro"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa"
dependencies = [
"rand_core 0.6.2",
]

[[package]]
name = "rayon"
version = "1.3.1"
Expand Down Expand Up @@ -3783,6 +3779,7 @@ dependencies = [
"rustc_llvm",
"rustc_metadata",
"rustc_middle",
"rustc_query_system",
"rustc_serialize",
"rustc_session",
"rustc_span",
Expand Down Expand Up @@ -3846,7 +3843,9 @@ dependencies = [
"rustc_incremental",
"rustc_index",
"rustc_macros",
"rustc_metadata",
"rustc_middle",
"rustc_query_system",
"rustc_serialize",
"rustc_session",
"rustc_span",
Expand Down Expand Up @@ -3874,6 +3873,7 @@ dependencies = [
"rustc_macros",
"rustc_middle",
"rustc_mir_dataflow",
"rustc_query_system",
"rustc_session",
"rustc_span",
"rustc_target",
Expand Down Expand Up @@ -4227,6 +4227,8 @@ dependencies = [
"either",
"gsgdt",
"polonius-engine",
"rand 0.8.4",
"rand_xoshiro 0.6.0",
"rustc-rayon-core",
"rustc_apfloat",
"rustc_arena",
Expand Down Expand Up @@ -4307,6 +4309,7 @@ dependencies = [
"rustc_index",
"rustc_middle",
"rustc_mir_dataflow",
"rustc_query_system",
"rustc_serialize",
"rustc_session",
"rustc_span",
Expand Down Expand Up @@ -4437,13 +4440,17 @@ dependencies = [
"parking_lot",
"rustc-rayon-core",
"rustc_arena",
"rustc_ast",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
"rustc_hir",
"rustc_index",
"rustc_macros",
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_target",
"smallvec",
"tracing",
]
Expand Down Expand Up @@ -4511,6 +4518,7 @@ dependencies = [
"rustc_errors",
"rustc_feature",
"rustc_fs_util",
"rustc_hir",
"rustc_lint_defs",
"rustc_macros",
"rustc_serialize",
Expand Down Expand Up @@ -4546,6 +4554,7 @@ dependencies = [
"rustc_data_structures",
"rustc_hir",
"rustc_middle",
"rustc_query_system",
"rustc_session",
"rustc_span",
"rustc_target",
Expand Down Expand Up @@ -4589,6 +4598,7 @@ dependencies = [
"rustc_macros",
"rustc_middle",
"rustc_parse_format",
"rustc_query_system",
"rustc_session",
"rustc_span",
"rustc_target",
Expand Down Expand Up @@ -4677,6 +4687,15 @@ dependencies = [
"semver 0.11.0",
]

[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver 1.0.3",
]

[[package]]
name = "rustdoc"
version = "0.0.0"
Expand Down Expand Up @@ -5037,9 +5056,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"

[[package]]
name = "smallvec"
version = "1.6.1"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"

[[package]]
name = "snap"
Expand Down Expand Up @@ -5237,7 +5256,7 @@ checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
dependencies = [
"cfg-if 1.0.0",
"libc",
"rand 0.8.3",
"rand 0.8.4",
"redox_syscall",
"remove_dir_all",
"winapi",
Expand Down Expand Up @@ -5486,9 +5505,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6"

[[package]]
name = "tracing"
version = "0.1.25"
version = "0.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f"
checksum = "84f96e095c0c82419687c20ddf5cb3eadb61f4e1405923c9dc8e53a1adacbda8"
dependencies = [
"cfg-if 1.0.0",
"pin-project-lite",
Expand All @@ -5498,9 +5517,9 @@ dependencies = [

[[package]]
name = "tracing-attributes"
version = "0.1.13"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8a9bd1db7706f2373a190b0d067146caa39350c486f3d455b0e33b431f94c07"
checksum = "c4f915eb6abf914599c200260efced9203504c4c37380af10cdf3b7d36970650"
dependencies = [
"proc-macro2",
"quote",
Expand All @@ -5509,9 +5528,9 @@ dependencies = [

[[package]]
name = "tracing-core"
version = "0.1.17"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f"
checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4"
dependencies = [
"lazy_static",
]
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ members = [
exclude = [
"build",
"compiler/rustc_codegen_cranelift",
"compiler/rustc_codegen_gcc",
"src/test/rustdoc-gui",
# HACK(eddyb) This hardcodes the fact that our CI uses `/checkout/obj`.
"obj",
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,8 @@ impl Expr {
}
}

ExprKind::Underscore => TyKind::Infer,

// This expression doesn't look like a type syntactically.
_ => return None,
};
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ impl TokenKind {
match *self {
Comma => Some(vec![Dot, Lt, Semi]),
Semi => Some(vec![Colon, Comma]),
FatArrow => Some(vec![Eq, RArrow]),
_ => None,
}
}
Expand Down
11 changes: 7 additions & 4 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
ExprKind::If(ref cond, ref then, ref else_opt) => {
self.lower_expr_if(cond, then, else_opt.as_deref())
}
ExprKind::While(ref cond, ref body, opt_label) => self
.with_loop_scope(e.id, |this| {
this.lower_expr_while_in_loop_scope(e.span, cond, body, opt_label)
}),
ExprKind::While(ref cond, ref body, opt_label) => {
self.with_loop_scope(e.id, |this| {
let span =
this.mark_span_with_reason(DesugaringKind::WhileLoop, e.span, None);
this.lower_expr_while_in_loop_scope(span, cond, body, opt_label)
})
}
ExprKind::Loop(ref body, opt_label) => self.with_loop_scope(e.id, |this| {
hir::ExprKind::Loop(
this.lower_block(body, false),
Expand Down
63 changes: 38 additions & 25 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,32 +1328,45 @@ impl<'hir> LoweringContext<'_, 'hir> {
// keep track of the Span info. Now, `add_implicitly_sized` in `AstConv` checks both param bounds and
// where clauses for `?Sized`.
for pred in &generics.where_clause.predicates {
if let WherePredicate::BoundPredicate(ref bound_pred) = *pred {
'next_bound: for bound in &bound_pred.bounds {
if let GenericBound::Trait(_, TraitBoundModifier::Maybe) = *bound {
// Check if the where clause type is a plain type parameter.
match self
.resolver
.get_partial_res(bound_pred.bounded_ty.id)
.map(|d| (d.base_res(), d.unresolved_segments()))
{
Some((Res::Def(DefKind::TyParam, def_id), 0))
if bound_pred.bound_generic_params.is_empty() =>
{
for param in &generics.params {
if def_id == self.resolver.local_def_id(param.id).to_def_id() {
continue 'next_bound;
}
}
}
_ => {}
}
self.diagnostic().span_err(
bound_pred.bounded_ty.span,
"`?Trait` bounds are only permitted at the \
point where a type parameter is declared",
);
let bound_pred = match *pred {
WherePredicate::BoundPredicate(ref bound_pred) => bound_pred,
_ => continue,
};
let compute_is_param = || {
// Check if the where clause type is a plain type parameter.
match self
.resolver
.get_partial_res(bound_pred.bounded_ty.id)
.map(|d| (d.base_res(), d.unresolved_segments()))
{
Some((Res::Def(DefKind::TyParam, def_id), 0))
if bound_pred.bound_generic_params.is_empty() =>
{
generics
.params
.iter()
.find(|p| def_id == self.resolver.local_def_id(p.id).to_def_id())
.is_some()
}
// Either the `bounded_ty` is not a plain type parameter, or
// it's not found in the generic type parameters list.
_ => false,
}
};
// We only need to compute this once per `WherePredicate`, but don't
// need to compute this at all unless there is a Maybe bound.
let mut is_param: Option<bool> = None;
for bound in &bound_pred.bounds {
if !matches!(*bound, GenericBound::Trait(_, TraitBoundModifier::Maybe)) {
continue;
}
let is_param = *is_param.get_or_insert_with(compute_is_param);
if !is_param {
self.diagnostic().span_err(
bound.span(),
"`?Trait` bounds are only permitted at the \
point where a type parameter is declared",
);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub trait ResolverAstLowering {
fn legacy_const_generic_args(&mut self, expr: &Expr) -> Option<Vec<usize>>;

/// Obtains resolution for a `NodeId` with a single resolution.
fn get_partial_res(&mut self, id: NodeId) -> Option<PartialRes>;
fn get_partial_res(&self, id: NodeId) -> Option<PartialRes>;

/// Obtains per-namespace resolutions for `use` statement with the given `NodeId`.
fn get_import_res(&mut self, id: NodeId) -> PerNS<Option<Res<NodeId>>>;
Expand Down
Loading

0 comments on commit 4643e33

Please sign in to comment.