Rollup merge of #134956 - compiler-errors:format-args-hidden-chars, r=jieyouxu
Account for C string literals and `format_args` in `HiddenUnicodeCodepoints` lint This is stacked on #134955, and either that can land first or both of them can land together here. I split this out because this is a bit more involved of an impl. Fixes #94945
This commit is contained in:
commit
0c94f631d8
9 changed files with 157 additions and 42 deletions
|
@ -4,6 +4,7 @@ use rustc_span::{Ident, Span, Symbol};
|
||||||
|
|
||||||
use crate::Expr;
|
use crate::Expr;
|
||||||
use crate::ptr::P;
|
use crate::ptr::P;
|
||||||
|
use crate::token::LitKind;
|
||||||
|
|
||||||
// Definitions:
|
// Definitions:
|
||||||
//
|
//
|
||||||
|
@ -45,6 +46,10 @@ pub struct FormatArgs {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub template: Vec<FormatArgsPiece>,
|
pub template: Vec<FormatArgsPiece>,
|
||||||
pub arguments: FormatArguments,
|
pub arguments: FormatArguments,
|
||||||
|
/// The raw, un-split format string literal, with no escaping or processing.
|
||||||
|
///
|
||||||
|
/// Generally only useful for lints that care about the raw bytes the user wrote.
|
||||||
|
pub uncooked_fmt_str: (LitKind, Symbol),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A piece of a format template string.
|
/// A piece of a format template string.
|
||||||
|
|
|
@ -1596,7 +1596,7 @@ fn walk_inline_asm_sym<T: MutVisitor>(
|
||||||
|
|
||||||
fn walk_format_args<T: MutVisitor>(vis: &mut T, fmt: &mut FormatArgs) {
|
fn walk_format_args<T: MutVisitor>(vis: &mut T, fmt: &mut FormatArgs) {
|
||||||
// FIXME: visit the template exhaustively.
|
// FIXME: visit the template exhaustively.
|
||||||
let FormatArgs { span, template: _, arguments } = fmt;
|
let FormatArgs { span, template: _, arguments, uncooked_fmt_str: _ } = fmt;
|
||||||
for FormatArgument { kind, expr } in arguments.all_args_mut() {
|
for FormatArgument { kind, expr } in arguments.all_args_mut() {
|
||||||
match kind {
|
match kind {
|
||||||
FormatArgumentKind::Named(ident) | FormatArgumentKind::Captured(ident) => {
|
FormatArgumentKind::Named(ident) | FormatArgumentKind::Captured(ident) => {
|
||||||
|
|
|
@ -1061,7 +1061,7 @@ pub fn walk_inline_asm_sym<'a, V: Visitor<'a>>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn walk_format_args<'a, V: Visitor<'a>>(visitor: &mut V, fmt: &'a FormatArgs) -> V::Result {
|
pub fn walk_format_args<'a, V: Visitor<'a>>(visitor: &mut V, fmt: &'a FormatArgs) -> V::Result {
|
||||||
let FormatArgs { span: _, template: _, arguments } = fmt;
|
let FormatArgs { span: _, template: _, arguments, uncooked_fmt_str: _ } = fmt;
|
||||||
for FormatArgument { kind, expr } in arguments.all_args() {
|
for FormatArgument { kind, expr } in arguments.all_args() {
|
||||||
match kind {
|
match kind {
|
||||||
FormatArgumentKind::Named(ident) | FormatArgumentKind::Captured(ident) => {
|
FormatArgumentKind::Named(ident) | FormatArgumentKind::Captured(ident) => {
|
||||||
|
|
|
@ -16,7 +16,7 @@ use smallvec::smallvec;
|
||||||
use {rustc_ast as ast, rustc_parse_format as parse};
|
use {rustc_ast as ast, rustc_parse_format as parse};
|
||||||
|
|
||||||
use crate::errors;
|
use crate::errors;
|
||||||
use crate::util::expr_to_spanned_string;
|
use crate::util::{ExprToSpannedString, expr_to_spanned_string};
|
||||||
|
|
||||||
pub struct AsmArgs {
|
pub struct AsmArgs {
|
||||||
pub templates: Vec<P<ast::Expr>>,
|
pub templates: Vec<P<ast::Expr>>,
|
||||||
|
@ -527,7 +527,12 @@ fn expand_preparsed_asm(
|
||||||
let msg = "asm template must be a string literal";
|
let msg = "asm template must be a string literal";
|
||||||
let template_sp = template_expr.span;
|
let template_sp = template_expr.span;
|
||||||
let template_is_mac_call = matches!(template_expr.kind, ast::ExprKind::MacCall(_));
|
let template_is_mac_call = matches!(template_expr.kind, ast::ExprKind::MacCall(_));
|
||||||
let (template_str, template_style, template_span) = {
|
let ExprToSpannedString {
|
||||||
|
symbol: template_str,
|
||||||
|
style: template_style,
|
||||||
|
span: template_span,
|
||||||
|
..
|
||||||
|
} = {
|
||||||
let ExpandResult::Ready(mac) = expr_to_spanned_string(ecx, template_expr, msg) else {
|
let ExpandResult::Ready(mac) = expr_to_spanned_string(ecx, template_expr, msg) else {
|
||||||
return ExpandResult::Retry(());
|
return ExpandResult::Retry(());
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,7 +17,7 @@ use rustc_parse_format as parse;
|
||||||
use rustc_span::{BytePos, ErrorGuaranteed, Ident, InnerSpan, Span, Symbol};
|
use rustc_span::{BytePos, ErrorGuaranteed, Ident, InnerSpan, Span, Symbol};
|
||||||
|
|
||||||
use crate::errors;
|
use crate::errors;
|
||||||
use crate::util::expr_to_spanned_string;
|
use crate::util::{ExprToSpannedString, expr_to_spanned_string};
|
||||||
|
|
||||||
// The format_args!() macro is expanded in three steps:
|
// The format_args!() macro is expanded in three steps:
|
||||||
// 1. First, `parse_args` will parse the `(literal, arg, arg, name=arg, name=arg)` syntax,
|
// 1. First, `parse_args` will parse the `(literal, arg, arg, name=arg, name=arg)` syntax,
|
||||||
|
@ -166,13 +166,18 @@ fn make_format_args(
|
||||||
|
|
||||||
let MacroInput { fmtstr: efmt, mut args, is_direct_literal } = input;
|
let MacroInput { fmtstr: efmt, mut args, is_direct_literal } = input;
|
||||||
|
|
||||||
let (fmt_str, fmt_style, fmt_span) = {
|
let ExprToSpannedString {
|
||||||
|
symbol: fmt_str,
|
||||||
|
span: fmt_span,
|
||||||
|
style: fmt_style,
|
||||||
|
uncooked_symbol: uncooked_fmt_str,
|
||||||
|
} = {
|
||||||
let ExpandResult::Ready(mac) = expr_to_spanned_string(ecx, efmt.clone(), msg) else {
|
let ExpandResult::Ready(mac) = expr_to_spanned_string(ecx, efmt.clone(), msg) else {
|
||||||
return ExpandResult::Retry(());
|
return ExpandResult::Retry(());
|
||||||
};
|
};
|
||||||
match mac {
|
match mac {
|
||||||
Ok(mut fmt) if append_newline => {
|
Ok(mut fmt) if append_newline => {
|
||||||
fmt.0 = Symbol::intern(&format!("{}\n", fmt.0));
|
fmt.symbol = Symbol::intern(&format!("{}\n", fmt.symbol));
|
||||||
fmt
|
fmt
|
||||||
}
|
}
|
||||||
Ok(fmt) => fmt,
|
Ok(fmt) => fmt,
|
||||||
|
@ -584,7 +589,12 @@ fn make_format_args(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpandResult::Ready(Ok(FormatArgs { span: fmt_span, template, arguments: args }))
|
ExpandResult::Ready(Ok(FormatArgs {
|
||||||
|
span: fmt_span,
|
||||||
|
template,
|
||||||
|
arguments: args,
|
||||||
|
uncooked_fmt_str,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn invalid_placeholder_type_error(
|
fn invalid_placeholder_type_error(
|
||||||
|
|
|
@ -57,7 +57,17 @@ pub(crate) fn warn_on_duplicate_attribute(ecx: &ExtCtxt<'_>, item: &Annotatable,
|
||||||
|
|
||||||
/// `Ok` represents successfully retrieving the string literal at the correct
|
/// `Ok` represents successfully retrieving the string literal at the correct
|
||||||
/// position, e.g., `println("abc")`.
|
/// position, e.g., `println("abc")`.
|
||||||
type ExprToSpannedStringResult<'a> = Result<(Symbol, ast::StrStyle, Span), UnexpectedExprKind<'a>>;
|
pub(crate) type ExprToSpannedStringResult<'a> = Result<ExprToSpannedString, UnexpectedExprKind<'a>>;
|
||||||
|
|
||||||
|
pub(crate) struct ExprToSpannedString {
|
||||||
|
pub symbol: Symbol,
|
||||||
|
pub style: ast::StrStyle,
|
||||||
|
pub span: Span,
|
||||||
|
/// The raw string literal, with no escaping or processing.
|
||||||
|
///
|
||||||
|
/// Generally only useful for lints that care about the raw bytes the user wrote.
|
||||||
|
pub uncooked_symbol: (ast::token::LitKind, Symbol),
|
||||||
|
}
|
||||||
|
|
||||||
/// - `Ok` is returned when the conversion to a string literal is unsuccessful,
|
/// - `Ok` is returned when the conversion to a string literal is unsuccessful,
|
||||||
/// but another type of expression is obtained instead.
|
/// but another type of expression is obtained instead.
|
||||||
|
@ -90,7 +100,12 @@ pub(crate) fn expr_to_spanned_string<'a>(
|
||||||
ExpandResult::Ready(Err(match expr.kind {
|
ExpandResult::Ready(Err(match expr.kind {
|
||||||
ast::ExprKind::Lit(token_lit) => match ast::LitKind::from_token_lit(token_lit) {
|
ast::ExprKind::Lit(token_lit) => match ast::LitKind::from_token_lit(token_lit) {
|
||||||
Ok(ast::LitKind::Str(s, style)) => {
|
Ok(ast::LitKind::Str(s, style)) => {
|
||||||
return ExpandResult::Ready(Ok((s, style, expr.span)));
|
return ExpandResult::Ready(Ok(ExprToSpannedString {
|
||||||
|
symbol: s,
|
||||||
|
style,
|
||||||
|
span: expr.span,
|
||||||
|
uncooked_symbol: (token_lit.kind, token_lit.symbol),
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
Ok(ast::LitKind::ByteStr(..)) => {
|
Ok(ast::LitKind::ByteStr(..)) => {
|
||||||
let mut err = cx.dcx().struct_span_err(expr.span, err_msg);
|
let mut err = cx.dcx().struct_span_err(expr.span, err_msg);
|
||||||
|
@ -128,7 +143,7 @@ pub(crate) fn expr_to_string(
|
||||||
Ok((err, _)) => err.emit(),
|
Ok((err, _)) => err.emit(),
|
||||||
Err(guar) => guar,
|
Err(guar) => guar,
|
||||||
})
|
})
|
||||||
.map(|(symbol, style, _)| (symbol, style))
|
.map(|ExprToSpannedString { symbol, style, .. }| (symbol, style))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +198,7 @@ pub(crate) fn get_single_str_spanned_from_tts(
|
||||||
Ok((err, _)) => err.emit(),
|
Ok((err, _)) => err.emit(),
|
||||||
Err(guar) => guar,
|
Err(guar) => guar,
|
||||||
})
|
})
|
||||||
.map(|(symbol, _style, span)| (symbol, span))
|
.map(|ExprToSpannedString { symbol, span, .. }| (symbol, span))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,36 @@ impl HiddenUnicodeCodepoints {
|
||||||
sub,
|
sub,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn check_literal(
|
||||||
|
&mut self,
|
||||||
|
cx: &EarlyContext<'_>,
|
||||||
|
text: Symbol,
|
||||||
|
lit_kind: ast::token::LitKind,
|
||||||
|
span: Span,
|
||||||
|
label: &'static str,
|
||||||
|
) {
|
||||||
|
if !contains_text_flow_control_chars(text.as_str()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let (padding, point_at_inner_spans) = match lit_kind {
|
||||||
|
// account for `"` or `'`
|
||||||
|
ast::token::LitKind::Str | ast::token::LitKind::Char => (1, true),
|
||||||
|
// account for `c"`
|
||||||
|
ast::token::LitKind::CStr => (2, true),
|
||||||
|
// account for `r###"`
|
||||||
|
ast::token::LitKind::StrRaw(n) => (n as u32 + 2, true),
|
||||||
|
// account for `cr###"`
|
||||||
|
ast::token::LitKind::CStrRaw(n) => (n as u32 + 3, true),
|
||||||
|
// suppress bad literals.
|
||||||
|
ast::token::LitKind::Err(_) => return,
|
||||||
|
// Be conservative just in case new literals do support these.
|
||||||
|
_ => (0, false),
|
||||||
|
};
|
||||||
|
self.lint_text_direction_codepoint(cx, text, span, padding, point_at_inner_spans, label);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EarlyLintPass for HiddenUnicodeCodepoints {
|
impl EarlyLintPass for HiddenUnicodeCodepoints {
|
||||||
fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &ast::Attribute) {
|
fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &ast::Attribute) {
|
||||||
if let ast::AttrKind::DocComment(_, comment) = attr.kind {
|
if let ast::AttrKind::DocComment(_, comment) = attr.kind {
|
||||||
|
@ -97,18 +126,11 @@ impl EarlyLintPass for HiddenUnicodeCodepoints {
|
||||||
// byte strings are already handled well enough by `EscapeError::NonAsciiCharInByteString`
|
// byte strings are already handled well enough by `EscapeError::NonAsciiCharInByteString`
|
||||||
match &expr.kind {
|
match &expr.kind {
|
||||||
ast::ExprKind::Lit(token_lit) => {
|
ast::ExprKind::Lit(token_lit) => {
|
||||||
let text = token_lit.symbol;
|
self.check_literal(cx, token_lit.symbol, token_lit.kind, expr.span, "literal");
|
||||||
if !contains_text_flow_control_chars(text.as_str()) {
|
}
|
||||||
return;
|
ast::ExprKind::FormatArgs(args) => {
|
||||||
}
|
let (lit_kind, text) = args.uncooked_fmt_str;
|
||||||
let padding = match token_lit.kind {
|
self.check_literal(cx, text, lit_kind, args.span, "format string");
|
||||||
// account for `"` or `'`
|
|
||||||
ast::token::LitKind::Str | ast::token::LitKind::Char => 1,
|
|
||||||
// account for `r###"`
|
|
||||||
ast::token::LitKind::StrRaw(n) => n as u32 + 2,
|
|
||||||
_ => return,
|
|
||||||
};
|
|
||||||
self.lint_text_direction_codepoint(cx, text, expr.span, padding, true, "literal");
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//@ edition: 2021
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// if access_level != "user" { // Check if admin
|
// if access_level != "user" { // Check if admin
|
||||||
//~^ ERROR unicode codepoint changing visible direction of text present in comment
|
//~^ ERROR unicode codepoint changing visible direction of text present in comment
|
||||||
|
@ -25,6 +27,14 @@ fn main() {
|
||||||
//~| ERROR non-ASCII character in raw byte string literal
|
//~| ERROR non-ASCII character in raw byte string literal
|
||||||
println!("{:?}", '');
|
println!("{:?}", '');
|
||||||
//~^ ERROR unicode codepoint changing visible direction of text present in literal
|
//~^ ERROR unicode codepoint changing visible direction of text present in literal
|
||||||
|
|
||||||
|
let _ = c"";
|
||||||
|
//~^ ERROR unicode codepoint changing visible direction of text present in literal
|
||||||
|
let _ = cr#""#;
|
||||||
|
//~^ ERROR unicode codepoint changing visible direction of text present in literal
|
||||||
|
|
||||||
|
println!("{{}}");
|
||||||
|
//~^ ERROR unicode codepoint changing visible direction of text present in format string
|
||||||
}
|
}
|
||||||
|
|
||||||
//"/* } if isAdmin begin admins only */"
|
//"/* } if isAdmin begin admins only */"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error: unicode escape in byte string
|
error: unicode escape in byte string
|
||||||
--> $DIR/unicode-control-codepoints.rs:6:26
|
--> $DIR/unicode-control-codepoints.rs:8:26
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", b"us\u{202B}e\u{202A}r");
|
LL | println!("{:?}", b"us\u{202B}e\u{202A}r");
|
||||||
| ^^^^^^^^ unicode escape in byte string
|
| ^^^^^^^^ unicode escape in byte string
|
||||||
|
@ -7,7 +7,7 @@ LL | println!("{:?}", b"us\u{202B}e\u{202A}r");
|
||||||
= help: unicode escape sequences cannot be used as a byte or in a byte string
|
= help: unicode escape sequences cannot be used as a byte or in a byte string
|
||||||
|
|
||||||
error: unicode escape in byte string
|
error: unicode escape in byte string
|
||||||
--> $DIR/unicode-control-codepoints.rs:6:35
|
--> $DIR/unicode-control-codepoints.rs:8:35
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", b"us\u{202B}e\u{202A}r");
|
LL | println!("{:?}", b"us\u{202B}e\u{202A}r");
|
||||||
| ^^^^^^^^ unicode escape in byte string
|
| ^^^^^^^^ unicode escape in byte string
|
||||||
|
@ -15,7 +15,7 @@ LL | println!("{:?}", b"us\u{202B}e\u{202A}r");
|
||||||
= help: unicode escape sequences cannot be used as a byte or in a byte string
|
= help: unicode escape sequences cannot be used as a byte or in a byte string
|
||||||
|
|
||||||
error: non-ASCII character in byte string literal
|
error: non-ASCII character in byte string literal
|
||||||
--> $DIR/unicode-control-codepoints.rs:16:26
|
--> $DIR/unicode-control-codepoints.rs:18:26
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", b"/*<2A> } <20>if isAdmin<69> <20> begin admins only ");
|
LL | println!("{:?}", b"/*<2A> } <20>if isAdmin<69> <20> begin admins only ");
|
||||||
| ^ must be ASCII but is '\u{202e}'
|
| ^ must be ASCII but is '\u{202e}'
|
||||||
|
@ -26,7 +26,7 @@ LL | println!("{:?}", b"/*\xE2\x80\xAE } <20>if isAdmin<69> <20> begin admins o
|
||||||
| ~~~~~~~~~~~~
|
| ~~~~~~~~~~~~
|
||||||
|
|
||||||
error: non-ASCII character in byte string literal
|
error: non-ASCII character in byte string literal
|
||||||
--> $DIR/unicode-control-codepoints.rs:16:30
|
--> $DIR/unicode-control-codepoints.rs:18:30
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", b"/*<2A> } <20>if isAdmin<69> <20> begin admins only ");
|
LL | println!("{:?}", b"/*<2A> } <20>if isAdmin<69> <20> begin admins only ");
|
||||||
| ^ must be ASCII but is '\u{2066}'
|
| ^ must be ASCII but is '\u{2066}'
|
||||||
|
@ -37,7 +37,7 @@ LL | println!("{:?}", b"/*<2A> } \xE2\x81\xA6if isAdmin<69> <20> begin admins o
|
||||||
| ~~~~~~~~~~~~
|
| ~~~~~~~~~~~~
|
||||||
|
|
||||||
error: non-ASCII character in byte string literal
|
error: non-ASCII character in byte string literal
|
||||||
--> $DIR/unicode-control-codepoints.rs:16:41
|
--> $DIR/unicode-control-codepoints.rs:18:41
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", b"/*<2A> } <20>if isAdmin<69> <20> begin admins only ");
|
LL | println!("{:?}", b"/*<2A> } <20>if isAdmin<69> <20> begin admins only ");
|
||||||
| ^ must be ASCII but is '\u{2069}'
|
| ^ must be ASCII but is '\u{2069}'
|
||||||
|
@ -48,7 +48,7 @@ LL | println!("{:?}", b"/*<2A> } <20>if isAdmin\xE2\x81\xA9 <20> begin admins o
|
||||||
| ~~~~~~~~~~~~
|
| ~~~~~~~~~~~~
|
||||||
|
|
||||||
error: non-ASCII character in byte string literal
|
error: non-ASCII character in byte string literal
|
||||||
--> $DIR/unicode-control-codepoints.rs:16:43
|
--> $DIR/unicode-control-codepoints.rs:18:43
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", b"/*<2A> } <20>if isAdmin<69> <20> begin admins only ");
|
LL | println!("{:?}", b"/*<2A> } <20>if isAdmin<69> <20> begin admins only ");
|
||||||
| ^ must be ASCII but is '\u{2066}'
|
| ^ must be ASCII but is '\u{2066}'
|
||||||
|
@ -59,31 +59,31 @@ LL | println!("{:?}", b"/*<2A> } <20>if isAdmin<69> \xE2\x81\xA6 begin admins o
|
||||||
| ~~~~~~~~~~~~
|
| ~~~~~~~~~~~~
|
||||||
|
|
||||||
error: non-ASCII character in raw byte string literal
|
error: non-ASCII character in raw byte string literal
|
||||||
--> $DIR/unicode-control-codepoints.rs:21:29
|
--> $DIR/unicode-control-codepoints.rs:23:29
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", br##"/*<2A> } <20>if isAdmin<69> <20> begin admins only "##);
|
LL | println!("{:?}", br##"/*<2A> } <20>if isAdmin<69> <20> begin admins only "##);
|
||||||
| ^ must be ASCII but is '\u{202e}'
|
| ^ must be ASCII but is '\u{202e}'
|
||||||
|
|
||||||
error: non-ASCII character in raw byte string literal
|
error: non-ASCII character in raw byte string literal
|
||||||
--> $DIR/unicode-control-codepoints.rs:21:33
|
--> $DIR/unicode-control-codepoints.rs:23:33
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", br##"/*<2A> } <20>if isAdmin<69> <20> begin admins only "##);
|
LL | println!("{:?}", br##"/*<2A> } <20>if isAdmin<69> <20> begin admins only "##);
|
||||||
| ^ must be ASCII but is '\u{2066}'
|
| ^ must be ASCII but is '\u{2066}'
|
||||||
|
|
||||||
error: non-ASCII character in raw byte string literal
|
error: non-ASCII character in raw byte string literal
|
||||||
--> $DIR/unicode-control-codepoints.rs:21:44
|
--> $DIR/unicode-control-codepoints.rs:23:44
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", br##"/*<2A> } <20>if isAdmin<69> <20> begin admins only "##);
|
LL | println!("{:?}", br##"/*<2A> } <20>if isAdmin<69> <20> begin admins only "##);
|
||||||
| ^ must be ASCII but is '\u{2069}'
|
| ^ must be ASCII but is '\u{2069}'
|
||||||
|
|
||||||
error: non-ASCII character in raw byte string literal
|
error: non-ASCII character in raw byte string literal
|
||||||
--> $DIR/unicode-control-codepoints.rs:21:46
|
--> $DIR/unicode-control-codepoints.rs:23:46
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", br##"/*<2A> } <20>if isAdmin<69> <20> begin admins only "##);
|
LL | println!("{:?}", br##"/*<2A> } <20>if isAdmin<69> <20> begin admins only "##);
|
||||||
| ^ must be ASCII but is '\u{2066}'
|
| ^ must be ASCII but is '\u{2066}'
|
||||||
|
|
||||||
error: unicode codepoint changing visible direction of text present in comment
|
error: unicode codepoint changing visible direction of text present in comment
|
||||||
--> $DIR/unicode-control-codepoints.rs:2:5
|
--> $DIR/unicode-control-codepoints.rs:4:5
|
||||||
|
|
|
|
||||||
LL | // if access_level != "us<75>e<EFBFBD>r" { // Check if admin
|
LL | // if access_level != "us<75>e<EFBFBD>r" { // Check if admin
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^-^-^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^-^-^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -97,7 +97,7 @@ LL | // if access_level != "us<75>e<EFBFBD>r" { // Check if admin
|
||||||
= help: if their presence wasn't intentional, you can remove them
|
= help: if their presence wasn't intentional, you can remove them
|
||||||
|
|
||||||
error: unicode codepoint changing visible direction of text present in comment
|
error: unicode codepoint changing visible direction of text present in comment
|
||||||
--> $DIR/unicode-control-codepoints.rs:30:1
|
--> $DIR/unicode-control-codepoints.rs:40:1
|
||||||
|
|
|
|
||||||
LL | //"/*<2A> } <20>if isAdmin<69> <20> begin admins only */"
|
LL | //"/*<2A> } <20>if isAdmin<69> <20> begin admins only */"
|
||||||
| ^^^^^-^^^-^^^^^^^^^^-^-^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^-^^^-^^^^^^^^^^-^-^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -112,7 +112,7 @@ LL | //"/*<2A> } <20>if isAdmin<69> <20> begin admins only */"
|
||||||
= help: if their presence wasn't intentional, you can remove them
|
= help: if their presence wasn't intentional, you can remove them
|
||||||
|
|
||||||
error: unicode codepoint changing visible direction of text present in literal
|
error: unicode codepoint changing visible direction of text present in literal
|
||||||
--> $DIR/unicode-control-codepoints.rs:11:22
|
--> $DIR/unicode-control-codepoints.rs:13:22
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", "/*<2A> } <20>if isAdmin<69> <20> begin admins only ");
|
LL | println!("{:?}", "/*<2A> } <20>if isAdmin<69> <20> begin admins only ");
|
||||||
| ^^^-^^^-^^^^^^^^^^-^-^^^^^^^^^^^^^^^^^^^^
|
| ^^^-^^^-^^^^^^^^^^-^-^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -132,7 +132,7 @@ LL | println!("{:?}", "/*\u{202e} } \u{2066}if isAdmin\u{2069} \u{2066} begi
|
||||||
| ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~
|
| ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~
|
||||||
|
|
||||||
error: unicode codepoint changing visible direction of text present in literal
|
error: unicode codepoint changing visible direction of text present in literal
|
||||||
--> $DIR/unicode-control-codepoints.rs:14:22
|
--> $DIR/unicode-control-codepoints.rs:16:22
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", r##"/*<2A> } <20>if isAdmin<69> <20> begin admins only "##);
|
LL | println!("{:?}", r##"/*<2A> } <20>if isAdmin<69> <20> begin admins only "##);
|
||||||
| ^^^^^^-^^^-^^^^^^^^^^-^-^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^-^^^-^^^^^^^^^^-^-^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -151,7 +151,7 @@ LL | println!("{:?}", r##"/*\u{202e} } \u{2066}if isAdmin\u{2069} \u{2066} b
|
||||||
| ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~
|
| ~~~~~~~~ ~~~~~~~~ ~~~~~~~~ ~~~~~~~~
|
||||||
|
|
||||||
error: unicode codepoint changing visible direction of text present in literal
|
error: unicode codepoint changing visible direction of text present in literal
|
||||||
--> $DIR/unicode-control-codepoints.rs:26:22
|
--> $DIR/unicode-control-codepoints.rs:28:22
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", '<27>');
|
LL | println!("{:?}", '<27>');
|
||||||
| ^-^
|
| ^-^
|
||||||
|
@ -166,8 +166,56 @@ help: if you want to keep them but make them visible in your source code, you ca
|
||||||
LL | println!("{:?}", '\u{202e}');
|
LL | println!("{:?}", '\u{202e}');
|
||||||
| ~~~~~~~~
|
| ~~~~~~~~
|
||||||
|
|
||||||
|
error: unicode codepoint changing visible direction of text present in literal
|
||||||
|
--> $DIR/unicode-control-codepoints.rs:31:13
|
||||||
|
|
|
||||||
|
LL | let _ = c"<22>";
|
||||||
|
| ^^-^
|
||||||
|
| | |
|
||||||
|
| | '\u{202e}'
|
||||||
|
| this literal contains an invisible unicode text flow control codepoint
|
||||||
|
|
|
||||||
|
= note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen
|
||||||
|
= help: if their presence wasn't intentional, you can remove them
|
||||||
|
help: if you want to keep them but make them visible in your source code, you can escape them
|
||||||
|
|
|
||||||
|
LL | let _ = c"\u{202e}";
|
||||||
|
| ~~~~~~~~
|
||||||
|
|
||||||
|
error: unicode codepoint changing visible direction of text present in literal
|
||||||
|
--> $DIR/unicode-control-codepoints.rs:33:13
|
||||||
|
|
|
||||||
|
LL | let _ = cr#"<22>"#;
|
||||||
|
| ^^^^-^^
|
||||||
|
| | |
|
||||||
|
| | '\u{202e}'
|
||||||
|
| this literal contains an invisible unicode text flow control codepoint
|
||||||
|
|
|
||||||
|
= note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen
|
||||||
|
= help: if their presence wasn't intentional, you can remove them
|
||||||
|
help: if you want to keep them but make them visible in your source code, you can escape them
|
||||||
|
|
|
||||||
|
LL | let _ = cr#"\u{202e}"#;
|
||||||
|
| ~~~~~~~~
|
||||||
|
|
||||||
|
error: unicode codepoint changing visible direction of text present in format string
|
||||||
|
--> $DIR/unicode-control-codepoints.rs:36:14
|
||||||
|
|
|
||||||
|
LL | println!("{{<7B>}}");
|
||||||
|
| ^^^-^^^
|
||||||
|
| | |
|
||||||
|
| | '\u{202e}'
|
||||||
|
| this format string contains an invisible unicode text flow control codepoint
|
||||||
|
|
|
||||||
|
= note: these kind of unicode codepoints change the way text flows on applications that support them, but can cause confusion because they change the order of characters on the screen
|
||||||
|
= help: if their presence wasn't intentional, you can remove them
|
||||||
|
help: if you want to keep them but make them visible in your source code, you can escape them
|
||||||
|
|
|
||||||
|
LL | println!("{{\u{202e}}}");
|
||||||
|
| ~~~~~~~~
|
||||||
|
|
||||||
error: unicode codepoint changing visible direction of text present in doc comment
|
error: unicode codepoint changing visible direction of text present in doc comment
|
||||||
--> $DIR/unicode-control-codepoints.rs:33:1
|
--> $DIR/unicode-control-codepoints.rs:43:1
|
||||||
|
|
|
|
||||||
LL | /** '<27>'); */fn foo() {}
|
LL | /** '<27>'); */fn foo() {}
|
||||||
| ^^^^^^^^^^^^^ this doc comment contains an invisible unicode text flow control codepoint
|
| ^^^^^^^^^^^^^ this doc comment contains an invisible unicode text flow control codepoint
|
||||||
|
@ -177,7 +225,7 @@ LL | /** '<27>'); */fn foo() {}
|
||||||
= note: if you want to keep them but make them visible in your source code, you can escape them: '\u{202e}'
|
= note: if you want to keep them but make them visible in your source code, you can escape them: '\u{202e}'
|
||||||
|
|
||||||
error: unicode codepoint changing visible direction of text present in doc comment
|
error: unicode codepoint changing visible direction of text present in doc comment
|
||||||
--> $DIR/unicode-control-codepoints.rs:36:1
|
--> $DIR/unicode-control-codepoints.rs:46:1
|
||||||
|
|
|
|
||||||
LL | / /**
|
LL | / /**
|
||||||
LL | | *
|
LL | | *
|
||||||
|
@ -188,5 +236,5 @@ LL | | * '<27>'); */fn bar() {}
|
||||||
= note: if their presence wasn't intentional, you can remove them
|
= note: if their presence wasn't intentional, you can remove them
|
||||||
= note: if you want to keep them but make them visible in your source code, you can escape them: '\u{202e}'
|
= note: if you want to keep them but make them visible in your source code, you can escape them: '\u{202e}'
|
||||||
|
|
||||||
error: aborting due to 17 previous errors
|
error: aborting due to 20 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue