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 5 pull requests #114697

Merged
merged 11 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,7 @@ impl Expr<'_> {
.iter()
.map(|field| field.expr)
.chain(init.into_iter())
.all(|e| e.can_have_side_effects()),
.any(|e| e.can_have_side_effects()),

ExprKind::Array(args)
| ExprKind::Tup(args)
Expand All @@ -1857,7 +1857,7 @@ impl Expr<'_> {
..
},
args,
) => args.iter().all(|arg| arg.can_have_side_effects()),
) => args.iter().any(|arg| arg.can_have_side_effects()),
ExprKind::If(..)
| ExprKind::Match(..)
| ExprKind::MethodCall(..)
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Returns false if the coercion creates any obligations that result in
/// errors.
pub fn can_coerce(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> bool {
// FIXME(-Ztrait-solver=next): We need to structurally resolve both types here.
let source = self.resolve_vars_with_obligations(expr_ty);
debug!("coercion::can_with_predicates({:?} -> {:?})", source, target);

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
));
let expr = expr.peel_drop_temps();
let cause = self.misc(expr.span);
let expr_ty = self.resolve_vars_with_obligations(checked_ty);
let expr_ty = self.resolve_vars_if_possible(checked_ty);
let mut err = self.err_ctxt().report_mismatched_types(&cause, expected, expr_ty, e);

let is_insufficiently_polymorphic =
Expand Down
14 changes: 3 additions & 11 deletions compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// to get more type information.
// FIXME(-Ztrait-solver=next): A lot of the calls to this method should
// probably be `try_structurally_resolve_type` or `structurally_resolve_type` instead.
pub(in super::super) fn resolve_vars_with_obligations(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
self.resolve_vars_with_obligations_and_mutate_fulfillment(ty, |_| {})
}

#[instrument(skip(self, mutate_fulfillment_errors), level = "debug", ret)]
pub(in super::super) fn resolve_vars_with_obligations_and_mutate_fulfillment(
&self,
mut ty: Ty<'tcx>,
mutate_fulfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
) -> Ty<'tcx> {
#[instrument(skip(self), level = "debug", ret)]
pub(in super::super) fn resolve_vars_with_obligations(&self, mut ty: Ty<'tcx>) -> Ty<'tcx> {
// No Infer()? Nothing needs doing.
if !ty.has_non_region_infer() {
debug!("no inference var, nothing needs doing");
Expand All @@ -112,7 +104,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// possible. This can help substantially when there are
// indirect dependencies that don't seem worth tracking
// precisely.
self.select_obligations_where_possible(mutate_fulfillment_errors);
self.select_obligations_where_possible(|_| {});
self.resolve_vars_if_possible(ty)
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if !expected.is_unit() {
return;
}
let found = self.resolve_vars_with_obligations(found);
let found = self.resolve_vars_if_possible(found);

let in_loop = self.is_loop(id)
|| self
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2994,7 +2994,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// This occurs for UFCS desugaring of `T::method`, where there is no
// receiver expression for the method call, and thus no autoderef.
if let SelfSource::QPath(_) = source {
return is_local(self.resolve_vars_with_obligations(rcvr_ty));
return is_local(rcvr_ty);
}

self.autoderef(span, rcvr_ty).any(|(ty, _)| is_local(ty))
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ fn needs_codegen_config(run: &RunConfig<'_>) -> bool {
needs_codegen_cfg
}

const CODEGEN_BACKEND_PREFIX: &str = "rustc_codegen_";
pub(crate) const CODEGEN_BACKEND_PREFIX: &str = "rustc_codegen_";

fn is_codegen_cfg_needed(path: &TaskPath, run: &RunConfig<'_>) -> bool {
if path.path.to_str().unwrap().contains(&CODEGEN_BACKEND_PREFIX) {
Expand Down
18 changes: 16 additions & 2 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::str::FromStr;
use crate::cache::{Interned, INTERNER};
use crate::cc_detect::{ndk_compiler, Language};
use crate::channel::{self, GitInfo};
use crate::compile::CODEGEN_BACKEND_PREFIX;
pub use crate::flags::Subcommand;
use crate::flags::{Color, Flags, Warnings};
use crate::util::{exe, output, t};
Expand Down Expand Up @@ -1443,8 +1444,21 @@ impl Config {
.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"));

if let Some(ref backends) = rust.codegen_backends {
config.rust_codegen_backends =
backends.iter().map(|s| INTERNER.intern_str(s)).collect();
let available_backends = vec!["llvm", "cranelift", "gcc"];

config.rust_codegen_backends = backends.iter().map(|s| {
if let Some(backend) = s.strip_prefix(CODEGEN_BACKEND_PREFIX) {
if available_backends.contains(&backend) {
panic!("Invalid value '{s}' for 'rust.codegen-backends'. Instead, please use '{backend}'.");
} else {
println!("help: '{s}' for 'rust.codegen-backends' might fail. \
Codegen backends are mostly defined without the '{CODEGEN_BACKEND_PREFIX}' prefix. \
In this case, it would be referred to as '{backend}'.");
}
}

INTERNER.intern_str(s)
}).collect();
}

config.rust_codegen_units = rust.codegen_units.map(threads_from_config);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `profile-sample-use
# `profile-sample-use`

---

Expand Down
1 change: 0 additions & 1 deletion tests/ui/async-await/in-trait/return-type-suggestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ trait A {
async fn e() {
Ok(())
//~^ ERROR mismatched types
//~| HELP consider using a semicolon here
}
}

Expand Down
4 changes: 1 addition & 3 deletions tests/ui/async-await/in-trait/return-type-suggestion.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ error[E0308]: mismatched types
--> $DIR/return-type-suggestion.rs:7:9
|
LL | Ok(())
| ^^^^^^- help: consider using a semicolon here: `;`
| |
| expected `()`, found `Result<(), _>`
| ^^^^^^ expected `()`, found `Result<(), _>`
|
= note: expected unit type `()`
found enum `Result<(), _>`
Expand Down
24 changes: 24 additions & 0 deletions tests/ui/return/return-struct.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
struct S;

enum Age {
Years(i64, i64)
}

fn foo() {
let mut age = 29;
Age::Years({age += 1; age}, 55)
//~^ ERROR mismatched types
}

fn bar() {
let mut age = 29;
Age::Years(age, 55)
//~^ ERROR mismatched types
}

fn baz() {
S
//~^ ERROR mismatched types
}

fn main() {}
35 changes: 35 additions & 0 deletions tests/ui/return/return-struct.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
error[E0308]: mismatched types
--> $DIR/return-struct.rs:9:5
|
LL | Age::Years({age += 1; age}, 55)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Age`
|
help: consider using a semicolon here
|
LL | Age::Years({age += 1; age}, 55);
| +
help: try adding a return type
|
LL | fn foo() -> Age {
| ++++++

error[E0308]: mismatched types
--> $DIR/return-struct.rs:15:5
|
LL | fn bar() {
| - help: try adding a return type: `-> Age`
LL | let mut age = 29;
LL | Age::Years(age, 55)
| ^^^^^^^^^^^^^^^^^^^ expected `()`, found `Age`

error[E0308]: mismatched types
--> $DIR/return-struct.rs:20:5
|
LL | fn baz() {
| - help: try adding a return type: `-> S`
LL | S
| ^ expected `()`, found `S`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0308`.
2 changes: 1 addition & 1 deletion triagebot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ cc = ["@nnethercote"]
[assign]
warn_non_default_branch = true
contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"
users_on_vacation = ["jyn514", "WaffleLapkin"]
users_on_vacation = ["jyn514", "WaffleLapkin", "clubby789"]

[assign.adhoc_groups]
compiler-team = [
Expand Down
Loading