Message ID | 20240130121026.807464-86-arthur.cohen@embecosm.com |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1189667dyb; Tue, 30 Jan 2024 04:40:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IH756QCakRi8/sbxMuF8k7YpwDuICCWCro0rgqMvAsA0g71hIyVpFl0fB7mXQatzM3/CZGc X-Received: by 2002:a05:620a:12d1:b0:783:cd88:c97a with SMTP id e17-20020a05620a12d100b00783cd88c97amr7870521qkl.16.1706618426646; Tue, 30 Jan 2024 04:40:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706618426; cv=pass; d=google.com; s=arc-20160816; b=WjO8cshuNLlxzNAdnOwjrEGYaXfu4LQ6G0rtRmJUTKkBgWGsvej0n+KxvKJ9t75OhZ pZJNiIgFYi3aUxZlJdi2CXjEQHXKfNh13bQl9DpoArNzsE9EUbQRm5IsDyGzznEQa/Gm C7p0PDkLgReJnDWNzV0LdJFPuGpmqTW28eNdfLWX4hjklb7FLGzhDDOnGwEJ/38oiuyE Sm+WgEhcYO9aejYsqMuDQSduh0yshrWXzsVGgE6R2sMWtT6/uLKHOlGBXTdWAAFN66Lf r8Q9K+DR2y/AEgYQ0CFeFWHSvAKtDaO7YZW2S4FkxfCqgmyLJPlMC65SD7wCFPjevlet nSBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=INjL0mXwk11RZ5qYUshsl68a1MU/pQHo+PS67zkndzA=; fh=tF/FjG7igJhcOEGq79wqr3ldeoZUVk5V7TNEGxaLUD4=; b=ANBGSFKGuHcXWF9HjqSevTgQvxLHd7AVK8W+RqqTmnZdYa5LOps4u6S10x2UXhnN1i qNQYJQV7rdw/XtR42VecmzPSRp1ehlhTavsX7ZxxGPDveTUf8pvCxn8Yuuk+4ttrB5CZ vlcoJNvU/ID/zobhKtUznA/ZhX+HiPA6YsYwgr9EcnNhdfvm+YqPNoku7iuihPQcMofu nBHGHtU9O/XoNBAbsq15vbQunnT5vMb1SKgvnPgkGfFKfGIC2rFtF87P5Hs4fQch4RG5 kuMqeG8lPngNJ20PPBC9gCYpcrvrPgsBpAD3sdNKpg8Xrr1zCYgfnaD2qejObbpOEymw wvXQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=LXY11vOu; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id q8-20020a05620a0d8800b00783aa61af29si10636129qkl.526.2024.01.30.04.40.26 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:40:26 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=LXY11vOu; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CFD0B384F020 for <ouuuleilei@gmail.com>; Tue, 30 Jan 2024 12:39:50 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 0845B38582A1 for <gcc-patches@gcc.gnu.org>; Tue, 30 Jan 2024 12:11:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0845B38582A1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0845B38582A1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::434 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616756; cv=none; b=CUkTMMrKTWGYVi70Tt70Wa1cJf5gF3gqUa2K/M3XMbZk5h/mrRWVvNrzaS5SnNsxb5w6HK4K7v5FVq6aIRuX/IdFrRx2/+N42ddANy2mMUP/8Dlcl/q50cNDQs9MH+DKA++UYKtTIaYH+k09jN180s4qrVKHlJcLVCrTiYfTYNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616756; c=relaxed/simple; bh=B4ADjOzKdm3sYx0AaonWIbwdt6jbi9atqLgpk8PdbCo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=HGoLmODq/MP/mhK4/537KsbhiAR+trk42hU4dFW+39IB5YMZlhQkZtA1XcSWKIfP+hG1KikJcajqk/AjqPoZlgSmlBlWFYmUwf/iiJ65o3DWpW0gP1i3lFNKR+dquvOduyPKBrY/ElQ/+DazE2UrhsIZycHV9NNtKMEuJ7gXcNE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-33ae2d80b70so1860343f8f.0 for <gcc-patches@gcc.gnu.org>; Tue, 30 Jan 2024 04:11:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1706616710; x=1707221510; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=INjL0mXwk11RZ5qYUshsl68a1MU/pQHo+PS67zkndzA=; b=LXY11vOupJF3dbMyrLbR6r5ZKWJ8S3F6//WxbMVQKMYUtMhS/M2Y7+4nqSNz+9Iw5x WpsIoGQDh6R38LCWVCv9KRVqgHAU5Ov1W+u5EqMlqGbjLDUsEBQ9UfJ0d4eqpdNKmZh1 XvLIsVpgAD4In47rCe9qwUOJWzuRJsLBG+FlKXdQrXjWBBLexaph1GkWuzcGsibD/uVa Ii5w6Ee5SQxVLmDAMpXnprE9O7Zs1/GltFcZQ1IiwooclJoEfH0AMcQQSROqGqrF1RxG nIwc6izW3eOgzm41cjCY5MqWdPxY+RkVRrvs32TTPtdC8mLpz2qMkoeD7vas6ePxgCbh 8AFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706616710; x=1707221510; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=INjL0mXwk11RZ5qYUshsl68a1MU/pQHo+PS67zkndzA=; b=AbXmVDg/wDUpww0Xvp45fZh6CKz2fkWoxlBcGHYcpPlTs8Ka/R953jUxxE+MJ0oMju Jv+hSzbUFuvAVTf7XHIIi6wXBN/oYPA2d4xWocjTsQCGLvpkgOaXYpwz/buyvmi0Eu6R lv5qsREs3fhqZABpYJU6pH3m0q3w5t3foBjFZydWJr0A4xUkSLXpnqQ2mNwLb1daKx/u YEkNH1E7hF0++lyCQG/r9/MmhmwSD56sxcW0YzLB+vDDT19kdJjBEI0khLaek1z4zhaY J+6sGnTdjSnU+NSwJRhCnuaqnbtgrvasrdFKalLIE++J186p8rNuwxk7iUDyUht2kvwB ztgw== X-Gm-Message-State: AOJu0YxFXrk1y4anTpj0KqIZZnLLL2ydF2vL7zaNT8hvatoaOCTwhiFK 1G8o47LF+mGx77XbiwkKrxzKi5bTsHi7ONgdMhn41VGa31N94uOWpvENpF02wRgS4jDZAHTj4qQ S0w== X-Received: by 2002:a5d:588a:0:b0:33a:f41e:f68b with SMTP id n10-20020a5d588a000000b0033af41ef68bmr4261432wrf.25.1706616710525; Tue, 30 Jan 2024 04:11:50 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id f9-20020a056000036900b00339307d9d31sm10569894wrf.112.2024.01.30.04.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:11:50 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Jakub Dupak <dev@jakubdupak.com> Subject: [COMMITTED 083/101] gccrs: ast: Unify explicitly and implicitly elided lifettimes Date: Tue, 30 Jan 2024 13:07:39 +0100 Message-ID: <20240130121026.807464-86-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240130121026.807464-2-arthur.cohen@embecosm.com> References: <20240130121026.807464-2-arthur.cohen@embecosm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Reply-To: arthur.cohen@embecosm.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789519123257421197 X-GMAIL-MSGID: 1789519123257421197 |
Series |
[COMMITTED,001/101] gccrs: Add visibility to trait item
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Arthur Cohen
Jan. 30, 2024, 12:07 p.m. UTC
From: Jakub Dupak <dev@jakubdupak.com> gcc/rust/ChangeLog: * ast/rust-ast.h: Elided lifetime static constructor * ast/rust-type.h: Default lifetime to elided. * parse/rust-parse-impl.h (Parser::parse_lifetime_param): Use elided lifetime. (Parser::parse_lifetime): Use elided lifetime/ (Parser::lifetime_from_token): Use elided lifetime. (Parser::parse_self_param): Use elided lifetime. (Parser::parse_reference_type_inner): Use elided lifetime. Signed-off-by: Jakub Dupak <dev@jakubdupak.com> --- gcc/rust/ast/rust-ast.h | 2 ++ gcc/rust/ast/rust-type.h | 2 +- gcc/rust/parse/rust-parse-impl.h | 10 ++++------ 3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index b193c67c69e..a45085489e8 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -1512,6 +1512,8 @@ public: // Creates an "error" lifetime. static Lifetime error () { return Lifetime (NAMED, ""); } + static Lifetime elided () { return Lifetime (WILDCARD, ""); } + // Returns true if the lifetime is in an error state. bool is_error () const { diff --git a/gcc/rust/ast/rust-type.h b/gcc/rust/ast/rust-type.h index 1637367791c..91a9d2f5999 100644 --- a/gcc/rust/ast/rust-type.h +++ b/gcc/rust/ast/rust-type.h @@ -547,7 +547,7 @@ public: // Constructor ReferenceType (bool is_mut, std::unique_ptr<TypeNoBounds> type_no_bounds, - location_t locus, Lifetime lifetime = Lifetime::error ()) + location_t locus, Lifetime lifetime = Lifetime::elided ()) : lifetime (std::move (lifetime)), has_mut (is_mut), type (std::move (type_no_bounds)), locus (locus) {} diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 90bc2e214e4..0e2cfce1e19 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -3470,8 +3470,6 @@ Parser<ManagedTokenSource>::parse_lifetime_param () return AST::LifetimeParam::create_error (); } lexer.skip_token (); - /* TODO: does this always create a named lifetime? or can a different type - * be made? */ AST::Lifetime lifetime (AST::Lifetime::NAMED, lifetime_tok->get_str (), lifetime_tok->get_locus ()); @@ -4141,10 +4139,9 @@ AST::Lifetime Parser<ManagedTokenSource>::parse_lifetime () { const_TokenPtr lifetime_tok = lexer.peek_token (); - // create error lifetime if doesn't exist if (lifetime_tok->get_id () != LIFETIME) { - return AST::Lifetime::error (); + return AST::Lifetime::elided (); } lexer.skip_token (); @@ -4164,6 +4161,7 @@ Parser<ManagedTokenSource>::lifetime_from_token (const_TokenPtr tok) } else if (lifetime_ident == "_") { + // Explicitly and implicitly elided lifetimes follow the same rules. return AST::Lifetime (AST::Lifetime::WILDCARD, "", locus); } else @@ -7177,7 +7175,7 @@ tl::expected<std::unique_ptr<AST::Param>, ParseSelfError> Parser<ManagedTokenSource>::parse_self_param () { bool has_reference = false; - AST::Lifetime lifetime = AST::Lifetime::error (); + AST::Lifetime lifetime = AST::Lifetime::elided (); location_t locus = lexer.peek_token ()->get_locus (); @@ -9837,7 +9835,7 @@ std::unique_ptr<AST::ReferenceType> Parser<ManagedTokenSource>::parse_reference_type_inner (location_t locus) { // parse optional lifetime - AST::Lifetime lifetime = AST::Lifetime::error (); + AST::Lifetime lifetime = AST::Lifetime::elided (); if (lexer.peek_token ()->get_id () == LIFETIME) { lifetime = parse_lifetime ();