Skip to content

Commit faee636

Browse files
committed
Auto merge of rust-lang#114697 - matthiaskrgr:rollup-ywooy8x, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#114278 (better error handling for `rust.codegen-backends` on deserialization) - rust-lang#114674 (Add clubby789 to `users_on_vacation`) - rust-lang#114678 (`Expr::can_have_side_effects()` is incorrect for struct/enum/array/tuple literals) - rust-lang#114681 (doc (unstable-book): fix a typo) - rust-lang#114684 (Remove redundant calls to `resolve_vars_with_obligations`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9fa6bdd + 5f0d585 commit faee636

File tree

14 files changed

+88
-25
lines changed

14 files changed

+88
-25
lines changed

compiler/rustc_hir/src/hir.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1843,7 +1843,7 @@ impl Expr<'_> {
18431843
.iter()
18441844
.map(|field| field.expr)
18451845
.chain(init.into_iter())
1846-
.all(|e| e.can_have_side_effects()),
1846+
.any(|e| e.can_have_side_effects()),
18471847

18481848
ExprKind::Array(args)
18491849
| ExprKind::Tup(args)
@@ -1857,7 +1857,7 @@ impl Expr<'_> {
18571857
..
18581858
},
18591859
args,
1860-
) => args.iter().all(|arg| arg.can_have_side_effects()),
1860+
) => args.iter().any(|arg| arg.can_have_side_effects()),
18611861
ExprKind::If(..)
18621862
| ExprKind::Match(..)
18631863
| ExprKind::MethodCall(..)

compiler/rustc_hir_typeck/src/coercion.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10391039
/// Returns false if the coercion creates any obligations that result in
10401040
/// errors.
10411041
pub fn can_coerce(&self, expr_ty: Ty<'tcx>, target: Ty<'tcx>) -> bool {
1042+
// FIXME(-Ztrait-solver=next): We need to structurally resolve both types here.
10421043
let source = self.resolve_vars_with_obligations(expr_ty);
10431044
debug!("coercion::can_with_predicates({:?} -> {:?})", source, target);
10441045

compiler/rustc_hir_typeck/src/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
260260
));
261261
let expr = expr.peel_drop_temps();
262262
let cause = self.misc(expr.span);
263-
let expr_ty = self.resolve_vars_with_obligations(checked_ty);
263+
let expr_ty = self.resolve_vars_if_possible(checked_ty);
264264
let mut err = self.err_ctxt().report_mismatched_types(&cause, expected, expr_ty, e);
265265

266266
let is_insufficiently_polymorphic =

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8585
/// to get more type information.
8686
// FIXME(-Ztrait-solver=next): A lot of the calls to this method should
8787
// probably be `try_structurally_resolve_type` or `structurally_resolve_type` instead.
88-
pub(in super::super) fn resolve_vars_with_obligations(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
89-
self.resolve_vars_with_obligations_and_mutate_fulfillment(ty, |_| {})
90-
}
91-
92-
#[instrument(skip(self, mutate_fulfillment_errors), level = "debug", ret)]
93-
pub(in super::super) fn resolve_vars_with_obligations_and_mutate_fulfillment(
94-
&self,
95-
mut ty: Ty<'tcx>,
96-
mutate_fulfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
97-
) -> Ty<'tcx> {
88+
#[instrument(skip(self), level = "debug", ret)]
89+
pub(in super::super) fn resolve_vars_with_obligations(&self, mut ty: Ty<'tcx>) -> Ty<'tcx> {
9890
// No Infer()? Nothing needs doing.
9991
if !ty.has_non_region_infer() {
10092
debug!("no inference var, nothing needs doing");
@@ -112,7 +104,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
112104
// possible. This can help substantially when there are
113105
// indirect dependencies that don't seem worth tracking
114106
// precisely.
115-
self.select_obligations_where_possible(mutate_fulfillment_errors);
107+
self.select_obligations_where_possible(|_| {});
116108
self.resolve_vars_if_possible(ty)
117109
}
118110

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
950950
if !expected.is_unit() {
951951
return;
952952
}
953-
let found = self.resolve_vars_with_obligations(found);
953+
let found = self.resolve_vars_if_possible(found);
954954

955955
let in_loop = self.is_loop(id)
956956
|| self

compiler/rustc_hir_typeck/src/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2994,7 +2994,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29942994
// This occurs for UFCS desugaring of `T::method`, where there is no
29952995
// receiver expression for the method call, and thus no autoderef.
29962996
if let SelfSource::QPath(_) = source {
2997-
return is_local(self.resolve_vars_with_obligations(rcvr_ty));
2997+
return is_local(rcvr_ty);
29982998
}
29992999

30003000
self.autoderef(span, rcvr_ty).any(|(ty, _)| is_local(ty))

src/bootstrap/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ fn needs_codegen_config(run: &RunConfig<'_>) -> bool {
11291129
needs_codegen_cfg
11301130
}
11311131

1132-
const CODEGEN_BACKEND_PREFIX: &str = "rustc_codegen_";
1132+
pub(crate) const CODEGEN_BACKEND_PREFIX: &str = "rustc_codegen_";
11331133

11341134
fn is_codegen_cfg_needed(path: &TaskPath, run: &RunConfig<'_>) -> bool {
11351135
if path.path.to_str().unwrap().contains(&CODEGEN_BACKEND_PREFIX) {

src/bootstrap/config.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use std::str::FromStr;
2020
use crate::cache::{Interned, INTERNER};
2121
use crate::cc_detect::{ndk_compiler, Language};
2222
use crate::channel::{self, GitInfo};
23+
use crate::compile::CODEGEN_BACKEND_PREFIX;
2324
pub use crate::flags::Subcommand;
2425
use crate::flags::{Color, Flags, Warnings};
2526
use crate::util::{exe, output, t};
@@ -1443,8 +1444,21 @@ impl Config {
14431444
.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"));
14441445

14451446
if let Some(ref backends) = rust.codegen_backends {
1446-
config.rust_codegen_backends =
1447-
backends.iter().map(|s| INTERNER.intern_str(s)).collect();
1447+
let available_backends = vec!["llvm", "cranelift", "gcc"];
1448+
1449+
config.rust_codegen_backends = backends.iter().map(|s| {
1450+
if let Some(backend) = s.strip_prefix(CODEGEN_BACKEND_PREFIX) {
1451+
if available_backends.contains(&backend) {
1452+
panic!("Invalid value '{s}' for 'rust.codegen-backends'. Instead, please use '{backend}'.");
1453+
} else {
1454+
println!("help: '{s}' for 'rust.codegen-backends' might fail. \
1455+
Codegen backends are mostly defined without the '{CODEGEN_BACKEND_PREFIX}' prefix. \
1456+
In this case, it would be referred to as '{backend}'.");
1457+
}
1458+
}
1459+
1460+
INTERNER.intern_str(s)
1461+
}).collect();
14481462
}
14491463

14501464
config.rust_codegen_units = rust.codegen_units.map(threads_from_config);

src/doc/unstable-book/src/compiler-flags/profile_sample_use.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `profile-sample-use
1+
# `profile-sample-use`
22

33
---
44

tests/ui/async-await/in-trait/return-type-suggestion.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ trait A {
66
async fn e() {
77
Ok(())
88
//~^ ERROR mismatched types
9-
//~| HELP consider using a semicolon here
109
}
1110
}
1211

tests/ui/async-await/in-trait/return-type-suggestion.stderr

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/return-type-suggestion.rs:7:9
33
|
44
LL | Ok(())
5-
| ^^^^^^- help: consider using a semicolon here: `;`
6-
| |
7-
| expected `()`, found `Result<(), _>`
5+
| ^^^^^^ expected `()`, found `Result<(), _>`
86
|
97
= note: expected unit type `()`
108
found enum `Result<(), _>`

tests/ui/return/return-struct.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
struct S;
2+
3+
enum Age {
4+
Years(i64, i64)
5+
}
6+
7+
fn foo() {
8+
let mut age = 29;
9+
Age::Years({age += 1; age}, 55)
10+
//~^ ERROR mismatched types
11+
}
12+
13+
fn bar() {
14+
let mut age = 29;
15+
Age::Years(age, 55)
16+
//~^ ERROR mismatched types
17+
}
18+
19+
fn baz() {
20+
S
21+
//~^ ERROR mismatched types
22+
}
23+
24+
fn main() {}

tests/ui/return/return-struct.stderr

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/return-struct.rs:9:5
3+
|
4+
LL | Age::Years({age += 1; age}, 55)
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Age`
6+
|
7+
help: consider using a semicolon here
8+
|
9+
LL | Age::Years({age += 1; age}, 55);
10+
| +
11+
help: try adding a return type
12+
|
13+
LL | fn foo() -> Age {
14+
| ++++++
15+
16+
error[E0308]: mismatched types
17+
--> $DIR/return-struct.rs:15:5
18+
|
19+
LL | fn bar() {
20+
| - help: try adding a return type: `-> Age`
21+
LL | let mut age = 29;
22+
LL | Age::Years(age, 55)
23+
| ^^^^^^^^^^^^^^^^^^^ expected `()`, found `Age`
24+
25+
error[E0308]: mismatched types
26+
--> $DIR/return-struct.rs:20:5
27+
|
28+
LL | fn baz() {
29+
| - help: try adding a return type: `-> S`
30+
LL | S
31+
| ^ expected `()`, found `S`
32+
33+
error: aborting due to 3 previous errors
34+
35+
For more information about this error, try `rustc --explain E0308`.

triagebot.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ cc = ["@nnethercote"]
490490
[assign]
491491
warn_non_default_branch = true
492492
contributing_url = "https://rustc-dev-guide.rust-lang.org/getting-started.html"
493-
users_on_vacation = ["jyn514", "WaffleLapkin"]
493+
users_on_vacation = ["jyn514", "WaffleLapkin", "clubby789"]
494494

495495
[assign.adhoc_groups]
496496
compiler-team = [

0 commit comments

Comments
 (0)