Skip to content

Commit 754f6d4

Browse files
committed
Auto merge of #106892 - matthiaskrgr:rollup-ohneu8o, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #106072 (fix: misleading "add dyn keyword before derive macro" suggestion) - #106859 (Suggestion for type mismatch when we need a u8 but the programmer wrote a char literal) - #106863 (Remove various double spaces in compiler source comments.) - #106865 (Add explanation comment for GUI test) - #106867 (Fix the stability attributes for `std::os::fd`.) - #106878 (Add regression test for #92157) - #106879 (Add regression test for #42114) - #106880 (doc: fix typo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents afaf3e0 + cdf4622 commit 754f6d4

File tree

22 files changed

+205
-15
lines changed

22 files changed

+205
-15
lines changed

compiler/rustc_abi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ pub enum FieldsShape {
11001100
/// named `inverse_memory_index`.
11011101
///
11021102
// FIXME(eddyb) build a better abstraction for permutations, if possible.
1103-
// FIXME(camlorn) also consider small vector optimization here.
1103+
// FIXME(camlorn) also consider small vector optimization here.
11041104
memory_index: Vec<u32>,
11051105
},
11061106
}

compiler/rustc_borrowck/src/places_conflict.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ fn place_components_conflict<'tcx>(
209209
match (elem, &base_ty.kind(), access) {
210210
(_, _, Shallow(Some(ArtificialField::ArrayLength)))
211211
| (_, _, Shallow(Some(ArtificialField::ShallowBorrow))) => {
212-
// The array length is like additional fields on the
212+
// The array length is like additional fields on the
213213
// type; it does not overlap any existing data there.
214214
// Furthermore, if cannot actually be a prefix of any
215215
// borrowed place (at least in MIR as it is currently.)

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
235235
/// # Parameters
236236
///
237237
/// - `def_id`, the `impl Trait` type
238-
/// - `substs`, the substs used to instantiate this opaque type
238+
/// - `substs`, the substs used to instantiate this opaque type
239239
/// - `instantiated_ty`, the inferred type C1 -- fully resolved, lifted version of
240240
/// `opaque_defn.concrete_ty`
241241
#[instrument(level = "debug", skip(self))]

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3305,7 +3305,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
33053305
let label = "add `dyn` keyword before this trait";
33063306
let mut diag =
33073307
rustc_errors::struct_span_err!(tcx.sess, self_ty.span, E0782, "{}", msg);
3308-
diag.multipart_suggestion_verbose(label, sugg, Applicability::MachineApplicable);
3308+
if self_ty.span.can_be_used_for_suggestions() {
3309+
diag.multipart_suggestion_verbose(
3310+
label,
3311+
sugg,
3312+
Applicability::MachineApplicable,
3313+
);
3314+
}
33093315
// check if the impl trait that we are considering is a impl of a local trait
33103316
self.maybe_lint_blanket_trait_impl(&self_ty, &mut diag);
33113317
diag.emit();

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
417417
// Named constants have to be equated with the value
418418
// being matched, so that's a read of the value being matched.
419419
//
420-
// FIXME: We don't actually reads for ZSTs.
420+
// FIXME: We don't actually reads for ZSTs.
421421
needs_to_be_read = true;
422422
}
423423
_ => {

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub type PickResult<'tcx> = Result<Pick<'tcx>, MethodError<'tcx>>;
232232
pub enum Mode {
233233
// An expression of the form `receiver.method_name(...)`.
234234
// Autoderefs are performed on `receiver`, lookup is done based on the
235-
// `self` argument of the method, and static methods aren't considered.
235+
// `self` argument of the method, and static methods aren't considered.
236236
MethodCall,
237237
// An expression of the form `Type::item` or `<T>::item`.
238238
// No autoderefs are performed, lookup is done based on the type each

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,6 +1923,22 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
19231923
(ty::Tuple(fields), _) => {
19241924
self.emit_tuple_wrap_err(&mut err, span, found, fields)
19251925
}
1926+
// If a byte was expected and the found expression is a char literal
1927+
// containing a single ASCII character, perhaps the user meant to write `b'c'` to
1928+
// specify a byte literal
1929+
(ty::Uint(ty::UintTy::U8), ty::Char) => {
1930+
if let Ok(code) = self.tcx.sess().source_map().span_to_snippet(span)
1931+
&& let Some(code) = code.strip_prefix('\'').and_then(|s| s.strip_suffix('\''))
1932+
&& code.chars().next().map_or(false, |c| c.is_ascii())
1933+
{
1934+
err.span_suggestion(
1935+
span,
1936+
"if you meant to write a byte literal, prefix with `b`",
1937+
format!("b'{}'", escape_literal(code)),
1938+
Applicability::MachineApplicable,
1939+
);
1940+
}
1941+
}
19261942
// If a character was expected and the found expression is a string literal
19271943
// containing a single character, perhaps the user meant to write `'c'` to
19281944
// specify a character literal (issue #92479)

compiler/rustc_middle/src/ty/typeck_results.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub struct TypeckResults<'tcx> {
193193
pub generator_interior_types: ty::Binder<'tcx, Vec<GeneratorInteriorTypeCause<'tcx>>>,
194194

195195
/// We sometimes treat byte string literals (which are of type `&[u8; N]`)
196-
/// as `&[u8]`, depending on the pattern in which they are used.
196+
/// as `&[u8]`, depending on the pattern in which they are used.
197197
/// This hashset records all instances where we behave
198198
/// like this to allow `const_to_pat` to reliably handle this situation.
199199
pub treat_byte_string_as_slice: ItemLocalSet,

compiler/rustc_parse/src/parser/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ impl<'a> Parser<'a> {
469469
/// Try to recover the more general form `intersect ::= $pat_lhs @ $pat_rhs`.
470470
///
471471
/// Allowed binding patterns generated by `binding ::= ref? mut? $ident @ $pat_rhs`
472-
/// should already have been parsed by now at this point,
472+
/// should already have been parsed by now at this point,
473473
/// if the next token is `@` then we can try to parse the more general form.
474474
///
475475
/// Consult `parse_pat_ident` for the `binding` grammar.

compiler/rustc_session/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2091,7 +2091,7 @@ fn parse_libs(matches: &getopts::Matches, error_format: ErrorOutputType) -> Vec<
20912091
.map(|s| {
20922092
// Parse string of the form "[KIND[:MODIFIERS]=]lib[:new_name]",
20932093
// where KIND is one of "dylib", "framework", "static", "link-arg" and
2094-
// where MODIFIERS are a comma separated list of supported modifiers
2094+
// where MODIFIERS are a comma separated list of supported modifiers
20952095
// (bundle, verbatim, whole-archive, as-needed). Each modifier is prefixed
20962096
// with either + or - to indicate whether it is enabled or disabled.
20972097
// The last value specified for a given modifier wins.

0 commit comments

Comments
 (0)